[PATCH 01/13] multipathd: use symbolic values for wait_for_udev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/configure.c  |  2 +-
 libmultipath/structs.h    |  8 +++++++-
 multipathd/cli_handlers.c | 16 ++++++++--------
 multipathd/main.c         | 35 ++++++++++++++++++-----------------
 4 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index 191df1ef..534ca7f4 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -1018,7 +1018,7 @@ int domap(struct multipath *mpp, char *params, int is_daemon)
 				mpp->action = ACT_NOTHING;
 			else {
 				conf = get_multipath_config();
-				mpp->wait_for_udev = 1;
+				mpp->wait_for_udev = UDEV_WAIT_STARTED;
 				mpp->uev_wait_tick = conf->uev_wait_timeout;
 				put_multipath_config(conf);
 			}
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 9d22bdd0..1b5a878b 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -430,6 +430,12 @@ enum prio_update_type {
 	PRIO_UPDATE_MARGINAL,
 };
 
+enum udev_wait_states {
+	UDEV_WAIT_DONE = 0,
+	UDEV_WAIT_STARTED,
+	UDEV_WAIT_RELOAD,
+};
+
 struct multipath {
 	char wwid[WWID_SIZE];
 	char alias_old[WWID_SIZE];
@@ -441,7 +447,7 @@ struct multipath {
 	int bestpg;
 	int queuedio;
 	int action;
-	int wait_for_udev;
+	enum udev_wait_states wait_for_udev;
 	int uev_wait_tick;
 	int pgfailback;
 	int failback_tick;
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 0849fe51..4bcc82ac 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -812,7 +812,7 @@ cli_reload(void *v, struct strbuf *reply, void *data)
 	if (!mpp)
 		return -ENODEV;
 
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing reload",
 			mpp->alias);
 		return 1;
@@ -841,7 +841,7 @@ cli_resize(void *v, struct strbuf *reply, void *data)
 	if (!mpp)
 		return -ENODEV;
 
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing resize",
 			mpp->alias);
 		return 1;
@@ -1046,7 +1046,7 @@ cli_suspend(void * v, struct strbuf *reply, void * data)
 	if (!mpp)
 		return 1;
 
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing suspend",
 			mpp->alias);
 		return 1;
@@ -1078,7 +1078,7 @@ cli_resume(void * v, struct strbuf *reply, void * data)
 		return 1;
 
 	udev_flags = (mpp->skip_kpartx)? MPATH_UDEV_NO_KPARTX_FLAG : 0;
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing resume",
 			mpp->alias);
 		return 1;
@@ -1131,7 +1131,7 @@ cli_reassign (void * v, struct strbuf *reply, void * data)
 	if (!mpp)
 		return 1;
 
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing reassign",
 			mpp->alias);
 		return 1;
@@ -1406,7 +1406,7 @@ static int cli_set_marginal(void * v, struct strbuf *reply, void * data)
 
 	condlog(2, "%s: set marginal path %s (operator)",
 		pp->mpp->alias, pp->dev_t);
