All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/7] multipathd 'cookie' handling rework
@ 2016-05-09 10:52 Hannes Reinecke
  2016-05-09 10:52 ` [PATCH 1/7] devmapper: do not flush I/O for DM_DEVICE_CREATE Hannes Reinecke
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:52 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: dm-devel

Hi all,

here's now the second attempt to fixup the 'cookie' handling
in multipath-tools.
I've removed the patch to pass in a cookie as an argument
for dm_addmap_reload() and dm_simplecmd().
And I've removed all instances where we had been calling
dm_udev_complete() after failing to set the cookie to a task.

As usual, reviews and comments are welcome.

Hannes Reinecke (7):
  devmapper: do not flush I/O for DM_DEVICE_CREATE
  devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed
  configure: Rename ACT_RENAME2 to ACT_FORCERENAME
  devmapper: wait for udev in dm_simplecmd_noflush()
  multipathd: wait for udev in cli_resume()
  devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()
  libmultipath: Fixup 'DM_DEVICE_RELOAD' handling

 libmultipath/configure.c  | 20 ++++---------
 libmultipath/configure.h  |  2 +-
 libmultipath/devmapper.c  | 75 +++++++++++++++++++++++++++++++----------------
 libmultipath/devmapper.h  |  4 +--
 multipathd/cli_handlers.c |  4 +--
 5 files changed, 60 insertions(+), 45 deletions(-)

-- 
2.6.6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/7] devmapper: do not flush I/O for DM_DEVICE_CREATE
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
@ 2016-05-09 10:52 ` Hannes Reinecke
  2016-05-09 10:53 ` [PATCH 2/7] devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed Hannes Reinecke
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:52 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: dm-devel

DM_DEVICE_CREATE loads a new table, so there cannot be any
I/O pending. Hence we should be setting the 'no flush'
and 'skip lockfs' flag to avoid delays during creation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 libmultipath/devmapper.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index fb202e8..2ac62a5 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -285,16 +285,23 @@ dm_addmap (int task, const char *target, struct multipath *mpp,
 	if (ro)
 		dm_task_set_ro(dmt);
 
-	if ((task == DM_DEVICE_CREATE) && strlen(mpp->wwid) > 0){
-		prefixed_uuid = MALLOC(UUID_PREFIX_LEN + strlen(mpp->wwid) + 1);
-		if (!prefixed_uuid) {
-			condlog(0, "cannot create prefixed uuid : %s",
-				strerror(errno));
-			goto addout;
+	if (task == DM_DEVICE_CREATE) {
+		if (strlen(mpp->wwid) > 0) {
+			prefixed_uuid = MALLOC(UUID_PREFIX_LEN +
+					       strlen(mpp->wwid) + 1);
+			if (!prefixed_uuid) {
+				condlog(0, "cannot create prefixed uuid : %s",
+					strerror(errno));
+				goto addout;
+			}
+			sprintf(prefixed_uuid, UUID_PREFIX "%s", mpp->wwid);
+			if (!dm_task_set_uuid(dmt, prefixed_uuid))
+				goto freeout;
 		}
-		sprintf(prefixed_uuid, UUID_PREFIX "%s", mpp->wwid);
-		if (!dm_task_set_uuid(dmt, prefixed_uuid))
-			goto freeout;
+		dm_task_skip_lockfs(dmt);
+#ifdef LIBDM_API_FLUSH
+		dm_task_no_flush(dmt);
+#endif
 	}
 
 	if (mpp->attribute_flags & (1 << ATTR_MODE) &&
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/7] devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
  2016-05-09 10:52 ` [PATCH 1/7] devmapper: do not flush I/O for DM_DEVICE_CREATE Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 10:53 ` [PATCH 3/7] configure: Rename ACT_RENAME2 to ACT_FORCERENAME Hannes Reinecke
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

As per Benjamin Marzinski libdevice-mapper will take care of cleaning
up the cookie for us.
So there's no need to call dm_udev_complete() if dm_task_set_cookie()
fails.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/devmapper.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 2ac62a5..8a89f46 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -232,10 +232,9 @@ dm_simplecmd (int task, const char *name, int no_flush, int need_sync, uint16_t
 #endif
 	if (udev_wait_flag &&
 	    !dm_task_set_cookie(dmt, &cookie,
-				DM_UDEV_DISABLE_LIBRARY_FALLBACK | udev_flags)) {
-		dm_udev_complete(cookie);
+				DM_UDEV_DISABLE_LIBRARY_FALLBACK | udev_flags))
 		goto out;
-	}
+
 	r = dm_task_run (dmt);
 
 	if (udev_wait_flag) {
@@ -320,10 +319,9 @@ dm_addmap (int task, const char *target, struct multipath *mpp,
 
 	if (task == DM_DEVICE_CREATE &&
 	    !dm_task_set_cookie(dmt, &cookie,
-				DM_UDEV_DISABLE_LIBRARY_FALLBACK)) {
-		dm_udev_complete(cookie);
+				DM_UDEV_DISABLE_LIBRARY_FALLBACK))
 		goto freeout;
-	}
+
 	r = dm_task_run (dmt);
 
 	if (task == DM_DEVICE_CREATE) {
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/7] configure: Rename ACT_RENAME2 to ACT_FORCERENAME
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
  2016-05-09 10:52 ` [PATCH 1/7] devmapper: do not flush I/O for DM_DEVICE_CREATE Hannes Reinecke
  2016-05-09 10:53 ` [PATCH 2/7] devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 10:53 ` [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush() Hannes Reinecke
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

Use a more descriptive name instead of 'ACT_RENAME2'.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/configure.c | 4 ++--
 libmultipath/configure.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index affd1d5..b976da7 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -398,7 +398,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload)
 			strncpy(mpp->alias_old, cmpp->alias, WWID_SIZE);
 			mpp->action = ACT_RENAME;
 			if (force_reload)
