[PATCH 09/13] scsi: alua: Add scsi_alua_handle_state_transition()

John Garry posted 13 patches 2 weeks, 6 days ago
[PATCH 09/13] scsi: alua: Add scsi_alua_handle_state_transition()
Posted by John Garry 2 weeks, 6 days ago
Add an equivalent of alua_handle_state_transition() from scsi_dh_alua.c

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 drivers/scsi/scsi_alua.c | 11 +++++++++++
 include/scsi/scsi_alua.h |  5 +++++
 2 files changed, 16 insertions(+)

diff --git a/drivers/scsi/scsi_alua.c b/drivers/scsi/scsi_alua.c
index 9c317e60d031e..d19d1845bc324 100644
--- a/drivers/scsi/scsi_alua.c
+++ b/drivers/scsi/scsi_alua.c
@@ -40,6 +40,17 @@ static struct workqueue_struct *kalua_wq;
 #define ALUA_RTPG_DELAY_MSECS		5
 #define ALUA_RTPG_RETRY_DELAY		2
 
+void scsi_alua_handle_state_transition(struct scsi_device *sdev)
+{
+	struct alua_data *alua = sdev->alua;
+	unsigned long flags;
+
+	spin_lock_irqsave(&alua->lock, flags);
+	alua->state = SCSI_ACCESS_STATE_TRANSITIONING;
+	spin_unlock_irqrestore(&alua->lock, flags);
+}
+EXPORT_SYMBOL_GPL(scsi_alua_handle_state_transition);
+
 /*
  * alua_tur - Send a TEST UNIT READY
  * @sdev: device to which the TEST UNIT READY command should be send
diff --git a/include/scsi/scsi_alua.h b/include/scsi/scsi_alua.h
index 2e664f20d9681..5b3a12861658f 100644
--- a/include/scsi/scsi_alua.h
+++ b/include/scsi/scsi_alua.h
@@ -30,6 +30,8 @@ struct alua_data {
 int scsi_alua_sdev_init(struct scsi_device *sdev);
 void scsi_alua_sdev_exit(struct scsi_device *sdev);
 
+void scsi_alua_handle_state_transition(struct scsi_device *sdev);
+
 int scsi_alua_check_tpgs(struct scsi_device *sdev);
 
 int scsi_alua_rtpg_run(struct scsi_device *sdev);
@@ -39,6 +41,9 @@ int scsi_alua_init(void);
 void scsi_exit_alua(void);
 #else //CONFIG_SCSI_ALUA
 
+static inline void scsi_alua_handle_state_transition(struct scsi_device *sdev)
+{
+}
 static inline int scsi_alua_check_tpgs(struct scsi_device *sdev)
 {
 	return 0;
-- 
2.43.5
Re: [PATCH 09/13] scsi: alua: Add scsi_alua_handle_state_transition()
Posted by Hannes Reinecke 2 weeks, 5 days ago
On 3/17/26 13:06, John Garry wrote:
> Add an equivalent of alua_handle_state_transition() from scsi_dh_alua.c
> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>   drivers/scsi/scsi_alua.c | 11 +++++++++++
>   include/scsi/scsi_alua.h |  5 +++++
>   2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/scsi/scsi_alua.c b/drivers/scsi/scsi_alua.c
> index 9c317e60d031e..d19d1845bc324 100644
> --- a/drivers/scsi/scsi_alua.c
> +++ b/drivers/scsi/scsi_alua.c
> @@ -40,6 +40,17 @@ static struct workqueue_struct *kalua_wq;
>   #define ALUA_RTPG_DELAY_MSECS		5
>   #define ALUA_RTPG_RETRY_DELAY		2
>   
> +void scsi_alua_handle_state_transition(struct scsi_device *sdev)
> +{
> +	struct alua_data *alua = sdev->alua;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&alua->lock, flags);
> +	alua->state = SCSI_ACCESS_STATE_TRANSITIONING;
> +	spin_unlock_irqrestore(&alua->lock, flags);
> +}
> +EXPORT_SYMBOL_GPL(scsi_alua_handle_state_transition);
> +
>   /*
>    * alua_tur - Send a TEST UNIT READY
>    * @sdev: device to which the TEST UNIT READY command should be send
> diff --git a/include/scsi/scsi_alua.h b/include/scsi/scsi_alua.h
> index 2e664f20d9681..5b3a12861658f 100644
> --- a/include/scsi/scsi_alua.h
> +++ b/include/scsi/scsi_alua.h
> @@ -30,6 +30,8 @@ struct alua_data {
>   int scsi_alua_sdev_init(struct scsi_device *sdev);
>   void scsi_alua_sdev_exit(struct scsi_device *sdev);
>   
> +void scsi_alua_handle_state_transition(struct scsi_device *sdev);
> +
>   int scsi_alua_check_tpgs(struct scsi_device *sdev);
>   
>   int scsi_alua_rtpg_run(struct scsi_device *sdev);
> @@ -39,6 +41,9 @@ int scsi_alua_init(void);
>   void scsi_exit_alua(void);
>   #else //CONFIG_SCSI_ALUA
>   
> +static inline void scsi_alua_handle_state_transition(struct scsi_device *sdev)
> +{
> +}
>   static inline int scsi_alua_check_tpgs(struct scsi_device *sdev)
>   {
>   	return 0;

???
This doesn't handle a state transition, it just _sets_ the state 
transition. Please fold it into the patch where the state transition
is actually handled.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH 09/13] scsi: alua: Add scsi_alua_handle_state_transition()
Posted by John Garry 2 weeks ago
On 18/03/2026 07:58, Hannes Reinecke wrote:
>>   int scsi_alua_check_tpgs(struct scsi_device *sdev);
>>   int scsi_alua_rtpg_run(struct scsi_device *sdev);
>> @@ -39,6 +41,9 @@ int scsi_alua_init(void);
>>   void scsi_exit_alua(void);
>>   #else //CONFIG_SCSI_ALUA
>> +static inline void scsi_alua_handle_state_transition(struct 
>> scsi_device *sdev)
>> +{
>> +}
>>   static inline int scsi_alua_check_tpgs(struct scsi_device *sdev)
>>   {
>>       return 0;
> 
> ???
> This doesn't handle a state transition, it just _sets_ the state 
> transition. Please fold it into the patch where the state transition
> is actually handled.

Sure, doing it like this is a bit silly.

Thanks,
John