Commit 566079c8 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Acked-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
parent 1bab0de0
...@@ -725,12 +725,6 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m) ...@@ -725,12 +725,6 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)
return 0; return 0;
m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL); m->hw_handler_name = kstrdup(dm_shift_arg(as), GFP_KERNEL);
if (!try_then_request_module(scsi_dh_handler_exist(m->hw_handler_name),
"scsi_dh_%s", m->hw_handler_name)) {
ti->error = "unknown hardware handler type";
ret = -EINVAL;
goto fail;
}
if (hw_argc > 1) { if (hw_argc > 1) {
char *p; char *p;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
static DEFINE_SPINLOCK(list_lock); static DEFINE_SPINLOCK(list_lock);
static LIST_HEAD(scsi_dh_list); 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; struct scsi_device_handler *tmp, *found = NULL;
...@@ -44,6 +44,19 @@ static struct scsi_device_handler *get_device_handler(const char *name) ...@@ -44,6 +44,19 @@ static struct scsi_device_handler *get_device_handler(const char *name)
return found; 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 * device_handler_match_function - Match a device handler to a device
* @sdev - SCSI device to be tested * @sdev - SCSI device to be tested
...@@ -158,7 +171,8 @@ store_dh_state(struct device *dev, struct device_attribute *attr, ...@@ -158,7 +171,8 @@ store_dh_state(struct device *dev, struct device_attribute *attr,
/* /*
* Attach to a device handler * Attach to a device handler
*/ */
if (!(scsi_dh = get_device_handler(buf))) scsi_dh = scsi_dh_lookup(buf);
if (!scsi_dh)
return err; return err;
err = scsi_dh_handler_attach(sdev, scsi_dh); err = scsi_dh_handler_attach(sdev, scsi_dh);
} else { } else {
...@@ -322,8 +336,7 @@ static int scsi_dh_notifier_remove(struct device *dev, void *data) ...@@ -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) int scsi_register_device_handler(struct scsi_device_handler *scsi_dh)
{ {
if (__scsi_dh_lookup(scsi_dh->name))
if (get_device_handler(scsi_dh->name))
return -EBUSY; return -EBUSY;
if (!scsi_dh->attach || !scsi_dh->detach) if (!scsi_dh->attach || !scsi_dh->detach)
...@@ -350,7 +363,7 @@ EXPORT_SYMBOL_GPL(scsi_register_device_handler); ...@@ -350,7 +363,7 @@ EXPORT_SYMBOL_GPL(scsi_register_device_handler);
int scsi_unregister_device_handler(struct scsi_device_handler *scsi_dh) 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; return -ENODEV;
bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh, bus_for_each_dev(&scsi_bus_type, NULL, scsi_dh,
...@@ -454,17 +467,6 @@ int scsi_dh_set_params(struct request_queue *q, const char *params) ...@@ -454,17 +467,6 @@ int scsi_dh_set_params(struct request_queue *q, const char *params)
} }
EXPORT_SYMBOL_GPL(scsi_dh_set_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 * scsi_dh_attach - Attach device handler
* @q - Request queue that is associated with the scsi_device * @q - Request queue that is associated with the scsi_device
...@@ -478,7 +480,7 @@ int scsi_dh_attach(struct request_queue *q, const char *name) ...@@ -478,7 +480,7 @@ int scsi_dh_attach(struct request_queue *q, const char *name)
struct scsi_device_handler *scsi_dh; struct scsi_device_handler *scsi_dh;
int err = 0; int err = 0;
scsi_dh = get_device_handler(name); scsi_dh = scsi_dh_lookup(name);
if (!scsi_dh) if (!scsi_dh)
return -EINVAL; return -EINVAL;
......
...@@ -57,7 +57,6 @@ enum { ...@@ -57,7 +57,6 @@ enum {
}; };
#if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE) #if defined(CONFIG_SCSI_DH) || defined(CONFIG_SCSI_DH_MODULE)
extern int scsi_dh_activate(struct request_queue *, activate_complete, void *); extern int scsi_dh_activate(struct request_queue *, activate_complete, void *);
extern int scsi_dh_handler_exist(const char *);
extern int scsi_dh_attach(struct request_queue *, const char *); extern int scsi_dh_attach(struct request_queue *, const char *);
extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t); extern const char *scsi_dh_attached_handler_name(struct request_queue *, gfp_t);
extern int scsi_dh_set_params(struct request_queue *, const char *); extern int scsi_dh_set_params(struct request_queue *, const char *);
...@@ -68,10 +67,6 @@ static inline int scsi_dh_activate(struct request_queue *req, ...@@ -68,10 +67,6 @@ static inline int scsi_dh_activate(struct request_queue *req,
fn(data, 0); fn(data, 0);
return 0; return 0;
} }
static inline int scsi_dh_handler_exist(const char *name)
{
return 0;
}
static inline int scsi_dh_attach(struct request_queue *req, const char *name) static inline int scsi_dh_attach(struct request_queue *req, const char *name)
{ {
return SCSI_DH_NOSYS; return SCSI_DH_NOSYS;
......
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