Patch "scsi: use 'scsi_device_from_queue()' for scsi_dh" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
scsi: use 'scsi_device_from_queue()' for scsi_dh
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
scsi-use-scsi_device_from_queue-for-scsi_dh.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
857de6e00778738dc3d61f75acbac35bdc48e533Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Fri, 17 Feb 2017 09:02:45 +0100
Subject: scsi: use 'scsi_device_from_queue()' for scsi_dh
From: Hannes Reinecke <[email protected]>
commit 857de6e00778738dc3d61f75acbac35bdc48e533 upstream.
The device handler needs to check if a given queue belongs to a scsi device; only then does it make sense to attach a device handler.
[mkp: dropped flags]
--- drivers/scsi/scsi_dh.c | 22 ++++------------------ drivers/scsi/scsi_lib.c | 23 +++++++++++++++++++++++ include/scsi/scsi_device.h | 1 + 3 files changed, 28 insertions(+), 18 deletions(-)
drivers/scsi/scsi_dh.c +4 -18
@@ -289,20 +289,6 @@ int scsi_unregister_device_handler(struc }EXPORT_SYMBOL_GPL (scsi_unregister_device_handler); -static struct scsi_device *get_sdev_from_queue (struct request_queue *q) -{ -struct scsi_device *sdev; -unsigned long flags; - -spin_lock_irqsave (q->queue_lock, flags); - sdev = q->queuedata; -if (!sdev || !get_device (&sdev->sdev_gendev)) - sdev =NULL ; -spin_unlock_irqrestore (q->queue_lock, flags); - -return sdev; -} -/* * scsi_dh_activate - activate the path associated with the scsi_device * corresponding to the given request queue.
@@ -321,7 +307,7 @@ int scsi_dh_activate(struct request_queustruct scsi_device *sdev;int err =SCSI_DH_NOSYS ; - sdev =get_sdev_from_queue (q); + sdev =scsi_device_from_queue (q);if (!sdev) {if (fn)fn (data, err);
@@ -368,7 +354,7 @@ int scsi_dh_set_params(struct request_qustruct scsi_device *sdev;int err = -SCSI_DH_NOSYS ; - sdev =get_sdev_from_queue (q); + sdev =scsi_device_from_queue (q);if (!sdev)return err;
@@ -391,7 +377,7 @@ int scsi_dh_attach(struct request_queuestruct scsi_device_handler *scsi_dh;int err =0 ; - sdev =get_sdev_from_queue (q); + sdev =scsi_device_from_queue (q);if (!sdev)return -ENODEV ;
@@ -429,7 +415,7 @@ const char *scsi_dh_attached_handler_namstruct scsi_device *sdev;const char *handler_name =NULL ; - sdev =get_sdev_from_queue (q); + sdev =scsi_device_from_queue (q);if (!sdev)return NULL ;
drivers/scsi/scsi_lib.c +23 -0
@@ -2215,6 +2215,29 @@ void scsi_mq_destroy_tags(struct Scsi_Hoblk_mq_free_tag_set (&shost->tag_set); } +/** +* scsi_device_from_queue - return sdev associated with a request_queue +* @q: The request queue to return the sdev from +* +* Return the sdev associated with a request queue or NULL if the +* request_queue does not reference a SCSI device. +*/ +struct scsi_device *scsi_device_from_queue (struct request_queue *q) +{ +struct scsi_device *sdev =NULL ; + +if (q->mq_ops) { +if (q->mq_ops == &scsi_mq_ops) + sdev = q->queuedata; + }else if (q->request_fn == scsi_request_fn) + sdev = q->queuedata; +if (!sdev || !get_device (&sdev->sdev_gendev)) + sdev =NULL ; + +return sdev; +} +EXPORT_SYMBOL_GPL (scsi_device_from_queue); +/* * Function: scsi_block_requests() *
include/scsi/scsi_device.h +1 -0
@@ -307,6 +307,7 @@ extern void scsi_remove_device(struct scextern int scsi_unregister_device_handler (struct scsi_device_handler *scsi_dh);void scsi_attach_vpd (struct scsi_device *sdev); +extern struct scsi_device *scsi_device_from_queue (struct request_queue *q);extern int scsi_device_get (struct scsi_device *);extern void scsi_device_put (struct scsi_device *); extern struct scsi_device *scsi_device_lookup(struct Scsi_Host *,
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/sd-get-disk-reference-in-sd_check_events.patch queue-4.4/scsi-use-scsi_device_from_queue-for-scsi_dh.patch