summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/device_handler/scsi_dh.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-08-27 14:16:55 +0200
committerJames Bottomley <JBottomley@Odin.com>2015-08-28 22:14:55 +0200
commit566079c849cfe538e908c44ac11a9c4638db8f91 (patch)
tree02c85d770138d16929a764fd0cbea8628dbc54b9 /drivers/scsi/device_handler/scsi_dh.c
parentdm-mpath, scsi_dh: don't let dm detach device handlers (diff)
downloadlinux-566079c849cfe538e908c44ac11a9c4638db8f91.tar.xz
linux-566079c849cfe538e908c44ac11a9c4638db8f91.zip
dm-mpath, scsi_dh: request scsi_dh modules in scsi_dh, not dm-mpath
This way we can reused the same code any attachment method, not just those requested from dm-mpath. [jejb: fixup checkpatch error] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Acked-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: James Bottomley <JBottomley@Odin.com>
Diffstat (limited to 'drivers/scsi/device_handler/scsi_dh.c')
-rw-r--r--drivers/scsi/device_handler/scsi_dh.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh.c b/drivers/scsi/device_handler/scsi_dh.c
index 869b5bd1ad25..3dfef5b0d298 100644
--- a/drivers/scsi/device_handler/scsi_dh.c
+++ b/drivers/scsi/device_handler/scsi_dh.c
@@ -29,7 +29,7 @@
static DEFINE_SPINLOCK(list_lock);
static LIST_HEAD(scsi_dh_list);
-static struct scsi_device_handler *get_device_handler(const char *name)
+static struct scsi_device_handler *__scsi_dh_lookup(const char *name)
{
struct scsi_device_handler *tmp, *found = NULL;
@@ -44,6 +44,19 @@ static struct scsi_device_handler *get_device_handler(const char *name)
return found;
}
+static struct scsi_device_handler *scsi_dh_lookup(const char *name)
+{
+ struct scsi_device_handler *dh;
+
+ dh = __scsi_dh_lookup(name);
+ if (!dh) {
+ request_module(name);
+ dh = __scsi_dh_lookup(name);
+ }
+
+ return dh;
+}
+
/*
* device_handler_match_function - Match a device handler to a device
* @sdev - SCSI device to be tested
@@ -158,7 +171,8 @@ store_dh_state(struct device *dev, struct device_attribute *attr,
/*
* Attach to a device handler
*/
- if (!(scsi_dh = get_device_handler(buf)))
+ scsi_dh = scsi_dh_lookup(buf);
+ if (!scsi_dh)
return err;
err = scsi_dh_handler_attach(sdev, scsi_dh);
} else {
@@ -322,8 +336,7 @@ static int scsi_dh_notifier_remove(struct device *dev, void *data)
*/
int scsi_register_device_handler(struct scsi_device_handler *scsi_dh)
{
-
- if (get_device_handler(scsi_dh->name))
+ if (__scsi_dh_lookup(scsi_dh->name))
return -EBUSY;
if (!scsi_dh->attach || !scsi_dh->detach)
@@ -350,7 +363,7 @@ EXPORT_SYMBOL_GPL(scsi_register_device_handler);
int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh)
{
- if (!get_device_handler(scsi_dh->name))
+ if (!__scsi_dh_lookup(scsi_dh->name))
return -ENODEV;
bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh,
@@ -455,17 +468,6 @@ int scsi_dh_set_params(struct request_queue *q, const char *params)
EXPORT_SYMBOL_GPL(scsi_dh_set_params);
/*
- * scsi_dh_handler_exist - Return TRUE(1) if a device handler exists for
- * the given name. FALSE(0) otherwise.
- * @name - name of the device handler.
- */
-int scsi_dh_handler_exist(const char *name)
-{
- return (get_device_handler(name) != NULL);
-}
-EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);
-
-/*
* scsi_dh_attach - Attach device handler
* @q - Request queue that is associated with the scsi_device
* the handler should be attached to
@@ -478,7 +480,7 @@ int scsi_dh_attach(struct request_queue *q, const char *name)
struct scsi_device_handler *scsi_dh;
int err = 0;
- scsi_dh = get_device_handler(name);
+ scsi_dh = scsi_dh_lookup(name);
if (!scsi_dh)
return -EINVAL;