Commit ef97d948 authored by Bart Van Assche's avatar Bart Van Assche Committed by Greg Kroah-Hartman

scsi: scsi_dh_alua: Ensure that alua_activate() calls the completion function

commit 7cb689fe upstream.

Callers of scsi_dh_activate(), e.g. dm-mpath, assume that this function
either returns an error code or calls the completion function. Make
alua_activate() call the completion function even if scsi_device_get()
fails.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Tang Junhui <tang.junhui@zte.com.cn>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2b1725d1
...@@ -113,7 +113,7 @@ struct alua_queue_data { ...@@ -113,7 +113,7 @@ struct alua_queue_data {
#define ALUA_POLICY_SWITCH_ALL 1 #define ALUA_POLICY_SWITCH_ALL 1
static void alua_rtpg_work(struct work_struct *work); static void alua_rtpg_work(struct work_struct *work);
static void alua_rtpg_queue(struct alua_port_group *pg, static bool alua_rtpg_queue(struct alua_port_group *pg,
struct scsi_device *sdev, struct scsi_device *sdev,
struct alua_queue_data *qdata, bool force); struct alua_queue_data *qdata, bool force);
static void alua_check(struct scsi_device *sdev, bool force); static void alua_check(struct scsi_device *sdev, bool force);
...@@ -866,7 +866,13 @@ static void alua_rtpg_work(struct work_struct *work) ...@@ -866,7 +866,13 @@ static void alua_rtpg_work(struct work_struct *work)
kref_put(&pg->kref, release_port_group); kref_put(&pg->kref, release_port_group);
} }
static void alua_rtpg_queue(struct alua_port_group *pg, /**
* alua_rtpg_queue() - cause RTPG to be submitted asynchronously
*
* Returns true if and only if alua_rtpg_work() will be called asynchronously.
* That function is responsible for calling @qdata->fn().
*/
static bool alua_rtpg_queue(struct alua_port_group *pg,
struct scsi_device *sdev, struct scsi_device *sdev,
struct alua_queue_data *qdata, bool force) struct alua_queue_data *qdata, bool force)
{ {
...@@ -875,7 +881,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg, ...@@ -875,7 +881,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
struct workqueue_struct *alua_wq = kaluad_wq; struct workqueue_struct *alua_wq = kaluad_wq;
if (!pg || scsi_device_get(sdev)) if (!pg || scsi_device_get(sdev))
return; return false;
spin_lock_irqsave(&pg->lock, flags); spin_lock_irqsave(&pg->lock, flags);
if (qdata) { if (qdata) {
...@@ -911,6 +917,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg, ...@@ -911,6 +917,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
} }
if (sdev) if (sdev)
scsi_device_put(sdev); scsi_device_put(sdev);
return true;
} }
/* /*
...@@ -1011,11 +1019,13 @@ static int alua_activate(struct scsi_device *sdev, ...@@ -1011,11 +1019,13 @@ static int alua_activate(struct scsi_device *sdev,
mutex_unlock(&h->init_mutex); mutex_unlock(&h->init_mutex);
goto out; goto out;
} }
fn = NULL;
rcu_read_unlock(); rcu_read_unlock();
mutex_unlock(&h->init_mutex); mutex_unlock(&h->init_mutex);
alua_rtpg_queue(pg, sdev, qdata, true); if (alua_rtpg_queue(pg, sdev, qdata, true))
fn = NULL;
else
err = SCSI_DH_DEV_OFFLINED;
kref_put(&pg->kref, release_port_group); kref_put(&pg->kref, release_port_group);
out: out:
if (fn) if (fn)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment