Skip to contentSkip to conversation

'default' hardware handler for multipath

PATCH In review Hannes Reinecke 4 participants 11 messages Apr 2, 2012 – Apr 18, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover 'default' hardware handler for multipath

This patchset introduces a 'default' hardware handler for dm-multipath.
Modern storage arrays typically support two failover methods, the original proprietary and the modern ALUA-based one. The device_handler implementation will currently select the ALUA handler, and falling back to the proprietary one if ALUA isn't supported.
However, in the built-in hardware table for multipath one can specify only one hardware handler, causing the original hardware handler to be overwritten.
By specifying a 'default' hardware handler multipath will not try to attach a specific hardware handler, but rather using the currently attached on.

Hannes Reinecke (2):
scsi_dh: Allow NULL hardware handler name in scsi_dh_attach()
dm-mpath: Allow 'default' hardware handler

 drivers/md/dm-mpath.c                 |    8 ++++++--
 drivers/scsi/device_handler/scsi_dh.c |    8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.7
#1 lore raw

PATCH 1/2 scsi_dh: Allow NULL hardware handler name in scsi_dh_attach()

This patch allows to pass in a NULL hardware handler to scsi_dh_attach(), causing the reference count of the existing hardware handler to be increased.
An error will be returned if no hardware handler is attached.

---
 drivers/scsi/device_handler/scsi_dh.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/device_handler/scsi_dh.c +6 -2
