Allow zero paths for multipath map
PATCH 2/2 Allow zero paths for multipath map
There is no reason why multipath should handle the removal of the last path from a multipath map different than any other path removal. In fact, in doing so we'll shed the stale reference to the dead device in the map and allow for a clean reconnection.
Signed-off-by Hannes Reinecke <[email protected]>
--- libmultipath/configure.c | 6 +- libmultipath/dmparser.c | 15 +++- libmultipath/pgpolicies.c | 5 ++ libmultipath/structs.c | 22 +++++-- libmultipath/structs.h | 1 + libmultipath/structs_vec.c | 16 +++-- multipathd/main.c | 158 ++++++++++++++++++++------------------------ 7 files changed, 119 insertions(+), 104 deletions(-)
libmultipath/configure.c +3 -3
@@ -189,14 +189,14 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) mpp->alias);return ; } -if (strncmp (cmpp->hwhandler, mpp->hwhandler, +if (!cmpp->selector ||strncmp (cmpp->hwhandler, mpp->hwhandler,strlen (mpp->hwhandler))) { mpp->action =ACT_RELOAD ;condlog (3 ,"%s: set ACT_RELOAD (hwhandler change)" , mpp->alias);return ; } -if (strncmp (cmpp->selector, mpp->selector, +if (!cmpp->selector ||strncmp (cmpp->selector, mpp->selector,strlen (mpp->selector))) { mpp->action =ACT_RELOAD ; condlog(3, "%s: set ACT_RELOAD (selector change)",
@@ -209,7 +209,7 @@ select_action (struct multipath * mpp, vector curmp, int force_reload) mpp->alias, cmpp->minio, mpp->minio);return ; } -if (VECTOR_SIZE (cmpp->pg) !=VECTOR_SIZE (mpp->pg)) { +if (!cmpp->pg ||VECTOR_SIZE (cmpp->pg) !=VECTOR_SIZE (mpp->pg)) { mpp->action =ACT_RELOAD ;condlog (3 ,"%s: set ACT_RELOAD (path group number change)" , mpp->alias);
libmultipath/dmparser.c +11 -4
@@ -145,6 +145,8 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp)FREE (word);return 1 ; } +setup_feature (mpp, word); +FREE (word); }
@@ -182,11 +184,12 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp) num_pg =atoi (word);FREE (word); -if (num_pg >0 && !mpp->pg) +if (num_pg >0 && !mpp->pg) { mpp->pg =vector_alloc (); - -if (!mpp->pg) -return 1 ; +if (!mpp->pg) +return 1 ; + } +/* * first pg to try */
@@ -327,6 +330,7 @@ out1:FREE (word); out:free_pgvec (mpp->pg,KEEP_PATHS ); + mpp->pg =NULL ;return 1 ; }
@@ -396,6 +400,9 @@ disassemble_status (char * params, struct multipath * mpp) num_pg =atoi (word);FREE (word); +if (num_pg ==0 ) +return 0 ; +/* * next pg to try */
libmultipath/pgpolicies.c +5 -0
@@ -126,6 +126,7 @@ out1:FREE (bitmap); out:free_pgvec (mp->pg,KEEP_PATHS ); + mp->pg =NULL ;return 1 ; }
@@ -197,6 +198,7 @@ out1:FREE (bitmap); out:free_pgvec (mp->pg,KEEP_PATHS ); + mp->pg =NULL ;return 1 ; }
@@ -231,6 +233,7 @@ one_path_per_group (struct multipath * mp)return 0 ; out:free_pgvec (mp->pg,KEEP_PATHS ); + mp->pg =NULL ;return 1 ; }
@@ -263,6 +266,7 @@ one_group (struct multipath * mp) /* aka multibus */return 0 ; out:free_pgvec (mp->pg,KEEP_PATHS ); + mp->pg =NULL ;return 1 ; }
@@ -337,6 +341,7 @@ group_by_prio (struct multipath * mp)return 0 ; out:free_pgvec (mp->pg,KEEP_PATHS ); + mp->pg =NULL ;return 1 ; }
libmultipath/structs.c +17 -5
@@ -362,15 +362,27 @@ pathcount (struct multipath * mpp, int state)int count =0 ;int i; -vector_foreach_slot (mpp->pg, pgp, i) - count += pathcountgr(pgp, state); - +if (mpp->pg) { +vector_foreach_slot (mpp->pg, pgp, i) + count += pathcountgr(pgp, state); + }return count; }struct path *first_path (struct multipath * mpp) { -struct pathgroup * pgp =VECTOR_SLOT (mpp->pg,0 ); -return VECTOR_SLOT (pgp->paths,0 ); +struct pathgroup * pgp; +if (!mpp->pg) +return NULL ; + pgp =VECTOR_SLOT (mpp->pg,0 ); + +return pgp?VECTOR_SLOT (pgp->paths,0 ):NULL ; +} + +extern void +setup_feature (struct multipath * mpp,char *feature) +{ +if (!strncmp (feature,"queue_if_no_path" ,16 )) + mpp->no_path_retry =NO_PATH_RETRY_QUEUE ; }
libmultipath/structs.h +1 -0
@@ -211,6 +211,7 @@ struct path * first_path (struct multipath * mpp);int pathcountgr (struct pathgroup *,int );int pathcount (struct multipath *,int ); +void setup_feature (struct multipath *,char *);extern char sysfs_path[PATH_SIZE ];
libmultipath/structs_vec.c +10 -6
@@ -187,13 +187,16 @@ remove_maps_and_stop_waiters (struct vectors * vecs)static struct hwentry *extract_hwe_from_path (struct multipath * mpp) { -struct path * pp; -struct pathgroup * pgp; +struct path * pp =NULL ; +struct pathgroup * pgp =NULL ; + +if (mpp && mpp->pg) + pgp =VECTOR_SLOT (mpp->pg,0 ); - pgp =VECTOR_SLOT (mpp->pg,0 ); - pp =VECTOR_SLOT (pgp->paths,0 ); +if (pgp && pgp->paths) + pp =VECTOR_SLOT (pgp->paths,0 ); -return pp->hwe; +return pp?pp->hwe:NULL ; } static int
@@ -247,7 +250,8 @@ set_no_path_retry(struct multipath *mpp) { mpp->retry_tick =0 ; mpp->nr_active =pathcount (mpp,PATH_UP ) +pathcount (mpp,PATH_GHOST ); -select_no_path_retry (mpp); +if (mpp->nr_active >0 ) +select_no_path_retry (mpp);switch (mpp->no_path_retry) {case NO_PATH_RETRY_UNDEF :
multipathd/main.c +72 -86
237 lines not on this page · raw message
Signature · 1 line
1.5.2.4