-				mpp->action = ACT_RENAME2;
+				mpp->action = ACT_FORCERENAME;
 			return;
 		}
 		mpp->action = ACT_CREATE;
@@ -641,7 +641,7 @@ domap (struct multipath * mpp, char * params)
 		r = dm_rename(mpp->alias_old, mpp->alias);
 		break;
 
-	case ACT_RENAME2:
+	case ACT_FORCERENAME:
 		r = dm_rename(mpp->alias_old, mpp->alias);
 		if (r) {
 			r = dm_addmap_reload(mpp, params);
diff --git a/libmultipath/configure.h b/libmultipath/configure.h
index c014b55..f357d9a 100644
--- a/libmultipath/configure.h
+++ b/libmultipath/configure.h
@@ -18,7 +18,7 @@ enum actions {
 	ACT_RENAME,
 	ACT_CREATE,
 	ACT_RESIZE,
-	ACT_RENAME2,
+	ACT_FORCERENAME,
 };
 
 #define FLUSH_ONE 1
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush()
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
                   ` (2 preceding siblings ...)
  2016-05-09 10:53 ` [PATCH 3/7] configure: Rename ACT_RENAME2 to ACT_FORCERENAME Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 17:57   ` Benjamin Marzinski
  2016-05-09 10:53 ` [PATCH 5/7] multipathd: wait for udev in cli_resume() Hannes Reinecke
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

When calling dm_simplecmd_noflush() with udev_flags set we
need to set the 'need_sync' flag otherwise the udev flags
will never be set.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/configure.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index b976da7..9c6904a 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -628,7 +628,7 @@ domap (struct multipath * mpp, char * params)
 		r = dm_addmap_reload(mpp, params);
 		if (r)
 			r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias,
-						 0, MPATH_UDEV_RELOAD_FLAG);
+						 1, MPATH_UDEV_RELOAD_FLAG);
 		break;
 
 	case ACT_RESIZE:
