Skip to contentSkip to conversation

Don't forget to reload table when both reload and rename is required

PATCH Applied Vaughan Cao 2 participants 2 messages Jun 25, 2014 – Jul 1, 2014 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't forget to reload table when both reload and rename is required

We encounter the following case:

@ After adding a multipaths section into /etc/multipath.conf to specify 'alias' @ and other attributes for a particular multipath device and
@ reloading/restarting the multipathd service, only renaming of the multipath @ device is done, other attribute changes are ignored.
@
@ It is more evident if you directly run 'multipath -r' to reload devmap after @ adding the 'multipaths' section with alias into /etc/multipath.conf. @
@ When reload/restart multipathd service or 'multipath -r' again, new settings @ can be applied right.

It's because that in select_action() when force_reload is set, if we also need rename the mpp device, reload action won't be taken any more.

I did this patch by introducing a new action ACT_RENAME2 to group these two action. Test passed. However, it seems to be a rough patch and I am not certain if this bind is fine refering to dm_reassign. Please comment, Thanks.

---
 libmultipath/configure.c | 11 +++++++++++
 libmultipath/configure.h |  1 +
 2 files changed, 12 insertions(+)
libmultipath/configure.c +11 -0
index 3ed6b55..7331f90 100644
@@ -385,6 +385,8 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
 				cmpp->alias, mpp->alias);
 			strncpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
 			mpp->action = ACT_RENAME;
+			if (force_reload)
+				mpp->action = ACT_RENAME2;
 			return;
 		}
 		mpp->action = ACT_CREATE;
@@ -623,6 +625,15 @@ domap (struct multipath * mpp, char * params)
 		r = dm_rename(mpp->alias_old, mpp->alias);
 		break;
 
+	case ACT_RENAME2:
+		r = dm_rename(mpp->alias_old, mpp->alias);
+		if (r) {
+			r = dm_addmap_reload(mpp, params);
+			if (r)
+				r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias, MPATH_UDEV_RELOAD_FLAG);
+		}
+		break;
+
 	default:
 		break;
 	}
libmultipath/configure.h +1 -0
index b3a6bb8..c014b55 100644
@@ -18,6 +18,7 @@ enum actions {
 	ACT_RENAME,
 	ACT_CREATE,
 	ACT_RESIZE,
+	ACT_RENAME2,
 };
 
 #define FLUSH_ONE 1
Signature · 1 line
1.9.0
#1 lore raw

Applied.
Thanks.

Quoted 79 lines · Vaughan Cao

We encounter the following case:

@ After adding a multipaths section into /etc/multipath.conf to specify 'alias'
@ and other attributes for a particular multipath device and @ reloading/restarting the multipathd service, only renaming of the multipath
@ device is done, other attribute changes are ignored.
@
@ It is more evident if you directly run 'multipath -r' to reload devmap after
@ adding the 'multipaths' section with alias into /etc/multipath.conf. @
@ When reload/restart multipathd service or 'multipath -r' again, new settings
@ can be applied right.

It's because that in select_action() when force_reload is set, if we also need
rename the mpp device, reload action won't be taken any more.

I did this patch by introducing a new action ACT_RENAME2 to group these two action. Test passed. However, it seems to be a rough patch and I am not certain if this bind is fine refering to dm_reassign. Please comment, Thanks.

---
 libmultipath/configure.c | 11 +++++++++++
 libmultipath/configure.h |  1 +
 2 files changed, 12 insertions(+)
libmultipath/configure.c +2 -0
index 3ed6b55..7331f90 100644
@@ -385,6 +385,8 @@ select_action (struct multipath * mpp, vector curmp,
 int force_reload)
                                cmpp->alias, mpp->alias);
                        strncpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
                        mpp->action = ACT_RENAME;
+                       if (force_reload)
+                               mpp->action = ACT_RENAME2;
                        return;
                }
                mpp->action = ACT_CREATE;
libmultipath/configure.c +9 -0
@@ -623,6 +625,15 @@ domap (struct multipath * mpp, char * params)
                r = dm_rename(mpp->alias_old, mpp->alias);
                break;
 
+       case ACT_RENAME2:
+               r = dm_rename(mpp->alias_old, mpp->alias);
+               if (r) {
+                       r = dm_addmap_reload(mpp, params);
+                       if (r)
+                               r = dm_simplecmd_noflush(DM_DEVICE_RESUME,
 mpp->alias, MPATH_UDEV_RELOAD_FLAG);
+               }
+               break;
+
        default:
                break;
        }
libmultipath/configure.h +1 -1
index b3a6bb8..c014b55 100644
@@ -18,6 +18,7 @@ enum actions {
        ACT_RENAME,
        ACT_CREATE,
        ACT_RESIZE,
+       ACT_RENAME2,
 };
 
 #define FLUSH_ONE 1
--

1.9.0