From b96dead74e868431e37f9bc1829e500315eee239 Mon Sep 17 00:00:00 2001 From: Christophe Varoqui Date: Thu, 24 Nov 2005 12:09:58 +0100 Subject: [PATCH] [multipathd] remove the retry login in uev_remove_path() The last uev_remove_path() should succeed since in addition to removing from the map the path being removed by the uevent, it will also remove all paths found in the current map which do not appear in pathvec. This avoids long delays due to path verifying in the old code. Edward Goggin, EMC --- libmultipath/dmparser.c | 2 ++ libmultipath/structs_vec.c | 5 ++-- libmultipath/structs_vec.h | 2 +- multipathd/main.c | 58 ++++++++++++---------------------------------- 4 files changed, 21 insertions(+), 46 deletions(-) diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c index 76408bd..278a24e 100644 --- a/libmultipath/dmparser.c +++ b/libmultipath/dmparser.c @@ -272,8 +272,10 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp) strncpy(pp->dev_t, word, BLK_DEV_SIZE); +#ifndef DAEMON if (store_path(pathvec, pp)) goto out; +#endif } FREE(word); diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 99d8512..06edcb4 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -19,7 +19,7 @@ * creates or updates mpp->paths reading mpp->pg */ extern int -update_mpp_paths(struct multipath * mpp) +update_mpp_paths(struct multipath * mpp, vector pathvec) { struct pathgroup * pgp; struct path * pp; @@ -35,6 +35,7 @@ update_mpp_paths(struct multipath * mpp) vector_foreach_slot (mpp->pg, pgp, i) { vector_foreach_slot (pgp->paths, pp, j) { if (!find_path_by_devt(mpp->paths, pp->dev_t) && + (find_path_by_devt(pathvec, pp->dev_t)) && store_path(mpp->paths, pp)) return 1; } @@ -51,7 +52,7 @@ adopt_paths (vector pathvec, struct multipath * mpp) if (!mpp) return 0; - if (update_mpp_paths(mpp)) + if (update_mpp_paths(mpp, pathvec)) return 1; vector_foreach_slot (pathvec, pp, i) { diff --git a/libmultipath/structs_vec.h b/libmultipath/structs_vec.h index 9b75e9c..348e9e5 100644 --- a/libmultipath/structs_vec.h +++ b/libmultipath/structs_vec.h @@ -30,7 +30,7 @@ void orphan_paths (vector pathvec, struct multipath * mpp); void orphan_path (struct path * pp); int verify_paths(struct multipath * mpp, struct vectors * vecs, vector rpvec); -int update_mpp_paths(struct multipath * mpp); +int update_mpp_paths(struct multipath * mpp, vector pathvec); int setup_multipath (struct vectors * vecs, struct multipath * mpp); int update_multipath_strings (struct multipath *mpp, vector pathvec); diff --git a/multipathd/main.c b/multipathd/main.c index 1042e40..43624a4 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -614,7 +614,7 @@ uev_umount_map (char * devname, struct vectors * vecs) if (!mpp) return 0; - update_mpp_paths(mpp); + update_mpp_paths(mpp, vecs->pathvec); verify_paths(mpp, vecs, NULL); if (!VECTOR_SIZE(mpp->paths)) @@ -698,7 +698,7 @@ rescan: if (mpp->action == ACT_RELOAD) { condlog(0, "%s: uev_add_path sleep", mpp->alias); sleep(1); - update_mpp_paths(mpp); + update_mpp_paths(mpp, vecs->pathvec); goto rescan; } else @@ -729,7 +729,7 @@ uev_remove_path (char * devname, struct vectors * vecs) { struct multipath * mpp; struct path * pp; - int redo, i; + int i; int rm_path = 1; condlog(3, "%s: uev_remove_path", devname); @@ -750,19 +750,15 @@ uev_remove_path (char * devname, struct vectors * vecs) */ if (pathcount(mpp, PATH_WILD) > 1) { vector rpvec = vector_alloc(); - struct path * mypp; - int j; /* * transform the mp->pg vector of vectors of paths * into a mp->params string to feed the device-mapper */ - update_mpp_paths(mpp); + update_mpp_paths(mpp, vecs->pathvec); if ((i = find_slot(mpp->paths, (void *)pp)) != -1) vector_del_slot(mpp->paths, i); -rescan: - redo = verify_paths(mpp, vecs, rpvec); if (VECTOR_SIZE(mpp->paths) == 0) { char alias[WWID_SIZE]; @@ -770,33 +766,13 @@ rescan: * flush_map will fail if the device is open */ strncpy(alias, mpp->alias, WWID_SIZE); - if (flush_map(mpp, vecs)) { + if (flush_map(mpp, vecs)) rm_path = 0; - vector_foreach_slot(rpvec, mypp, i) - if (store_path(mpp->paths, mypp)) - goto out; - } - else { - vector_foreach_slot(rpvec, mypp, i) { - if ((j = find_slot(vecs->pathvec, - (void *)mypp)) != -1) { - vector_del_slot(vecs->pathvec, j); - free_path(mypp); - } - } + else condlog(3, "%s: removed map after removing" " multiple paths", alias); - } } else { - vector_foreach_slot(rpvec, mypp, i) { - if ((j = find_slot(vecs->pathvec, - (void *)mypp)) != -1) { - vector_del_slot(vecs->pathvec, j); - free_path(mypp); - } - } - if (setup_map(mpp)) { condlog(0, "%s: failed to setup map for" " removal of path %s", mpp->alias, devname); @@ -812,17 +788,14 @@ rescan: "removal of path %s", mpp->alias, devname); /* - * deal with asynchronous uevents :(( - */ - if (!redo) { - condlog(3, "%s: uev_remove_path sleep", - mpp->alias); - sleep(1); - } - update_mpp_paths(mpp); - free_pathvec(rpvec, KEEP_PATHS); - rpvec = vector_alloc(); - goto rescan; + * Delete path from pathvec so that + * update_mpp_paths wont find it later + * when/if another path is removed. + */ + if ((i = find_slot(vecs->pathvec, (void *)pp)) != -1) + vector_del_slot(vecs->pathvec, i); + free_path(pp); + return 1; } /* * update our state from kernel @@ -844,9 +817,8 @@ rescan: * flush_map will fail if the device is open */ strncpy(alias, mpp->alias, WWID_SIZE); - if (flush_map(mpp, vecs)) { + if (flush_map(mpp, vecs)) rm_path = 0; - } else condlog(3, "%s: removed map", alias); } -- 2.7.4