@@ -646,7 +646,9 @@ domap (struct multipath * mpp, char * params)
 		if (r) {
 			r = dm_addmap_reload(mpp, params);
 			if (r)
-				r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias, 0, MPATH_UDEV_RELOAD_FLAG);
+				r = dm_simplecmd_noflush(DM_DEVICE_RESUME,
+							 mpp->alias, 1,
+							 MPATH_UDEV_RELOAD_FLAG);
 		}
 		break;
 
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/7] multipathd: wait for udev in cli_resume()
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
                   ` (3 preceding siblings ...)
  2016-05-09 10:53 ` [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush() Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 18:01   ` Benjamin Marzinski
  2016-05-09 10:53 ` [PATCH 6/7] devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush() Hannes Reinecke
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

When calling 'cli_resume()' we should be waiting for udev to
ensure the device really has been resumed.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 multipathd/cli_handlers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 0397353..5112786 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -967,7 +967,7 @@ cli_resume(void * v, char ** reply, int * len, void * data)
 		return 1;
 	}
 
-	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 0, 0);
+	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 1, 0);
 
 	condlog(2, "%s: resume (operator)", param);
 
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/7] devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
                   ` (4 preceding siblings ...)
  2016-05-09 10:53 ` [PATCH 5/7] multipathd: wait for udev in cli_resume() Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 10:53 ` [PATCH 7/7] libmultipath: Fixup 'DM_DEVICE_RELOAD' handling Hannes Reinecke
  2016-05-09 18:02 ` [PATCHv2 0/7] multipathd 'cookie' handling rework Benjamin Marzinski
  7 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: Hannes Reinecke, dm-devel

The 'udev_sync' argument is always '1', so we can remove it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 libmultipath/configure.c  | 4 ++--
 libmultipath/devmapper.c  | 9 +++++----
 libmultipath/devmapper.h  | 2 +-
 multipathd/cli_handlers.c | 4 ++--
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 9c6904a..708dae8 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -628,7 +628,7 @@ domap (struct multipath * mpp, char * params)
 		r = dm_addmap_reload(mpp, params);
 		if (r)
 			r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias,
-						 1, MPATH_UDEV_RELOAD_FLAG);
+						 MPATH_UDEV_RELOAD_FLAG);
 		break;
 
 	case ACT_RESIZE:
@@ -647,7 +647,7 @@ domap (struct multipath * mpp, char * params)
 			r = dm_addmap_reload(mpp, params);
 			if (r)
 				r = dm_simplecmd_noflush(DM_DEVICE_RESUME,
-							 mpp->alias, 1,
+							 mpp->alias,
 							 MPATH_UDEV_RELOAD_FLAG);
 		}
 		break;
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 8a89f46..6983ab6 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -254,8 +254,8 @@ dm_simplecmd_flush (int task, const char *name, uint16_t udev_flags) {
 }
 
 extern int
-dm_simplecmd_noflush (int task, const char *name, int needsync, uint16_t udev_flags) {
-	return dm_simplecmd(task, name, 1, needsync, udev_flags, 0);
+dm_simplecmd_noflush (int task, const char *name, uint16_t udev_flags) {
+	return dm_simplecmd(task, name, 1, 1, udev_flags, 0);
 }
 
 static int
@@ -847,7 +847,7 @@ dm_suspend_and_flush_map (const char * mapname)
 		return 0;
 	}
 	condlog(2, "failed to remove multipath map %s", mapname);
-	dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, 1, 0);
+	dm_simplecmd_noflush(DM_DEVICE_RESUME, mapname, 0);
 	if (queue_if_no_path)
 		s = dm_queue_if_no_path((char *)mapname, 1);
 	return 1;
@@ -1486,7 +1486,8 @@ int dm_reassign_table(const char *name, char *old, char *new)
 			condlog(3, "%s: failed to reassign targets", name);
 			goto out_reload;
 		}