index 48e46f5..77fa67e 100644
@@ -475,10 +475,14 @@ int scsi_dh_attach(struct request_queue *q, const char *name)
 {
 	unsigned long flags;
 	struct scsi_device *sdev;
-	struct scsi_device_handler *scsi_dh;
+	struct scsi_device_handler *scsi_dh = NULL;
 	int err = 0;
 
-	scsi_dh = get_device_handler(name);
+	if (name) {
+		scsi_dh = get_device_handler(name);
+	} else if (sdev->scsi_dh_data) {
+		scsi_dh = sdev->scsi_dh_data->scsi_dh;
+	}
 	if (!scsi_dh)
 		return -EINVAL;
 
Signature · 1 line
1.7.7
#4 lore raw

PATCH 2/2 dm-mpath: Allow 'default' hardware handler

In reply to Hannes Reinecke

This patch introduces a 'default' hardware handler for dm-mpath. When specifying '1 default' dm-multipath will be using the currently attached hardware handler.

---
 drivers/md/dm-mpath.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +6 -2
index 922a338..bbf950f 100644
@@ -586,15 +586,19 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 
 	if (m->hw_handler_name) {
 		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+		char *hw_handler = NULL;
 
-		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (strncmp(m->hw_handler_name, "default", 6))
+			hw_handler = m->hw_handler_name;
+		
+		r = scsi_dh_attach(q, hw_handler);
 		if (r == -EBUSY) {
 			/*
 			 * Already attached to different hw_handler,
 			 * try to reattach with correct one.
 			 */
 			scsi_dh_detach(q);
-			r = scsi_dh_attach(q, m->hw_handler_name);
+			r = scsi_dh_attach(q, hw_handler);
 		}
 
 		if (r < 0) {
Signature · 1 line
1.7.7
#5 lore raw

Re: [PATCH 2/2] dm-mpath: Allow 'default' hardware handler

Quoted 14 lines · Hannes Reinecke

This patch introduces a 'default' hardware handler for dm-mpath. When specifying '1 default' dm-multipath will be using the currently attached hardware handler.

---
 drivers/md/dm-mpath.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +0 -0
index 922a338..bbf950f 100644

drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · line 592

Quoted 8 lines
drivers/md/dm-mpath.c +3 -1
@@ -586,15 +586,19 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 
 	if (m->hw_handler_name) {
 		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+		char *hw_handler = NULL;
 
-		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (strncmp(m->hw_handler_name, "default", 6))
+			hw_handler = m->hw_handler_name;

Should be: if (strncmp(m->hw_handler_name, "default", 7))

Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] scsi_dh: Allow NULL hardware handler name in scsi_dh_attach()

In reply to Hannes Reinecke
Quoted 18 lines · Hannes Reinecke

This patch allows to pass in a NULL hardware handler to scsi_dh_attach(), causing the reference count of the existing hardware handler to be increased.
An error will be returned if no hardware handler is attached.

---
 drivers/scsi/device_handler/scsi_dh.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/device_handler/scsi_dh.c +0 -0
index 48e46f5..77fa67e 100644
@@ -475,10 +475,14 @@ int scsi_dh_attach(struct request_queue *q, const char *name)
 {
 	unsigned long flags;
 	struct scsi_device *sdev;

drivers/scsi/device_handler/scsi_dh.c int scsi_dh_attach(struct request_queue *q, const char *name) · line 485

Quoted 10 lines
drivers/scsi/device_handler/scsi_dh.c +6 -2
-	struct scsi_device_handler *scsi_dh;
+	struct scsi_device_handler *scsi_dh = NULL;
 	int err = 0;
 
-	scsi_dh = get_device_handler(name);
+	if (name) {
+		scsi_dh = get_device_handler(name);
+	} else if (sdev->scsi_dh_data) {
+		scsi_dh = sdev->scsi_dh_data->scsi_dh;
+	}

Extra brackets aren't needed. But otherwise:

#6 lore raw

Re: [PATCH 2/2] dm-mpath: Allow 'default' hardware handler

In reply to Mike Snitzer
Quoted 22 lines · Mike Snitzer
Quoted 19 lines · Hannes Reinecke

This patch introduces a 'default' hardware handler for dm-mpath. When specifying '1 default' dm-multipath will be using the currently attached hardware handler.

---
 drivers/md/dm-mpath.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +1 -0
index 922a338..bbf950f 100644
@@ -586,15 +586,19 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 
 	if (m->hw_handler_name) {
 		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+		char *hw_handler = NULL;
 
Quoted 5 lines

drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · line 592

Quoted 3 lines
drivers/md/dm-mpath.c +2 -1
-		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (strncmp(m->hw_handler_name, "default", 6))
+			hw_handler = m->hw_handler_name;

Should be: if (strncmp(m->hw_handler_name, "default", 7))

A-hem.

Counting by hand is at times tricky.
I'll be sending an updated patchset.

Cheers,

Hannes

Signature · 8 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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#7 lore raw

Re: [dm-devel] [PATCH 2/2] dm-mpath: Allow 'default' hardware handler

Hi Hannes,

Quoted 28 lines · Hannes Reinecke
Quoted 22 lines · Mike Snitzer
Quoted 19 lines · Hannes Reinecke

This patch introduces a 'default' hardware handler for dm-mpath. When specifying '1 default' dm-multipath will be using the currently attached hardware handler.

---
 drivers/md/dm-mpath.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/md/dm-mpath.c +1 -0
index 922a338..bbf950f 100644
@@ -586,15 +586,19 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 
 	if (m->hw_handler_name) {
 		struct request_queue *q = bdev_get_queue(p->path.dev->bdev);
+		char *hw_handler = NULL;
 
Quoted 5 lines

drivers/md/dm-mpath.c static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps · line 592

Quoted 3 lines
drivers/md/dm-mpath.c +2 -1
-		r = scsi_dh_attach(q, m->hw_handler_name);
+		if (strncmp(m->hw_handler_name, "default", 6))
+			hw_handler = m->hw_handler_name;

Should be: if (strncmp(m->hw_handler_name, "default", 7))

Quoted 4 lines

A-hem.

Counting by hand is at times tricky.
I'll be sending an updated patchset.

It seems you will hit the following error in parse_hw_handler(). Or is it avoided somehow?

        request_module("scsi_dh_%s", m->hw_handler_name);
        if (scsi_dh_handler_exist(m->hw_handler_name) == 0) {
                ti->error = "unknown hardware handler type";
                ret = -EINVAL;
                goto fail;
        }

Thanks,

Signature · 1 line
Jun'ichi Nomura, NEC Corporation
#3 lore raw

Re: [dm-devel] [PATCH 1/2] scsi_dh: Allow NULL hardware handler name in scsi_dh_attach()

In reply to Hannes Reinecke

Hi Hannes,

Quoted 20 lines · Hannes Reinecke

This patch allows to pass in a NULL hardware handler to scsi_dh_attach(), causing the reference count of the existing hardware handler to be increased.
An error will be returned if no hardware handler is attached.

---
 drivers/scsi/device_handler/scsi_dh.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/scsi/device_handler/scsi_dh.c +1 -1
index 48e46f5..77fa67e 100644
@@ -475,10 +475,14 @@ int scsi_dh_attach(struct request_queue *q, const char *name)
 {
 	unsigned long flags;
 	struct scsi_device *sdev;
-	struct scsi_device_handler *scsi_dh;
+	struct scsi_device_handler *scsi_dh = NULL;

drivers/scsi/device_handler/scsi_dh.c int scsi_dh_attach(struct request_queue *q, const char *name) · line 487

Quoted 10 lines
drivers/scsi/device_handler/scsi_dh.c +5 -1
 	int err = 0;
 
-	scsi_dh = get_device_handler(name);
+	if (name) {
+		scsi_dh = get_device_handler(name);
+	} else if (sdev->scsi_dh_data) {
+		scsi_dh = sdev->scsi_dh_data->scsi_dh;
+	}
 	if (!scsi_dh)
 		return -EINVAL;

It won't work. sdev is not initialized...

Thanks,

Signature · 1 line
Jun'ichi Nomura, NEC Corporation
#8 lore raw
In reply to Hannes Reinecke

Thanks Hannes. We appreciate your work on this.

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:dm-devel- [email protected]] On Behalf Of Hannes Reinecke
Sent: Monday, April 02, 2012 11:44 AM
To: [email protected]
Cc: [email protected]; Mike Snitzer
Subject: [dm-devel] [PATCH 0/2] 'default' hardware handler for multipath

Quoted 10 lines

This patchset introduces a 'default' hardware handler for dm-multipath. Modern storage arrays typically support two failover methods, the original proprietary and the modern ALUA-based one.
The device_handler implementation will currently select the ALUA handler, and falling back to the proprietary one if ALUA isn't supported. However, in the built-in hardware table for multipath one can specify only one hardware handler, causing the original hardware handler to be overwritten.
By specifying a 'default' hardware handler multipath will not try to attach a specific hardware handler, but rather using the currently attached on.

I think we still have some issues here. Right now we load the driver either by adding it in initrd or by using request_module call from device mapper.
If the user passes, hardware_handler "1 default" from multipath then request_module will fail.
How are we going to load the driver if these handlers are not loaded.

Quoted 16 lines

Hannes Reinecke (2):
scsi_dh: Allow NULL hardware handler name in scsi_dh_attach()
dm-mpath: Allow 'default' hardware handler

 drivers/md/dm-mpath.c                 |    8 ++++++--
 drivers/scsi/device_handler/scsi_dh.c |    8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

--
1.7.7

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#9 lore raw
Quoted 21 lines · Babu

Thanks Hannes. We appreciate your work on this.

Quoted 8 lines

-----Original Message-----
From: [email protected] [mailto:dm-devel- [email protected]] On Behalf Of Hannes Reinecke
Sent: Monday, April 02, 2012 11:44 AM
To: [email protected]
Cc: [email protected]; Mike Snitzer
Subject: [dm-devel] [PATCH 0/2] 'default' hardware handler for multipath

Quoted 10 lines

This patchset introduces a 'default' hardware handler for dm-multipath. Modern storage arrays typically support two failover methods, the original proprietary and the modern ALUA-based one.
The device_handler implementation will currently select the ALUA handler, and falling back to the proprietary one if ALUA isn't supported. However, in the built-in hardware table for multipath one can specify only one hardware handler, causing the original hardware handler to be overwritten.
By specifying a 'default' hardware handler multipath will not try to attach a specific hardware handler, but rather using the currently attached on.

Quoted 5 lines

I think we still have some issues here. Right now we load the driver either by adding it in initrd or by using request_module call from device mapper.
If the user passes, hardware_handler "1 default" from multipath then request_module will fail.
How are we going to load the driver if these handlers are not loaded.

The idea of the 'default' hardware handler is to avoid multipath overriding the kernel matchine algorithm. To make this work we obviously have to load the modules prior to start multipathing.

Given that we (ie RH and us) are already loading the device-handler modules from the initrd independent from multipathing we should be fine.

But thinking a bit more about it, it might be better to handle this via features.
Implementing a feature like 'default_hw_handler' would not override the default hardware handler from the hardware table.
So the requested hardware handler would still be loaded, but the actual initialisation would be controlled via the feature.

Yep, that sound better.
I'll be preparing a patch.

Cheers,

Hannes

Signature · 8 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)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

Hannes,

Quoted 44 lines

-----Original Message-----
From: Hannes Reinecke [mailto:[email protected]]
Sent: Wednesday, April 18, 2012 9:08 AM
To: Moger, Babu
Cc: device-mapper development; [email protected]; Mike Snitzer
Subject: Re: [dm-devel] [PATCH 0/2] 'default' hardware handler for multipath

Quoted 14 lines · Babu

Thanks Hannes. We appreciate your work on this.

Quoted 12 lines

-----Original Message-----
From: [email protected] [mailto:dm-devel- [email protected]] On Behalf Of Hannes Reinecke
Sent: Monday, April 02, 2012 11:44 AM
To: [email protected]
Cc: [email protected]; Mike Snitzer
Subject: [dm-devel] [PATCH 0/2] 'default' hardware handler for multipath

This patchset introduces a 'default' hardware handler for dm-multipath. Modern storage arrays typically support two failover methods, the original proprietary and the modern ALUA-based one.
The device_handler implementation will currently select the ALUA

handler,

Quoted 9 lines
Quoted 6 lines

and falling back to the proprietary one if ALUA isn't supported. However, in the built-in hardware table for multipath one can specify only one hardware handler, causing the original hardware handler to be overwritten.
By specifying a 'default' hardware handler multipath will not try to attach a specific hardware handler, but rather using the currently attached on.

I think we still have some issues here. Right now we load the driver either by adding it in initrd or by using request_module call from device

mapper.

Quoted 1 line

If the user passes, hardware_handler "1 default" from multipath then

request_module will fail.

Quoted 2 lines

How are we going to load the driver if these handlers are not loaded.

The idea of the 'default' hardware handler is to avoid multipath overriding the kernel matchine algorithm. To make this work we obviously have to load the modules prior to start multipathing.

Given that we (ie RH and us) are already loading the device-handler modules from the initrd independent from multipathing we should be fine.

Quoted 6 lines

But thinking a bit more about it, it might be better to handle this via features.
Implementing a feature like 'default_hw_handler' would not override the default hardware handler from the hardware table.
So the requested hardware handler would still be loaded, but the actual initialisation would be controlled via the feature.

hardware_handler is also used to pass on the arguments to handler. Like.
hardware_handler "2 emc 1"
We have to make sure that this feature does not break here. Considering all this don't you think it may be better if we make this decision in multipath tools itself. Common factor here is alua. It is always between alua or some other handler. Does it make sense to check TPGS in tools?

Quoted 11 lines

Yep, that sound better.
I'll be preparing a patch.

Cheers,

Hannes
--
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)

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html