Skip to contentSkip to conversation

dm-mpath: Enable hw_handler_params to take effect if hw_handler is the same between new and old

PATCH In review [email protected] 2 participants 7 messages Nov 24, 2016 – Nov 29, 2016 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dm-mpath: Enable hw_handler_params to take effect if hw_handler is the same between new and old

From: "tang.junhui" <[email protected]>

If the hardware handle which a device has already attached is the same with m->hw_handler_name, m->hw_handler_params should not be ignored, but be enabled to take effect.

---
 drivers/md/dm-mpath.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/md/dm-mpath.c +9 -5
index 0caab4b..b1aba63 100644
@@ -849,19 +849,23 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 retain:
 		attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
 		if (attached_handler_name) {
+			/* clear any hw_handler_params associated with
+			 * m->hw_handler_params if a different handler has
+			 * already been attached.
+			 */
+			if(!m->hw_handler_name || strcmp(attached_handler_name, m->hw_handler_name))
+			{
+				kfree(m->hw_handler_params);
+				m->hw_handler_params = NULL;
+			}
 			/*
 			 * Reset hw_handler_name to match the attached handler
-			 * and clear any hw_handler_params associated with the
-			 * ignored handler.
 			 *
 			 * NB. This modifies the table line to show the actual
 			 * handler instead of the original table passed in.
 			 */
 			kfree(m->hw_handler_name);
 			m->hw_handler_name = attached_handler_name;
-
-			kfree(m->hw_handler_params);
-			m->hw_handler_params = NULL;
 		}
 	}
 
Signature · 1 line
2.8.1.windows.1
#1 lore raw

PATCH 2/2 dm-mpath: Remove useless retain_attached_hw_handler parameter

From: "tang.junhui" <[email protected]>

Hardware handle would be retained no matter parameter retain_attached_hw_handler is set or not in the logic of current code. So remove this useless parameter.

---
 drivers/md/dm-mpath.c | 34 +++++-----------------------------
 1 file changed, 5 insertions(+), 29 deletions(-)
drivers/md/dm-mpath.c +5 -29
index b1aba63..fe6a529 100644
@@ -129,10 +129,9 @@ static void process_queued_bios(struct work_struct *work);
 #define MPATHF_QUEUE_IO 0			/* Must we queue all I/O? */
 #define MPATHF_QUEUE_IF_NO_PATH 1		/* Queue I/O if last path fails? */
 #define MPATHF_SAVED_QUEUE_IF_NO_PATH 2		/* Saved state during suspension */
-#define MPATHF_RETAIN_ATTACHED_HW_HANDLER 3	/* If there's already a hw_handler present, don't change it. */
-#define MPATHF_PG_INIT_DISABLED 4		/* pg_init is not currently allowed */
-#define MPATHF_PG_INIT_REQUIRED 5		/* pg_init needs calling? */
-#define MPATHF_PG_INIT_DELAY_RETRY 6		/* Delay pg_init retry? */
+#define MPATHF_PG_INIT_DISABLED 3		/* pg_init is not currently allowed */
+#define MPATHF_PG_INIT_REQUIRED 4		/* pg_init needs calling? */
+#define MPATHF_PG_INIT_DELAY_RETRY 5		/* Delay pg_init retry? */
 
 /*-----------------------------------------------
  * Allocation routines
@@ -240,11 +239,6 @@ static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m)
 	}
 	else if (m->queue_mode == DM_TYPE_BIO_BASED) {
 		INIT_WORK(&m->process_queued_bios, process_queued_bios);
-		/*
-		 * bio-based doesn't support any direct scsi_dh management;
-		 * it just discovers if a scsi_dh is attached.
-		 */
-		set_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags);
 	}
 
 	dm_table_set_type(ti->table, m->queue_mode);
@@ -842,11 +836,8 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 		goto bad;
 	}
 
-	if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags) || m->hw_handler_name)
+	if (m->hw_handler_name) {
 		q = bdev_get_queue(p->path.dev->bdev);
-
-	if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) {
-retain:
 		attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL);
 		if (attached_handler_name) {
 			/* clear any hw_handler_params associated with
@@ -871,13 +862,6 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
 
 	if (m->hw_handler_name) {
 		r = scsi_dh_attach(q, m->hw_handler_name);
-		if (r == -EBUSY) {
-			char b[BDEVNAME_SIZE];
-
-			printk(KERN_INFO "dm-mpath: retaining handler on device %s\n",
-				bdevname(p->path.dev->bdev, b));
-			goto retain;
-		}
 		if (r < 0) {
 			ti->error = "error attaching hardware handler";
 			dm_put_device(ti, p->path.dev);
@@ -1040,7 +1024,7 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
 	const char *arg_name;
 
 	static struct dm_arg _args[] = {
-		{0, 8, "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"},
 	};
@@ -1061,11 +1045,6 @@ static int parse_features(struct dm_arg_set *as, struct multipath *m)
 			continue;
 		}
 
-		if (!strcasecmp(arg_name, "retain_attached_hw_handler")) {
-			set_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags);
-			continue;
-		}
-
 		if (!strcasecmp(arg_name, "pg_init_retries") &&
 		    (argc >= 1)) {
 			r = dm_read_arg(_args + 1, as, &m->pg_init_retries, &ti->error);
@@ -1745,7 +1724,6 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
 		DMEMIT("%u ", test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) +
 			      (m->pg_init_retries > 0) * 2 +
 			      (m->pg_init_delay_msecs != DM_PG_INIT_DELAY_DEFAULT) * 2 +
-			      test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags) +
 			      (m->queue_mode != DM_TYPE_REQUEST_BASED) * 2);
 
 		if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))
@@ -1754,8 +1732,6 @@ static void multipath_status(struct dm_target *ti, status_type_t type,
 			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 (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags))
-			DMEMIT("retain_attached_hw_handler ");
 		if (m->queue_mode != DM_TYPE_REQUEST_BASED) {
 			switch(m->queue_mode) {
 			case DM_TYPE_BIO_BASED:
Signature · 1 line
2.8.1.windows.1
#2 lore raw

Re: [PATCH 2/2] dm-mpath: Remove useless retain_attached_hw_handler parameter

Quoted 5 lines · On Thu, Nov 24 2016 at 2:11am -0500, [email protected]…

From: "tang.junhui" <[email protected]>

Hardware handle would be retained no matter parameter retain_attached_hw_handler is set or not in the logic of current code. So remove this useless parameter.

Right, that wasn't always the case. Previously (before commit ) dm-mpath would first detach the attached handler.

I'm not completely opposed to removing the code that checks MPATHF_RETAIN_ATTACHED_HW_HANDLER in parse_path() but your proposed patch is broken in 2 ways:
1) in parse_path() you need to always initialize q
2) setting m->hw_handler_name to attached_handler_name needs to still happen regardless of whether m->hw_handler_name was previously set
3) the "retain_attached_hw_handler" feature should still be allowed on the command line, no sense to break multipath-tools

But honestly, I'm not seeing any reason to not just leave the existing code.

#3 lore raw

Re: [PATCH 2/2] dm-mpath: Remove useless retain_attached_hw_handler parameter

Quoted 21 lines · Mike Snitzer
Quoted 5 lines · On Thu, Nov 24 2016 at 2:11am -0500, [email protected]…

From: "tang.junhui" <[email protected]>

Hardware handle would be retained no matter parameter retain_attached_hw_handler is set or not in the logic of current code. So remove this useless parameter.

Right, that wasn't always the case. Previously (before commit ) dm-mpath would first detach the attached handler.

I'm not completely opposed to removing the code that checks MPATHF_RETAIN_ATTACHED_HW_HANDLER in parse_path() but your proposed patch is broken in 2 ways:
1) in parse_path() you need to always initialize q
2) setting m->hw_handler_name to attached_handler_name needs to still happen regardless of whether m->hw_handler_name was previously set
3) the "retain_attached_hw_handler" feature should still be allowed on the command line, no sense to break multipath-tools

Quoted 2 lines

But honestly, I'm not seeing any reason to not just leave the existing code.

In addition, your patch actually breaks the ability to cope with -EBUSY from the call to scsi_dh_attach(). Meaning we wouldn't properly fall back to retaining the attached hw handler.

So NACK on this patch.

#4 lore raw

Re: [PATCH 2/2] dm-mpath: Remove useless retain_attached_hw_handler parameter

In reply to Mike Snitzer
Quoted 11 lines · Mike Snitzer
Quoted 5 lines · On Thu, Nov 24 2016 at 2:11am -0500, [email protected]…

From: "tang.junhui" <[email protected]>

Hardware handle would be retained no matter parameter retain_attached_hw_handler is set or not in the logic of current code. So remove this useless parameter.

Right, that wasn't always the case. Previously (before commit ) dm-mpath would first detach the attached handler.

meant to reference commit 1bab0de02 ("dm-mpath, scsi_dh: don't let dm detach device handlers")

#5 lore raw

Re: [PATCH 2/2] dm-mpath: Remove useless retain_attached_hw_handler parameter

In reply to Mike Snitzer

Hello Mike:

Thanks for your respond.

Quoted 1 line

1) in parse_path() you need to always initialize q

the condition of q initialization is
if (m->retain_attached_hw_handler)”
comparing with previous condition
if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags) || m->hw_handler_name)
it does not increase the possibility of q initialization.

Quoted 2 lines

2) setting m->hw_handler_name to attached_handler_name needs to still happen regardless of whether m->hw_handler_name was previously set

The patch does not change the logic above, does it?

Quoted 2 lines

3) the "retain_attached_hw_handler" feature should still be allowed on the command line, no sense to break multipath-tools

Yes, actually I am still preparing two other patches now, one patch modifies parse_features() to ignore unsupported parameter and do not return failure. Another patch modifies multipath to remove this parameter also.

Quoted 3 lines

In addition, your patch actually breaks the ability to cope with –EBUSY from the call to scsi_dh_attach(). Meaning we wouldn't properly fall back to retaining the attached hw handler.

scsi_dh_attach() return –EBUSY only if that device has attached a different handle, after previous processing, the handle would be same, so it is impossible to return –EBUSY in scsi_dh_attach(), we do not need to process it.

Regards,
Tang

发件人: Mike Snitzer <[email protected]>
收件人: [email protected],

抄送:   [email protected], [email protected], [email protected]
日期:   2016/11/29 05:52
主题:   Re: [dm-devel] [PATCH 2/2] dm-mpath: Remove useless 

retain_attached_hw_handler parameter
发件人: [email protected]

Quoted 5 lines · On Thu, Nov 24 2016 at 2:11am -0500, [email protected]…

From: "tang.junhui" <[email protected]>

Hardware handle would be retained no matter parameter retain_attached_hw_handler is set or not in the logic of current code. So remove this useless parameter.

Right, that wasn't always the case. Previously (before commit ) dm-mpath would first detach the attached handler.

I'm not completely opposed to removing the code that checks MPATHF_RETAIN_ATTACHED_HW_HANDLER in parse_path() but your proposed patch is broken in 2 ways:
1) in parse_path() you need to always initialize q
2) setting m->hw_handler_name to attached_handler_name needs to still happen regardless of whether m->hw_handler_name was previously set
3) the "retain_attached_hw_handler" feature should still be allowed on the command line, no sense to break multipath-tools

But honestly, I'm not seeing any reason to not just leave the existing code.

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

#6 lore raw
In reply to [email protected]
Quoted 7 lines · On Thu, Nov 24 2016 at 2:11am -0500, [email protected]…

From: "tang.junhui" <[email protected]>

If the hardware handle which a device has already attached is the same with m->hw_handler_name, m->hw_handler_params should not be ignored, but be enabled to take effect.

I tweaked this a little bit and staged it for 4.10, see:
https://git.kernel.org/cgit/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.10&id=1422b33eda2ffbc70eb11163bf7ac1e59ebba222