-		dm_simplecmd_noflush(DM_DEVICE_RESUME, name, 1, MPATH_UDEV_RELOAD_FLAG);
+		dm_simplecmd_noflush(DM_DEVICE_RESUME, name,
+				     MPATH_UDEV_RELOAD_FLAG);
 	}
 	r = 1;
 
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index 8dd0963..bc13b07 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -16,7 +16,7 @@ void dm_init(void);
 int dm_prereq (void);
 int dm_drv_version (unsigned int * version, char * str);
 int dm_simplecmd_flush (int, const char *, uint16_t);
-int dm_simplecmd_noflush (int, const char *, int, uint16_t);
+int dm_simplecmd_noflush (int, const char *, uint16_t);
 int dm_addmap_create (struct multipath *mpp, char *params);
 int dm_addmap_reload (struct multipath *mpp, char *params);
 int dm_map_present (const char *);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 5112786..8b3cb9d 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -937,7 +937,7 @@ cli_suspend(void * v, char ** reply, int * len, void * data)
 		return 1;
 	}
 
-	r = dm_simplecmd_noflush(DM_DEVICE_SUSPEND, param, 0, 0);
+	r = dm_simplecmd_noflush(DM_DEVICE_SUSPEND, param, 0);
 
 	condlog(2, "%s: suspend (operator)", param);
 
@@ -967,7 +967,7 @@ cli_resume(void * v, char ** reply, int * len, void * data)
 		return 1;
 	}
 
-	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 1, 0);
+	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 0);
 
 	condlog(2, "%s: resume (operator)", param);
 
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 7/7] libmultipath: Fixup 'DM_DEVICE_RELOAD' handling
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
                   ` (5 preceding siblings ...)
  2016-05-09 10:53 ` [PATCH 6/7] devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush() Hannes Reinecke
@ 2016-05-09 10:53 ` Hannes Reinecke
  2016-05-09 18:02 ` [PATCHv2 0/7] multipathd 'cookie' handling rework Benjamin Marzinski
  7 siblings, 0 replies; 12+ messages in thread
From: Hannes Reinecke @ 2016-05-09 10:53 UTC (permalink / raw)
  To: Christophe Varoqui; +Cc: dm-devel

libdevmapper has the 'quirk' that DM_DEVICE_CREATE is translated
internally into a create/load/resume sequence, and the associated
cookie will wait for the last 'resume' to complete.
However, DM_DEVICE_RELOAD has no such translation, so if there
is a cookie assigned to it the caller _cannot_ wait for it,
as the cookie will only ever be completed upon the next
DM_DEVICE_RESUME.
multipathd already has some provisions for that (but even there
the cookie handling is dodgy), but 'multipath -r' doesn't know
about this.
So to avoid any future irritations this patch updates the
dm_addmad_reload() call to handle the call to DM_DEVICE_RESUME
correctly and removes the special handling from domap().

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 libmultipath/configure.c | 18 ++++--------------
 libmultipath/devmapper.c | 31 ++++++++++++++++++++++++-------
 libmultipath/devmapper.h |  2 +-
 3 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 708dae8..a4a2c44 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -625,16 +625,11 @@ domap (struct multipath * mpp, char * params)
 		break;
 
 	case ACT_RELOAD:
-		r = dm_addmap_reload(mpp, params);
-		if (r)
-			r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias,
-						 MPATH_UDEV_RELOAD_FLAG);
+		r = dm_addmap_reload(mpp, params, 0);
 		break;
 
 	case ACT_RESIZE:
-		r = dm_addmap_reload(mpp, params);
-		if (r)
-			r = dm_simplecmd_flush(DM_DEVICE_RESUME, mpp->alias, 0);
+		r = dm_addmap_reload(mpp, params, 1);
 		break;
 
 	case ACT_RENAME:
@@ -643,13 +638,8 @@ domap (struct multipath * mpp, char * params)
 
 	case ACT_FORCERENAME:
 		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);
-		}
+		if (r)
+			r = dm_addmap_reload(mpp, params, 0);
 		break;
 
 	default:
diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 6983ab6..6d1a5d6 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -312,7 +312,8 @@ dm_addmap (int task, const char *target, struct multipath *mpp,
 	if (mpp->attribute_flags & (1 << ATTR_GID) &&
 	    !dm_task_set_gid(dmt, mpp->gid))
 		goto freeout;
-	condlog(4, "%s: addmap [0 %llu %s %s]", mpp->alias, mpp->size,
+	condlog(4, "%s: %s [0 %llu %s %s]", mpp->alias,
+		task == DM_DEVICE_RELOAD ? "reload" : "addmap", mpp->size,
 		target, params);
 
 	dm_task_no_open_count(dmt);
@@ -371,12 +372,28 @@ dm_addmap_create (struct multipath *mpp, char * params) {
 #define ADDMAP_RO 1
 
 extern int
-dm_addmap_reload (struct multipath *mpp, char *params) {
-	if (dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, ADDMAP_RW))
-		return 1;
-	if (errno != EROFS)
-		return 0;
-	return dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, ADDMAP_RO);
+dm_addmap_reload (struct multipath *mpp, char *params, int flush)
+{
+	int r;
+	uint16_t udev_flags = flush ? 0 : MPATH_UDEV_RELOAD_FLAG;
+
+	/*
+	 * DM_DEVICE_RELOAD cannot wait on a cookie, as
+	 * the cookie will only ever be released after an
+	 * DM_DEVICE_RESUME. So call DM_DEVICE_RESUME
+	 * after each successful call to DM_DEVICE_RELOAD.
+	 */
+	r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp, params, ADDMAP_RW);
+	if (!r) {
+		if (errno != EROFS)
+			return 0;
+		r = dm_addmap(DM_DEVICE_RELOAD, TGT_MPATH, mpp,
+			      params, ADDMAP_RO);
+	}
+	if (r)
+		r = dm_simplecmd(DM_DEVICE_RESUME, mpp->alias, flush,
+				 1, udev_flags, 0);
+	return r;
 }
 
 extern int
diff --git a/libmultipath/devmapper.h b/libmultipath/devmapper.h
index bc13b07..b5df369 100644
--- a/libmultipath/devmapper.h
+++ b/libmultipath/devmapper.h
@@ -18,7 +18,7 @@ int dm_drv_version (unsigned int * version, char * str);
 int dm_simplecmd_flush (int, const char *, uint16_t);
 int dm_simplecmd_noflush (int, const char *, uint16_t);
 int dm_addmap_create (struct multipath *mpp, char *params);
-int dm_addmap_reload (struct multipath *mpp, char *params);
+int dm_addmap_reload (struct multipath *mpp, char *params, int flush);
 int dm_map_present (const char *);
 int dm_get_map(const char *, unsigned long long *, char *);
 int dm_get_status(char *, char *);
-- 
2.6.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush()
  2016-05-09 10:53 ` [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush() Hannes Reinecke
@ 2016-05-09 17:57   ` Benjamin Marzinski
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Marzinski @ 2016-05-09 17:57 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Hannes Reinecke, Christophe Varoqui

On Mon, May 09, 2016 at 12:53:02PM +0200, Hannes Reinecke wrote:
> When calling dm_simplecmd_noflush() with udev_flags set we
> need to set the 'need_sync' flag otherwise the udev flags
> will never be set.

The other possibility here would be to temporarily disable udev sync
support, and then restore it afterwards. That way we could still pass
the flags, but we wouldn't need to wait on these table reloads.  Either
that or to get libdevmapper to give us a cookie flag that says, "while,
I do have sync support enabled, for this one command, I'd like to skip
it".  But neither of those options has any significant benefit over this
solution.

ACK.

-Ben

> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  libmultipath/configure.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libmultipath/configure.c b/libmultipath/configure.c
> index b976da7..9c6904a 100644
> --- a/libmultipath/configure.c
> +++ b/libmultipath/configure.c
> @@ -628,7 +628,7 @@ domap (struct multipath * mpp, char * params)
>  		r = dm_addmap_reload(mpp, params);
>  		if (r)
>  			r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias,
> -						 0, MPATH_UDEV_RELOAD_FLAG);
> +						 1, MPATH_UDEV_RELOAD_FLAG);
>  		break;
>  
>  	case ACT_RESIZE:
> @@ -646,7 +646,9 @@ domap (struct multipath * mpp, char * params)
>  		if (r) {
>  			r = dm_addmap_reload(mpp, params);
>  			if (r)
> -				r = dm_simplecmd_noflush(DM_DEVICE_RESUME, mpp->alias, 0, MPATH_UDEV_RELOAD_FLAG);
> +				r = dm_simplecmd_noflush(DM_DEVICE_RESUME,
> +							 mpp->alias, 1,
> +							 MPATH_UDEV_RELOAD_FLAG);
>  		}
>  		break;
>  
> -- 
> 2.6.6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 5/7] multipathd: wait for udev in cli_resume()
  2016-05-09 10:53 ` [PATCH 5/7] multipathd: wait for udev in cli_resume() Hannes Reinecke
@ 2016-05-09 18:01   ` Benjamin Marzinski
  0 siblings, 0 replies; 12+ messages in thread