-	if (pp->mpp->wait_for_udev) {
+	if (pp->mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, failing set marginal",
 			pp->mpp->alias);
 		return 1;
@@ -1433,7 +1433,7 @@ static int cli_unset_marginal(void * v, struct strbuf *reply, void * data)
 
 	condlog(2, "%s: unset marginal path %s (operator)",
 		pp->mpp->alias, pp->dev_t);
-	if (pp->mpp->wait_for_udev) {
+	if (pp->mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, "
 			"failing unset marginal", pp->mpp->alias);
 		return 1;
@@ -1461,7 +1461,7 @@ static int cli_unset_all_marginal(void * v, struct strbuf *reply, void * data)
 	if (!mpp)
 		return -ENODEV;
 
-	if (mpp->wait_for_udev) {
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
 		condlog(2, "%s: device not fully created, "
 			"failing unset all marginal", mpp->alias);
 		return 1;
diff --git a/multipathd/main.c b/multipathd/main.c
index 4e26861d..3b4e61fc 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -331,7 +331,7 @@ static bool unblock_reconfigure(void)
  */
 void remove_map_callback(struct multipath *mpp)
 {
-	if (mpp->wait_for_udev > 0)
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE)
 		unblock_reconfigure();
 }
 
@@ -871,7 +871,7 @@ ev_add_map (char * dev, const char * alias, struct vectors * vecs)
 	mpp = find_mp_by_alias(vecs->mpvec, alias);
 
 	if (mpp) {
-		if (mpp->wait_for_udev > 1) {
+		if (mpp->wait_for_udev == UDEV_WAIT_RELOAD) {
 			condlog(2, "%s: performing delayed actions",
 				mpp->alias);
 			if (update_map(mpp, vecs, 0))
@@ -882,8 +882,8 @@ ev_add_map (char * dev, const char * alias, struct vectors * vecs)
 		reassign_maps = conf->reassign_maps;
 		put_multipath_config(conf);
 		dm_get_info(mpp->alias, &mpp->dmi);
-		if (mpp->wait_for_udev) {
-			mpp->wait_for_udev = 0;
+		if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
+			mpp->wait_for_udev = UDEV_WAIT_DONE;
 			if (!need_to_delay_reconfig(vecs) &&
 			    unblock_reconfigure())
 				return 0;
@@ -1241,7 +1241,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
 	}
 	if (mpp)
 		trigger_path_udev_change(pp, true);
-	if (mpp && mpp->wait_for_udev &&
+	if (mpp && mpp->wait_for_udev != UDEV_WAIT_DONE &&
 	    (pathcount(mpp, PATH_UP) > 0 ||
 	     (pathcount(mpp, PATH_GHOST) > 0 &&
 	      path_get_tpgs(pp) != TPGS_IMPLICIT &&
@@ -1249,7 +1249,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int need_do_map)
 		/* if wait_for_udev is set and valid paths exist */
 		condlog(3, "%s: delaying path addition until %s is fully initialized",
 			pp->dev, mpp->alias);
-		mpp->wait_for_udev = 2;
+		mpp->wait_for_udev = UDEV_WAIT_RELOAD;
 		orphan_path(pp, "waiting for create to complete");
 		return 0;
 	}
@@ -1433,8 +1433,8 @@ ev_remove_path (struct path *pp, struct vectors * vecs, int need_do_map)
 		    flush_map_nopaths(mpp, vecs))
 			goto out;
 
-		if (mpp->wait_for_udev) {
-			mpp->wait_for_udev = 2;
+		if (mpp->wait_for_udev != UDEV_WAIT_DONE) {
+			mpp->wait_for_udev = UDEV_WAIT_RELOAD;
 			retval = REMOVE_PATH_DELAY;
 			goto out;
 		}
@@ -1646,8 +1646,8 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 		if (needs_ro_update(mpp, ro)) {
 			condlog(2, "%s: update path write_protect to '%d' (uevent)", uev->kernel, ro);
 
-			if (mpp->wait_for_udev)
-				mpp->wait_for_udev = 2;
+			if (mpp->wait_for_udev != UDEV_WAIT_DONE)
+				mpp->wait_for_udev = UDEV_WAIT_RELOAD;
 			else {
 				if (ro == 1)
 					pp->mpp->force_readonly = 1;
@@ -1661,7 +1661,7 @@ uev_update_path (struct uevent *uev, struct vectors * vecs)
 			}
 		}
 		if (auto_resize != AUTO_RESIZE_NEVER && mpp &&
-		    !mpp->wait_for_udev) {
+		    mpp->wait_for_udev == UDEV_WAIT_DONE) {
 			struct pathgroup *pgp;
 			struct path *pp2;
 			unsigned int i, j;
@@ -2018,13 +2018,13 @@ followover_should_failback(struct multipath *mpp)
 static bool
 missing_uev_wait_tick(struct multipath *mpp, bool *timed_out)
 {
-	if (mpp->wait_for_udev && --mpp->uev_wait_tick <= 0) {
-		int wait = mpp->wait_for_udev;
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE && --mpp->uev_wait_tick <= 0) {
+		enum udev_wait_states wait = mpp->wait_for_udev;
 
-		mpp->wait_for_udev = 0;
+		mpp->wait_for_udev = UDEV_WAIT_DONE;
 		*timed_out = true;
 		condlog(0, "%s: timeout waiting on creation uevent. enabling reloads", mpp->alias);
-		return wait > 1;
+		return wait == UDEV_WAIT_RELOAD;
 	}
 	return false;
 }
@@ -2635,7 +2635,8 @@ static bool update_mpp_prio(struct multipath *mpp)
 	enum prio_update_type prio_update = mpp->prio_update;
 	mpp->prio_update = PRIO_UPDATE_NONE;
 
-	if (mpp->wait_for_udev || prio_update == PRIO_UPDATE_NONE)
+	if (mpp->wait_for_udev != UDEV_WAIT_DONE ||
+	    prio_update == PRIO_UPDATE_NONE)
 		return false;
 	condlog(4, "prio refresh");
 
@@ -3246,7 +3247,7 @@ need_to_delay_reconfig(struct vectors * vecs)
 		return 0;
 
 	vector_foreach_slot(vecs->mpvec, mpp, i) {
-		if (mpp->wait_for_udev)
+		if (mpp->wait_for_udev != UDEV_WAIT_DONE)
 			return 1;
 	}
 	return 0;
-- 
2.46.2





[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux