提交 a500c4cc 编写于 作者: B Bart Van Assche 提交者: Martin K. Petersen

scsi: device_handler: alua: Revert "Move a scsi_device_put() call out of alua_check_vpd()"

There is a bug in commit 0b25e17e ("scsi: alua: Move a
scsi_device_put() call out of alua_check_vpd()"): that patch may cause
alua_rtpg_queue() callers to call scsi_device_put() even if that function
should not be called. Revert that commit to prepare for a different
solution.

Cc: Hannes Reinecke <hare@suse.de>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Sachin Sant <sachinp@linux.ibm.com>
Cc: Benjamin Block <bblock@linux.ibm.com>
Reported-by: NSachin Sant <sachinp@linux.ibm.com>
Reported-by: NBenjamin Block <bblock@linux.ibm.com>
Signed-off-by: NBart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20221117183626.2656196-2-bvanassche@acm.orgTested-by: NSachin Sant <sachinp@linux.ibm.com>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
上级 e118df49
...@@ -324,7 +324,6 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h, ...@@ -324,7 +324,6 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h,
struct alua_port_group *pg, *old_pg = NULL; struct alua_port_group *pg, *old_pg = NULL;
bool pg_updated = false; bool pg_updated = false;
unsigned long flags; unsigned long flags;
bool put_sdev;
group_id = scsi_vpd_tpg_id(sdev, &rel_port); group_id = scsi_vpd_tpg_id(sdev, &rel_port);
if (group_id < 0) { if (group_id < 0) {
...@@ -374,14 +373,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h, ...@@ -374,14 +373,11 @@ static int alua_check_vpd(struct scsi_device *sdev, struct alua_dh_data *h,
list_add_rcu(&h->node, &pg->dh_list); list_add_rcu(&h->node, &pg->dh_list);
spin_unlock_irqrestore(&pg->lock, flags); spin_unlock_irqrestore(&pg->lock, flags);
put_sdev = alua_rtpg_queue(rcu_dereference_protected(h->pg, alua_rtpg_queue(rcu_dereference_protected(h->pg,
lockdep_is_held(&h->pg_lock)), lockdep_is_held(&h->pg_lock)),
sdev, NULL, true); sdev, NULL, true);
spin_unlock(&h->pg_lock); spin_unlock(&h->pg_lock);
if (put_sdev)
scsi_device_put(sdev);
if (old_pg) if (old_pg)
kref_put(&old_pg->kref, release_port_group); kref_put(&old_pg->kref, release_port_group);
...@@ -982,10 +978,9 @@ static void alua_rtpg_work(struct work_struct *work) ...@@ -982,10 +978,9 @@ static void alua_rtpg_work(struct work_struct *work)
* RTPG already has been scheduled. * RTPG already has been scheduled.
* *
* Returns true if and only if alua_rtpg_work() will be called asynchronously. * Returns true if and only if alua_rtpg_work() will be called asynchronously.
* That function is responsible for calling @qdata->fn(). If this function * That function is responsible for calling @qdata->fn().
* returns true, the caller is responsible for invoking scsi_device_put(@sdev).
*/ */
static bool __must_check 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)
{ {
...@@ -1024,6 +1019,8 @@ static bool __must_check alua_rtpg_queue(struct alua_port_group *pg, ...@@ -1024,6 +1019,8 @@ static bool __must_check alua_rtpg_queue(struct alua_port_group *pg,
else else
kref_put(&pg->kref, release_port_group); kref_put(&pg->kref, release_port_group);
} }
if (sdev)
scsi_device_put(sdev);
return true; return true;
} }
...@@ -1130,12 +1127,10 @@ static int alua_activate(struct scsi_device *sdev, ...@@ -1130,12 +1127,10 @@ static int alua_activate(struct scsi_device *sdev,
rcu_read_unlock(); rcu_read_unlock();
mutex_unlock(&h->init_mutex); mutex_unlock(&h->init_mutex);
if (alua_rtpg_queue(pg, sdev, qdata, true)) { if (alua_rtpg_queue(pg, sdev, qdata, true))
scsi_device_put(sdev);
fn = NULL; fn = NULL;
} else { else
err = SCSI_DH_DEV_OFFLINED; 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)
...@@ -1161,9 +1156,7 @@ static void alua_check(struct scsi_device *sdev, bool force) ...@@ -1161,9 +1156,7 @@ static void alua_check(struct scsi_device *sdev, bool force)
return; return;
} }
rcu_read_unlock(); rcu_read_unlock();
alua_rtpg_queue(pg, sdev, NULL, force);
if (alua_rtpg_queue(pg, sdev, NULL, force))
scsi_device_put(sdev);
kref_put(&pg->kref, release_port_group); kref_put(&pg->kref, release_port_group);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册