From: Benjamin Marzinski @ 2016-05-09 18:01 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Hannes Reinecke, Christophe Varoqui

On Mon, May 09, 2016 at 12:53:03PM +0200, Hannes Reinecke wrote:
> When calling 'cli_resume()' we should be waiting for udev to
> ensure the device really has been resumed.

Since multipathd has udev sync support disabled, this change doesn't do
anything (which is fine, since I don't see any need to wait for udev
here). It does allow your next patch to remove the need_sync option,
which is (I assume) the bigger point.

ACK

-Ben

> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  multipathd/cli_handlers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
> index 0397353..5112786 100644
> --- a/multipathd/cli_handlers.c
> +++ b/multipathd/cli_handlers.c
> @@ -967,7 +967,7 @@ cli_resume(void * v, char ** reply, int * len, void * data)
>  		return 1;
>  	}
>  
> -	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 0, 0);
> +	r = dm_simplecmd_noflush(DM_DEVICE_RESUME, param, 1, 0);
>  
>  	condlog(2, "%s: resume (operator)", param);
>  
> -- 
> 2.6.6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCHv2 0/7] multipathd 'cookie' handling rework
  2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
                   ` (6 preceding siblings ...)
  2016-05-09 10:53 ` [PATCH 7/7] libmultipath: Fixup 'DM_DEVICE_RELOAD' handling Hannes Reinecke
@ 2016-05-09 18:02 ` Benjamin Marzinski
  2016-05-10  6:15   ` Christophe Varoqui
  7 siblings, 1 reply; 12+ messages in thread
From: Benjamin Marzinski @ 2016-05-09 18:02 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: dm-devel, Christophe Varoqui

On Mon, May 09, 2016 at 12:52:58PM +0200, Hannes Reinecke wrote:
> Hi all,
> 
> here's now the second attempt to fixup the 'cookie' handling
> in multipath-tools.
> I've removed the patch to pass in a cookie as an argument
> for dm_addmap_reload() and dm_simplecmd().
> And I've removed all instances where we had been calling
> dm_udev_complete() after failing to set the cookie to a task.
> 
> As usual, reviews and comments are welcome.

ACK for the whole set.

Thanks for working through all this.
-Ben

> 
> Hannes Reinecke (7):
>   devmapper: do not flush I/O for DM_DEVICE_CREATE
>   devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed
>   configure: Rename ACT_RENAME2 to ACT_FORCERENAME
>   devmapper: wait for udev in dm_simplecmd_noflush()
>   multipathd: wait for udev in cli_resume()
>   devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()
>   libmultipath: Fixup 'DM_DEVICE_RELOAD' handling
> 
>  libmultipath/configure.c  | 20 ++++---------
>  libmultipath/configure.h  |  2 +-
>  libmultipath/devmapper.c  | 75 +++++++++++++++++++++++++++++++----------------
>  libmultipath/devmapper.h  |  4 +--
>  multipathd/cli_handlers.c |  4 +--
>  5 files changed, 60 insertions(+), 45 deletions(-)
> 
> -- 
> 2.6.6

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCHv2 0/7] multipathd 'cookie' handling rework
  2016-05-09 18:02 ` [PATCHv2 0/7] multipathd 'cookie' handling rework Benjamin Marzinski
@ 2016-05-10  6:15   ` Christophe Varoqui
  0 siblings, 0 replies; 12+ messages in thread
