dm mpath: add 'default_hw_handler' and 'no_partitions' features
Subsystems (2)
v2 cover dm mpath: add 'default_hw_handler' and 'no_partitions' features
I've included all related patches in this v2 post simply to eliminate any confusion with all the patches that have been in-flight from Hannes and I. Patches 1 and 2 are unchanged from previous posts.
Patch 4 is the combination of the different approaches Hannes and I took. I pushed the 'no_partitions' feature patch (5) to the end of the series because it seemed more natural.
Hannes Reinecke (2):
dm mpath: add 'default_hw_handler' feature dm mpath: add ability to disable partition creation
Mike Snitzer (3):
dm mpath: only try to load the scsi_dh module if the scsi_dh doesn't exist
scsi_dh: add scsi_dh_attached_handler_name
dm mpath: reduce size of multipath structure
drivers/md/dm-mpath.c | 53 +++++++++++++++++++++++++------- drivers/scsi/device_handler/scsi_dh.c | 31 ++++++++++++++++++- include/scsi/scsi_dh.h | 5 +++ 3 files changed, 75 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.4.4
PATCH v2 1/5 dm mpath: only try to load the scsi_dh module if the scsi_dh doesn't exist
There have been reports of multipath table loads hanging due to __request_module hanging (for some unknown reason).
More often than not, the scsi_dh is already available and there is no need to request_module().
--- drivers/md/dm-mpath.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +2 -2
@@ -718,8 +718,8 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)return 0 ; m->hw_handler_name =kstrdup (dm_shift_arg (as),GFP_KERNEL ); -request_module ("scsi_dh_%s" , m->hw_handler_name); -if (scsi_dh_handler_exist (m->hw_handler_name) ==0 ) { +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;
Signature · 1 line
1.7.4.4
Re: [PATCH v2 1/5] dm mpath: only try to load the scsi_dh module if the scsi_dh doesn't exist
Quoted 17 lines · Mike Snitzer
There have been reports of multipath table loads hanging due to
__request_modulehanging (for some unknown reason).More often than not, the
scsi_dhis already available and there is no need torequest_module().Reported-by Ben Marzinski <[email protected]>Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/md/dm-mpath.c +0
-0
drivers/md/dm-mpath.c static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m) · line 725
Quoted 10 lines
drivers/md/dm-mpath.c +2
-2@@ -718,8 +718,8 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)return 0 ; m->hw_handler_name =kstrdup (dm_shift_arg (as),GFP_KERNEL ); -request_module ("scsi_dh_%s" , m->hw_handler_name); -if (scsi_dh_handler_exist (m->hw_handler_name) ==0 ) { +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;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH v2 1/5] dm mpath: only try to load the scsi_dh module if the scsi_dh doesn't exist
In reply to Mike SnitzerQuoted 27 lines · Mike Snitzer
There have been reports of multipath table loads hanging due to
__request_modulehanging (for some unknown reason).More often than not, the
scsi_dhis already available and there is no need torequest_module().Reported-by Ben Marzinski <[email protected]>Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/md/dm-mpath.c +2
-2@@ -718,8 +718,8 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m)return 0 ; m->hw_handler_name =kstrdup (dm_shift_arg (as),GFP_KERNEL ); -request_module ("scsi_dh_%s" , m->hw_handler_name); -if (scsi_dh_handler_exist (m->hw_handler_name) ==0 ) { +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;
PATCH v2 2/5 scsi_dh: add scsi_dh_attached_handler_name
In reply to Mike SnitzerIntroduce scsi_dh_attached_handler_name() to retrieve the name of the scsi_dh that is attached to the scsi_device associated with the provided request queue. Returns NULL if a scsi_dh is not attached.
Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
--- drivers/scsi/device_handler/scsi_dh.c | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 +++++ 2 files changed, 34 insertions(+), 2 deletions(-)
drivers/scsi/device_handler/scsi_dh.c +29 -2
@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)
@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie
@@ -527,6 +529,31 @@ void scsi_dh_detach(struct request_queue *q) }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached scsi_dh, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; + +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); + +if (!sdev || !sdev->scsi_dh_data) +return NULL ; + +return sdev->scsi_dh_data->scsi_dh->name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };
include/scsi/scsi_dh.h +5 -0
@@ -60,6 +60,7 @@ 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 void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,
@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct request_queue *q) {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
Signature · 1 line
1.7.4.4
Re: [PATCH v2 2/5] scsi_dh: add scsi_dh_attached_handler_name
Quoted 82 lines · Mike Snitzer
Introduce
scsi_dh_attached_handler_name()to retrieve the name of thescsi_dhthat is attached to thescsi_deviceassociated with the provided request queue. Returns NULL if ascsi_dhis not attached.Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
Signed-off-by Mike Snitzer <[email protected]>--- drivers/scsi/device_handler/scsi_dh.c | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 +++++ 2 files changed, 34 insertions(+), 2 deletions(-)drivers/scsi/device_handler/scsi_dh.c +29
-2@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie @@ -527,6 +529,31 @@ void scsi_dh_detach(struct request_queue *q) }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached scsi_dh, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; + +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); + +if (!sdev || !sdev->scsi_dh_data) +return NULL ; + +return sdev->scsi_dh_data->scsi_dh->name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };include/scsi/scsi_dh.h +1
-0@@ -60,6 +60,7 @@ 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 void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,
include/scsi/scsi_dh.h static inline void scsi_dh_detach(struct request_queue *q) · line 90
Quoted 10 lines
include/scsi/scsi_dh.h +4
-0@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct request_queue *q) {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
Re: [PATCH v2 2/5] scsi_dh: add scsi_dh_attached_handler_name
In reply to Mike SnitzerMike, I have a question for you below.
Quoted 64 lines
-----Original Message-----
From: Mike Snitzer [mailto:[email protected]]
Sent: Tuesday, May 08, 2012 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; Moger, Babu; [email protected]; Mike Snitzer
Subject: [PATCH v2 2/5]scsi_dh: addscsi_dh_attached_handler_nameIntroduce
scsi_dh_attached_handler_name()to retrieve the name of thescsi_dhthat is attached to thescsi_deviceassociated with the provided request queue. Returns NULL if ascsi_dhis not attached.Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
Signed-off-by Mike Snitzer <[email protected]>--- drivers/scsi/device_handler/scsi_dh.c | 31 +++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 +++++ 2 files changed, 34 insertions(+), 2 deletions(-)drivers/scsi/device_handler/scsi_dh.c +17
-2@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist);/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie @@ -527,6 +529,31 @@ void scsi_dh_detach(struct request_queue *q) }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached scsi_dh, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; + +spin_lock_irqsave (q->queue_lock, flags);
drivers/scsi/device_handler/scsi_dh.c void scsi_dh_detach(struct request_queue *q) · line 554
Quoted 10 lines
drivers/scsi/device_handler/scsi_dh.c +10
-0+ sdev = q->queuedata; +if (!sdev || !get_device (&sdev->sdev_gendev)) + sdev =NULL ; +spin_unlock_irqrestore (q->queue_lock, flags); + +if (!sdev || !sdev->scsi_dh_data) +return NULL ; + +return sdev->scsi_dh_data->scsi_dh->name; +}
I only see get_device call. I don't see matching put_device call. Was that on purspose?
Quoted 35 lines
drivers/scsi/device_handler/scsi_dh.c +2
-0+EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };include/scsi/scsi_dh.h +1
-0@@ -60,6 +60,7 @@ 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 void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else
static inline int scsi_dh_activate(structrequest_queue*req,include/scsi/scsi_dh.h +4
-0@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct request_queue *q) {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +} static inline int scsi_dh_set_params(struct request_queue *req, const char*params)
{
return -SCSI_DH_NOSYS;
--
1.7.4.4
PATCH v3 2/5 scsi_dh: add scsi_dh_attached_handler_name
Introduce scsi_dh_attached_handler_name() to retrieve the name of the scsi_dh that is attached to the scsi_device associated with the provided request queue. Returns NULL if a scsi_dh is not attached.
Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
--- drivers/scsi/device_handler/scsi_dh.c | 36 ++++++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 ++++ 2 files changed, 39 insertions(+), 2 deletions(-)
v3: fixed missing put_device that Babu pointed out
drivers/scsi/device_handler/scsi_dh.c +34 -2
@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist)/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)
@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie
@@ -527,6 +529,36 @@ void scsi_dh_detach(struct request_queue }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached handler, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; +const char *handler_name =NULL ; + +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); + +if (!sdev) +return NULL ; + +if (sdev->scsi_dh_data) + handler_name = sdev->scsi_dh_data->scsi_dh->name; + +put_device (&sdev->sdev_gendev); +return handler_name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };
include/scsi/scsi_dh.h +5 -0
@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct requeextern int scsi_dh_handler_exist (const char *);extern int scsi_dh_attach (struct request_queue *,const char *);extern void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,
@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
Re: [PATCH v3 2/5] scsi_dh: add scsi_dh_attached_handler_name
Mike, you may have to cross post to linux-scsi for James to pick it up.
Quoted 100 lines · Mike Snitzer
Introduce
scsi_dh_attached_handler_name()to retrieve the name of thescsi_dhthat is attached to thescsi_deviceassociated with the provided request queue. Returns NULL if ascsi_dhis not attached.Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
Signed-off-by Mike Snitzer <[email protected]>--- drivers/scsi/device_handler/scsi_dh.c | 36 ++++++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 ++++ 2 files changed, 39 insertions(+), 2 deletions(-)v3: fixed missing
put_devicethat Babu pointed outIndex:
linux-2.6/drivers/scsi/device_handler/scsi_dh.c
===================================================================drivers/scsi/device_handler/scsi_dh.c +34
-2@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist)/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie @@ -527,6 +529,36 @@ void scsi_dh_detach(struct request_queue }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached handler, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; +const char *handler_name =NULL ; + +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); + +if (!sdev) +return NULL ; + +if (sdev->scsi_dh_data) + handler_name = sdev->scsi_dh_data->scsi_dh->name; + +put_device (&sdev->sdev_gendev); +return handler_name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };Index:
linux-2.6/include/scsi/scsi_dh.h
===================================================================include/scsi/scsi_dh.h +5
-0@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct requeextern int scsi_dh_handler_exist (const char *);extern int scsi_dh_attach (struct request_queue *,const char *);extern void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
Re: [PATCH v3 2/5] scsi_dh: add scsi_dh_attached_handler_name
In reply to Mike SnitzerMike, you may have to cross post to linux-scsi for James to pick it up.
Quoted 100 lines · Mike Snitzer
Introduce
scsi_dh_attached_handler_name()to retrieve the name of thescsi_dhthat is attached to thescsi_deviceassociated with the provided request queue. Returns NULL if ascsi_dhis not attached.Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
Signed-off-by Mike Snitzer <[email protected]>--- drivers/scsi/device_handler/scsi_dh.c | 36 ++++++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 ++++ 2 files changed, 39 insertions(+), 2 deletions(-)v3: fixed missing
put_devicethat Babu pointed outIndex:
linux-2.6/drivers/scsi/device_handler/scsi_dh.c
===================================================================drivers/scsi/device_handler/scsi_dh.c +34
-2@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist)/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie @@ -527,6 +529,36 @@ void scsi_dh_detach(struct request_queue }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached handler, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; +const char *handler_name =NULL ; + +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); + +if (!sdev) +return NULL ; + +if (sdev->scsi_dh_data) + handler_name = sdev->scsi_dh_data->scsi_dh->name; + +put_device (&sdev->sdev_gendev); +return handler_name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };Index:
linux-2.6/include/scsi/scsi_dh.h
===================================================================include/scsi/scsi_dh.h +5
-0@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct requeextern int scsi_dh_handler_exist (const char *);extern int scsi_dh_attach (struct request_queue *,const char *);extern void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
PATCH v3 2/5 scsi_dh: add scsi_dh_attached_handler_name
In reply to Moger, BabuIntroduce scsi_dh_attached_handler_name() to retrieve the name of the scsi_dh that is attached to the scsi_device associated with the provided request queue. Returns NULL if a scsi_dh is not attached.
Also, fix scsi_dh_{attach,detach} function header comments to document @q rather than @sdev.
--- drivers/scsi/device_handler/scsi_dh.c | 36 ++++++++++++++++++++++++++++++++-- include/scsi/scsi_dh.h | 5 ++++ 2 files changed, 39 insertions(+), 2 deletions(-)
v3: fixed missing put_device that Babu pointed out
drivers/scsi/device_handler/scsi_dh.c +34 -2
@@ -468,7 +468,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_handler_exist)/* * scsi_dh_attach - Attach device handler -* @sdev - sdev the handler should be attached to +* @q - Request queue that is associated with the scsi_device +* the handler should be attached to * @name - name of the handler to attach */ int scsi_dh_attach (struct request_queue *q,const char *name)
@@ -498,7 +499,8 @@ EXPORT_SYMBOL_GPL(scsi_dh_attach);/* * scsi_dh_detach - Detach device handler -* @sdev - sdev the handler should be detached from +* @q - Request queue that is associated with the scsi_device +* the handler should be detached from * * This function will detach the device handler only * if the sdev is not part of the internal list, ie
@@ -527,6 +529,36 @@ void scsi_dh_detach(struct request_queue }EXPORT_SYMBOL_GPL (scsi_dh_detach); +/* +* scsi_dh_attached_handler_name - Get attached device handler's name +* @q - Request queue that is associated with the scsi_device +* that may have a device handler attached +* +* Returns name of attached handler, NULL if no handler is attached. +*/ +const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +unsigned long flags; +struct scsi_device *sdev; +const char *handler_name =NULL ; + +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); + +if (!sdev) +return NULL ; + +if (sdev->scsi_dh_data) + handler_name = sdev->scsi_dh_data->scsi_dh->name; + +put_device (&sdev->sdev_gendev); +return handler_name; +} +EXPORT_SYMBOL_GPL (scsi_dh_attached_handler_name); +static struct notifier_block scsi_dh_nb = { .notifier_call = scsi_dh_notifier };
include/scsi/scsi_dh.h +5 -0
@@ -60,6 +60,7 @@ extern int scsi_dh_activate(struct requeextern int scsi_dh_handler_exist (const char *);extern int scsi_dh_attach (struct request_queue *,const char *);extern void scsi_dh_detach (struct request_queue *); +extern const char *scsi_dh_attached_handler_name (struct request_queue *q);extern int scsi_dh_set_params (struct request_queue *,const char *);#else static inline int scsi_dh_activate(struct request_queue *req,
@@ -80,6 +81,10 @@ static inline void scsi_dh_detach(struct {return ; } +static inline const char *scsi_dh_attached_handler_name (struct request_queue *q) +{ +return NULL ; +}static inline int scsi_dh_set_params (struct request_queue *req,const char *params) {return -SCSI_DH_NOSYS ;
PATCH v2 3/5 dm mpath: reduce size of multipath structure
In reply to Mike SnitzerMove multipath structure's 'lock' and 'queue_size' members to eliminate 2 4-byte holes. Also use a bit within a single unsigned int for each existing flag (saves 8-bytes). This allows future flags to be added without each consuming an unsigned int.
--- drivers/md/dm-mpath.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/md/dm-mpath.c +7 -6
@@ -61,11 +61,11 @@ struct multipath {struct list_head list;struct dm_target *ti; -spinlock_t lock; -const char *hw_handler_name;char *hw_handler_params; +spinlock_t lock; +unsigned nr_priority_groups;struct list_head priority_groups;
@@ -81,16 +81,17 @@ struct multipath {struct priority_group *next_pg;/* Switch to this PG if set */ unsigned repeat_count;/* I/Os left before calling PS again */ -unsigned queue_io;/* Must we queue all I/O? */ -unsigned queue_if_no_path;/* Queue I/O if last path fails? */ -unsigned saved_queue_if_no_path;/* Saved state during suspension */ + unsigned queue_io:1; /* Must we queue all I/O? */ + unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ + unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ +unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */ unsigned pg_init_delay_msecs;/* Number of msecs before pg_init retry */ +unsigned queue_size;struct work_struct process_queued_ios;struct list_head queued_ios; -unsigned queue_size;struct work_struct trigger_event;
Signature · 1 line
1.7.4.4
Re: [PATCH v2 3/5] dm mpath: reduce size of multipath structure
Quoted 40 lines · Mike Snitzer
Move multipath structure's 'lock' and '
queue_size' members to eliminate 2 4-byte holes. Also use a bit within a single unsigned int for each existing flag (saves 8-bytes). This allows future flags to be added without each consuming an unsigned int.Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-)drivers/md/dm-mpath.c +6
-5@@ -61,11 +61,11 @@ struct multipath {struct list_head list;struct dm_target *ti; -spinlock_t lock; -const char *hw_handler_name;char *hw_handler_params; +spinlock_t lock; +unsigned nr_priority_groups;struct list_head priority_groups;@@ -81,16 +81,17 @@ struct multipath {struct priority_group *next_pg;/* Switch to this PG if set */ unsigned repeat_count;/* I/Os left before calling PS again */ -unsigned queue_io;/* Must we queue all I/O? */ -unsigned queue_if_no_path;/* Queue I/O if last path fails? */ -unsigned saved_queue_if_no_path;/* Saved state during suspension */ + unsigned queue_io:1; /* Must we queue all I/O? */ + unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ + unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ +unsigned pg_init_retries;/* Number of times to retry pg_init */
drivers/md/dm-mpath.c struct multipath { · line 97
Quoted 10 lines
drivers/md/dm-mpath.c +1
-1unsigned pg_init_count;/* Number of times pg_init called */ unsigned pg_init_delay_msecs;/* Number of msecs before pg_init retry */ +unsigned queue_size;struct work_struct process_queued_ios;struct list_head queued_ios; -unsigned queue_size;struct work_struct trigger_event;
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke zSeries & Storage [email protected] +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
PATCH v2 4/5 dm mpath: add 'default_hw_handler' feature
In reply to Mike SnitzerFrom: Hannes Reinecke <[email protected]>
When specifying the feature 'default_hw_handler' multipath will be use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.
Leverages scsi_dh_attach's ability to increment the scsi_dh's reference count if the same scsi_dh name is provided when attaching -- currently attached scsi_dh name is determined with scsi_dh_attached_handler_name.
--- drivers/md/dm-mpath.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)
drivers/md/dm-mpath.c +23 -4
@@ -84,6 +84,7 @@ struct multipath { unsigned queue_io:1; /* Must we queue all I/O? */ unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ + unsigned use_default_hw_handler:1; /* Use attached device handler */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */
@@ -567,6 +568,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *psint r;struct pgpath *p;struct multipath *m = ti->private; +struct request_queue *q =NULL ;/* we need at least a path arg */ if (as->argc <1 ) {
@@ -585,9 +587,18 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev->bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name =scsi_dh_attached_handler_name (q); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name =kstrdup (attached_handler_name,GFP_KERNEL ); + } + } +if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);if (r == -EBUSY ) {/*
@@ -759,7 +770,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)const char *arg_name;static struct dm_arg _args[] = { - {0 ,5 ,"invalid number of feature args" }, + {0 ,6 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };
@@ -780,6 +791,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)continue ; } +if (!strcasecmp (arg_name,"default_hw_handler" )) { + m->use_default_hw_handler =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);
@@ -1363,13 +1379,16 @@ static int multipath_status(struct dm_target *ti, status_type_t type,else {DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + - (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 ); + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + + m->use_default_hw_handler);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)DMEMIT ("pg_init_retries %u " , m->pg_init_retries);if (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT )DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs); +if (m->use_default_hw_handler) +DMEMIT ("default_hw_handler " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )
Signature · 1 line
1.7.4.4
Re: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature
Mike,
Quoted 8 lines
-----Original Message-----
From: Mike Snitzer [mailto:[email protected]]
Sent: Tuesday, May 08, 2012 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; Moger, Babu; [email protected]; Mike Snitzer
Subject: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature
Quoted 6 lines
From: Hannes Reinecke <[email protected]>
When specifying the feature '
default_hw_handler' multipath will be use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.
I am trying to test these patches right now. What is the expectation from Multipath tools for this to work correctly. Do I have to pass following Parameters?
hardware_handler "1 alua"
features "1 default_hw_handler"
It appears to me that the first line will forcibly load the alua handler even if the default handler is different.
Quoted 111 lines
Leverages scsi_dh_attach's ability to increment the scsi_dh's reference count if the same
scsi_dhname is provided when attaching -- currently attachedscsi_dhname is determined withscsi_dh_attached_handler_name.Signed-off-by Hannes Reinecke <[email protected]>Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)drivers/md/dm-mpath.c +0
-0@@ -84,6 +84,7 @@ struct multipath { unsigned queue_io:1; /* Must we queue all I/O? */ unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state duringsuspension */
drivers/md/dm-mpath.c +1
-0+ unsigned use_default_hw_handler:1; /* Use attached devicehandler */
unsigned
pg_init_retries; /* Number of times to retrypg_init
*/
unsignedpg_init_count; /* Number of timespg_init
called */drivers/md/dm-mpath.c +1
-0@@ -567,6 +568,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *psint r;struct pgpath *p;struct multipath *m = ti->private; +struct request_queue *q =NULL ;/* we need at least a path arg */ drivers/md/dm-mpath.c +12
-3if (as->argc <1 ) {@@ -585,9 +587,18 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev- >bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name =scsi_dh_attached_handler_name (q); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name =kstrdup (attached_handler_name,GFP_KERNEL ); + } + } +if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);if (r == -EBUSY ) {/* @@ -759,7 +770,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)const char *arg_name;static struct dm_arg _args[] = { - {0 ,5 ,"invalid number of feature args" }, + {0 ,6 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0, 60000, "pg_init_delay_msecs must be between 0 and60000"},
drivers/md/dm-mpath.c +5
-0};@@ -780,6 +791,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m) continue; } +if (!strcasecmp (arg_name,"default_hw_handler" )) { + m->use_default_hw_handler =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) {r = dm_read_arg(_args + 1, as,
&m->pg_init_retries,&ti->error);drivers/md/dm-mpath.c +1
-1@@ -1363,13 +1379,16 @@ static int multipath_status(struct dm_target *ti, status_type_t type, else {DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + - (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT) * 2); + (m->pg_init_delay_msecs !=
DM_PG_INIT_DELAY_DEFAULT) * 2 +drivers/md/dm-mpath.c +1
-0+ m->use_default_hw_handler);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)DMEMIT ("pg_init_retries %u " , m->pg_init_retries); if (m->pg_init_delay_msecs !=
DM_PG_INIT_DELAY_DEFAULT)
DMEMIT("pg_init_delay_msecs %u ", m-Quoted 1 line
pg_init_delay_msecs);drivers/md/dm-mpath.c +2
-1+if (m->use_default_hw_handler) +DMEMIT ("default_hw_handler " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO ) --1.7.4.4
Re: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature
Quoted 17 lines · Babu
Mike,
Quoted 8 lines
-----Original Message-----
From: Mike Snitzer [mailto:[email protected]]
Sent: Tuesday, May 08, 2012 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; Moger, Babu; [email protected]; Mike Snitzer
Subject: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' featureQuoted 6 lines
From: Hannes Reinecke <[email protected]>
When specifying the feature '
default_hw_handler' multipath will be use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.
Quoted 6 lines
I am trying to test these patches right now. What is the expectation from Multipath tools for this to work correctly. Do I have to pass following Parameters?
hardware_handler"1 alua"
features "1default_hw_handler"
Yes.
Quoted 2 lines
It appears to me that the first line will forcibly load the alua handler even if the default handler is different.
Are you saying that based on testing or based on code review?
Quoted 23 lines
Quoted 23 lines
drivers/md/dm-mpath.c +10
-2@@ -585,9 +587,18 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev- >bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name =scsi_dh_attached_handler_name (q); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name =kstrdup (attached_handler_name,GFP_KERNEL ); + } + }
Quoted 4 lines
drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · line 604
Quoted 4 lines
drivers/md/dm-mpath.c +1
-0+if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);drivers/md/dm-mpath.c +0
-0if (r == -EBUSY ) {/*
The above hunk is what will cause the currently attached device handler to be used. But if a device handler is _not_ attached then we fallback to using the provided 'hardware_handler'.
So are you testing this patch with a device handler having already been attached?
Mike
Re: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature
Quoted 29 lines
-----Original Message-----
From: Mike Snitzer [mailto:[email protected]]
Sent: Wednesday, May 09, 2012 2:17 PM
To: Moger, Babu
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' featureQuoted 7 lines · Babu
Mike,
Quoted 5 lines
-----Original Message-----
From: Mike Snitzer [mailto:[email protected]]
Sent: Tuesday, May 08, 2012 4:56 PM
To: [email protected]
Cc: [email protected]; [email protected]; Moger, Babu;Quoted 10 lines
Quoted 9 lines
Mike Snitzer
Subject: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' featureFrom: Hannes Reinecke <[email protected]>
When specifying the feature '
default_hw_handler' multipath will be use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.
Quoted 8 lines
Quoted 6 lines
I am trying to test these patches right now. What is the expectation from Multipath tools for this to work correctly. Do I have to pass following Parameters?
hardware_handler"1 alua"
features "1default_hw_handler"Yes.
Ok. thanks
Quoted 5 lines
Quoted 3 lines
It appears to me that the first line will forcibly load the alua handler even if the default handler is different.
Are you saying that based on testing or based on code review?
I was only reviewing the code. Looking at the code again, It should work fine. I am going to test it anyway.
Quoted 27 lines
Quoted 6 lines
drivers/md/dm-mpath.c static struct pgpath *parse_path(struct
Quoted 6 lines
drivers/md/dm-mpath.c +0
-0@@ -585,9 +587,18 @@ static struct pgpath *parse_path(struct
dm_arg_setQuoted 4 lines
Quoted 4 lines
drivers/md/dm-mpath.c +0
-0*as, struct path_selector *ps goto bad; }Quoted 8 lines
drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
Quoted 8 lines
drivers/md/dm-mpath.c +5
-2-if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev- >bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { + const char *attached_handler_name =
scsi_dh_attached_handler_name(q);Quoted 3 lines
drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
Quoted 3 lines
drivers/md/dm-mpath.c +3
-0+if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name =
kstrdup(attached_handler_name, GFP_KERNEL);Quoted 3 lines
Quoted 3 lines
drivers/md/dm-mpath.c +2
-0+ } + }
Quoted 8 lines
Quoted 4 lines
drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · line 604
Quoted 4 lines
drivers/md/dm-mpath.c +1
-0+if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);drivers/md/dm-mpath.c +0
-0if (r == -EBUSY ) {/* The above hunk is what will cause the currently attached device handler to be used. But if a device handler is _not_ attached then we fallback to using the provided '
hardware_handler'.
Got it.
Quoted 3 lines
So are you testing this patch with a device handler having already been attached?
Yes. I will provide the feedback only tomorrow.
Re: [PATCH v2 4/5] dm mpath: add 'default_hw_handler' feature
In reply to Mike SnitzerQuoted 97 lines · Mike Snitzer
From: Hannes Reinecke <[email protected]>
When specifying the feature '
default_hw_handler' multipath will be use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.Leverages scsi_dh_attach's ability to increment the scsi_dh's reference count if the same
scsi_dhname is provided when attaching -- currently attachedscsi_dhname is determined withscsi_dh_attached_handler_name.Signed-off-by Hannes Reinecke <[email protected]>Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-)drivers/md/dm-mpath.c +23
-4@@ -84,6 +84,7 @@ struct multipath { unsigned queue_io:1; /* Must we queue all I/O? */ unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ + unsigned use_default_hw_handler:1; /* Use attached device handler */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */ @@ -567,6 +568,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *psint r;struct pgpath *p;struct multipath *m = ti->private; +struct request_queue *q =NULL ;/* we need at least a path arg */ if (as->argc <1 ) {@@ -585,9 +587,18 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev->bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name =scsi_dh_attached_handler_name (q); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name =kstrdup (attached_handler_name,GFP_KERNEL ); + } + } +if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);if (r == -EBUSY ) {/* @@ -759,7 +770,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)const char *arg_name;static struct dm_arg _args[] = { - {0 ,5 ,"invalid number of feature args" }, + {0 ,6 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };@@ -780,6 +791,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)continue ; } +if (!strcasecmp (arg_name,"default_hw_handler" )) { + m->use_default_hw_handler =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);@@ -1363,13 +1379,16 @@ static int multipath_status(struct dm_target *ti, status_type_t type,else {DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + - (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 ); + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + + m->use_default_hw_handler);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)DMEMIT ("pg_init_retries %u " , m->pg_init_retries);if (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT )DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs); +if (m->use_default_hw_handler) +DMEMIT ("default_hw_handler " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )
PATCH v3 4/5 dm mpath: add 'default_hw_handler' feature
In reply to Mike SnitzerWhen specifying the feature 'default_hw_handler' multipath will use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.
Leverages scsi_dh_attach's ability to increment the scsi_dh's reference count if the same scsi_dh name is provided when attaching -- currently attached scsi_dh name is determined with scsi_dh_attached_handler_name.
--- drivers/md/dm-mpath.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
v3: updated to not kstrdup since scsi_dh_attached_handler_name now does
drivers/md/dm-mpath.c +24 -4
@@ -84,6 +84,7 @@ struct multipath { unsigned queue_io:1; /* Must we queue all I/O? */ unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ + unsigned use_default_hw_handler:1; /* Use attached device handler */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */
@@ -567,6 +568,7 @@ static struct pgpath *parse_path(structint r;struct pgpath *p;struct multipath *m = ti->private; +struct request_queue *q =NULL ;/* we need at least a path arg */ if (as->argc <1 ) {
@@ -585,9 +587,19 @@ static struct pgpath *parse_path(struct goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev->bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name = +scsi_dh_attached_handler_name (q,GFP_KERNEL ); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name = attached_handler_name; + } + } +if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);if (r == -EBUSY ) {/*
@@ -759,7 +771,7 @@ static int parse_features(struct dm_arg_const char *arg_name;static struct dm_arg _args[] = { - {0 ,5 ,"invalid number of feature args" }, + {0 ,6 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };
@@ -780,6 +792,11 @@ static int parse_features(struct dm_arg_continue ; } +if (!strcasecmp (arg_name,"default_hw_handler" )) { + m->use_default_hw_handler =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);
@@ -1363,13 +1380,16 @@ static int multipath_status(struct dm_taelse {DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + - (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 ); + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + + m->use_default_hw_handler);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)DMEMIT ("pg_init_retries %u " , m->pg_init_retries);if (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT )DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs); +if (m->use_default_hw_handler) +DMEMIT ("default_hw_handler " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )
Re: [PATCH v3 4/5] dm mpath: add 'default_hw_handler' feature
Quoted 101 lines · Mike Snitzer
When specifying the feature '
default_hw_handler' multipath will use the currently attached hardware handler instead of trying to attach the one specified during table load. If no hardware handler is attached the specified hardware handler will be used.Leverages scsi_dh_attach's ability to increment the scsi_dh's reference count if the same
scsi_dhname is provided when attaching -- currently attachedscsi_dhname is determined withscsi_dh_attached_handler_name.Signed-off-by Mike Snitzer <[email protected]>Tested-by Babu Moger <[email protected]>Cc Hannes Reinecke <[email protected]>Cc Chandra Seetharaman <[email protected]>--- drivers/md/dm-mpath.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)v3: updated to not kstrdup since
scsi_dh_attached_handler_namenow doesIndex:
linux-2.6/drivers/md/dm-mpath.c
===================================================================drivers/md/dm-mpath.c +24
-4@@ -84,6 +84,7 @@ struct multipath { unsigned queue_io:1; /* Must we queue all I/O? */ unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ + unsigned use_default_hw_handler:1; /* Use attached device handler */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */ @@ -567,6 +568,7 @@ static struct pgpath *parse_path(structint r;struct pgpath *p;struct multipath *m = ti->private; +struct request_queue *q =NULL ;/* we need at least a path arg */ if (as->argc <1 ) {@@ -585,9 +587,19 @@ static struct pgpath *parse_path(struct goto bad; } -if (m->hw_handler_name) { -struct request_queue *q =bdev_get_queue (p->path.dev->bdev); +if (m->use_default_hw_handler || m->hw_handler_name) + q =bdev_get_queue (p->path.dev->bdev); + +if (m->use_default_hw_handler) { +const char *attached_handler_name = +scsi_dh_attached_handler_name (q,GFP_KERNEL ); +if (attached_handler_name) { +kfree (m->hw_handler_name); + m->hw_handler_name = attached_handler_name; + } + } +if (m->hw_handler_name) { r =scsi_dh_attach (q, m->hw_handler_name);if (r == -EBUSY ) {/* @@ -759,7 +771,7 @@ static int parse_features(struct dm_arg_const char *arg_name;static struct dm_arg _args[] = { - {0 ,5 ,"invalid number of feature args" }, + {0 ,6 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };@@ -780,6 +792,11 @@ static int parse_features(struct dm_arg_continue ; } +if (!strcasecmp (arg_name,"default_hw_handler" )) { + m->use_default_hw_handler =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);@@ -1363,13 +1380,16 @@ static int multipath_status(struct dm_taelse {DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + - (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 ); + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + + m->use_default_hw_handler);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)DMEMIT ("pg_init_retries %u " , m->pg_init_retries);if (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT )DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs); +if (m->use_default_hw_handler) +DMEMIT ("default_hw_handler " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )
PATCH v2 5/5 dm mpath: add ability to disable partition creation
In reply to Mike SnitzerFrom: Hannes Reinecke <[email protected]>
When multipath devices are being used as disks for VM Guests any partition scanning / setup should be done within the VM Guest, not from host. So we need to a mechanism to switch off partition scanning and creation via kpartx.
The new 'no_partitions' feature serves as a notifier to kpartx to _not_ create partitions on these multipath devices.
--- drivers/md/dm-mpath.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +11 -2
@@ -85,6 +85,7 @@ struct multipath { unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ unsigned use_default_hw_handler:1; /* Use attached device handler */ + unsigned no_partitions:1; /* Avoid partition scanning */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */
@@ -770,7 +771,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)const char *arg_name;static struct dm_arg _args[] = { - {0 ,6 ,"invalid number of feature args" }, + {0 ,7 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };
@@ -796,6 +797,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)continue ; } +if (!strcasecmp (arg_name,"no_partitions" )) { + m->no_partitions =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);
@@ -1380,7 +1386,8 @@ static int multipath_status(struct dm_target *ti, status_type_t type,DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + - m->use_default_hw_handler); + m->use_default_hw_handler + + m->no_partitions);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)
@@ -1389,6 +1396,8 @@ static int multipath_status(struct dm_target *ti, status_type_t type,DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs);if (m->use_default_hw_handler)DMEMIT ("default_hw_handler " ); +if (m->no_partitions) +DMEMIT ("no_partitions " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )
Signature · 1 line
1.7.4.4
Re: [PATCH v2 5/5] dm mpath: add ability to disable partition creation
Quoted 68 lines · Mike Snitzer
From: Hannes Reinecke <[email protected]>
When multipath devices are being used as disks for VM Guests any partition scanning / setup should be done within the VM Guest, not from host. So we need to a mechanism to switch off partition scanning and creation via kpartx.
The new '
no_partitions' feature serves as a notifier to kpartx to _not_ create partitions on these multipath devices.Signed-off-by Hannes Reinecke <[email protected]>Signed-off-by Mike Snitzer <[email protected]>--- drivers/md/dm-mpath.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-)drivers/md/dm-mpath.c +11
-2@@ -85,6 +85,7 @@ struct multipath { unsigned queue_if_no_path:1; /* Queue I/O if last path fails? */ unsigned saved_queue_if_no_path:1; /* Saved state during suspension */ unsigned use_default_hw_handler:1; /* Use attached device handler */ + unsigned no_partitions:1; /* Avoid partition scanning */unsigned pg_init_retries;/* Number of times to retry pg_init */ unsigned pg_init_count;/* Number of times pg_init called */ @@ -770,7 +771,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)const char *arg_name;static struct dm_arg _args[] = { - {0 ,6 ,"invalid number of feature args" }, + {0 ,7 ,"invalid number of feature args" }, {1 ,50 ,"pg_init_retries must be between 1 and 50" }, {0 ,60000 ,"pg_init_delay_msecs must be between 0 and 60000" }, };@@ -796,6 +797,11 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)continue ; } +if (!strcasecmp (arg_name,"no_partitions" )) { + m->no_partitions =1 ; +continue ; + } +if (!strcasecmp (arg_name,"pg_init_retries" ) && (argc >=1 )) { r =dm_read_arg (_args +1 , as, &m->pg_init_retries, &ti->error);@@ -1380,7 +1386,8 @@ static int multipath_status(struct dm_target *ti, status_type_t type,DMEMIT ("%u " , m->queue_if_no_path + (m->pg_init_retries >0 ) *2 + (m->pg_init_delay_msecs !=DM_PG_INIT_DELAY_DEFAULT ) *2 + - m->use_default_hw_handler); + m->use_default_hw_handler + + m->no_partitions);if (m->queue_if_no_path)DMEMIT ("queue_if_no_path " );if (m->pg_init_retries)@@ -1389,6 +1396,8 @@ static int multipath_status(struct dm_target *ti, status_type_t type,DMEMIT ("pg_init_delay_msecs %u " , m->pg_init_delay_msecs);if (m->use_default_hw_handler)DMEMIT ("default_hw_handler " ); +if (m->no_partitions) +DMEMIT ("no_partitions " ); }if (!m->hw_handler_name || type ==STATUSTYPE_INFO )