From: Christophe Varoqui @ 2016-05-10  6:15 UTC (permalink / raw)
  To: Benjamin Marzinski; +Cc: device-mapper development


[-- Attachment #1.1: Type: text/plain, Size: 1525 bytes --]

Merged.

multipath.conf.* are dropped.
the version code is bumped to 0.6.1

Thanks,
Christophe Varoqui
www.opensvc.com


On Mon, May 9, 2016 at 8:02 PM, Benjamin Marzinski <bmarzins@redhat.com>
wrote:

> On Mon, May 09, 2016 at 12:52:58PM +0200, Hannes Reinecke wrote:
> > Hi all,
> >
> > here's now the second attempt to fixup the 'cookie' handling
> > in multipath-tools.
> > I've removed the patch to pass in a cookie as an argument
> > for dm_addmap_reload() and dm_simplecmd().
> > And I've removed all instances where we had been calling
> > dm_udev_complete() after failing to set the cookie to a task.
> >
> > As usual, reviews and comments are welcome.
>
> ACK for the whole set.
>
> Thanks for working through all this.
> -Ben
>
> >
> > Hannes Reinecke (7):
> >   devmapper: do not flush I/O for DM_DEVICE_CREATE
> >   devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed
> >   configure: Rename ACT_RENAME2 to ACT_FORCERENAME
> >   devmapper: wait for udev in dm_simplecmd_noflush()
> >   multipathd: wait for udev in cli_resume()
> >   devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush()
> >   libmultipath: Fixup 'DM_DEVICE_RELOAD' handling
> >
> >  libmultipath/configure.c  | 20 ++++---------
> >  libmultipath/configure.h  |  2 +-
> >  libmultipath/devmapper.c  | 75
> +++++++++++++++++++++++++++++++----------------
> >  libmultipath/devmapper.h  |  4 +--
> >  multipathd/cli_handlers.c |  4 +--
> >  5 files changed, 60 insertions(+), 45 deletions(-)
> >
> > --
> > 2.6.6
>

[-- Attachment #1.2: Type: text/html, Size: 2275 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-05-10  6:15 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09 10:52 [PATCHv2 0/7] multipathd 'cookie' handling rework Hannes Reinecke
2016-05-09 10:52 ` [PATCH 1/7] devmapper: do not flush I/O for DM_DEVICE_CREATE Hannes Reinecke
2016-05-09 10:53 ` [PATCH 2/7] devmapper: do not call dm_udev_complete if dm_task_set_cookie() failed Hannes Reinecke
2016-05-09 10:53 ` [PATCH 3/7] configure: Rename ACT_RENAME2 to ACT_FORCERENAME Hannes Reinecke
2016-05-09 10:53 ` [PATCH 4/7] devmapper: wait for udev in dm_simplecmd_noflush() Hannes Reinecke
2016-05-09 17:57   ` Benjamin Marzinski
2016-05-09 10:53 ` [PATCH 5/7] multipathd: wait for udev in cli_resume() Hannes Reinecke
2016-05-09 18:01   ` Benjamin Marzinski
2016-05-09 10:53 ` [PATCH 6/7] devmapper: remove 'udev_sync' argument from dm_simplecmd_noflush() Hannes Reinecke
2016-05-09 10:53 ` [PATCH 7/7] libmultipath: Fixup 'DM_DEVICE_RELOAD' handling Hannes Reinecke
2016-05-09 18:02 ` [PATCHv2 0/7] multipathd 'cookie' handling rework Benjamin Marzinski
2016-05-10  6:15   ` Christophe Varoqui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.