In preparation for a future patch, make prflag an enum, and change the
reply of cli_getprstatus() to a string.

Signed-off-by: Benjamin Marzinski <bmarz...@redhat.com>
---
 libmpathpersist/mpath_persist_int.c |  2 +-
 libmultipath/structs.h              |  8 +++++++-
 multipathd/cli_handlers.c           | 17 +++++++++--------
 multipathd/main.c                   | 14 +++++++-------
 4 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/libmpathpersist/mpath_persist_int.c 
b/libmpathpersist/mpath_persist_int.c
index 6924b379..a84d9474 100644
--- a/libmpathpersist/mpath_persist_int.c
+++ b/libmpathpersist/mpath_persist_int.c
@@ -783,7 +783,7 @@ int update_map_pr(struct multipath *mpp)
 
        if (isFound)
        {
-               mpp->prflag = 1;
+               mpp->prflag = PRFLAG_SET;
                condlog(2, "%s: prflag flag set.", mpp->alias );
        }
 
diff --git a/libmultipath/structs.h b/libmultipath/structs.h
index 9e2c1ab0..f2265300 100644
--- a/libmultipath/structs.h
+++ b/libmultipath/structs.h
@@ -375,6 +375,12 @@ struct path {
 
 typedef int (pgpolicyfn) (struct multipath *, vector);
 
+
+enum prflag_value {
+       PRFLAG_UNSET,
+       PRFLAG_SET,
+};
+
 struct multipath {
        char wwid[WWID_SIZE];
        char alias_old[WWID_SIZE];
@@ -449,7 +455,7 @@ struct multipath {
        int prkey_source;
        struct be64 reservation_key;
        uint8_t sa_flags;
-       unsigned char prflag;
+       int prflag;
        int all_tg_pt;
        struct gen_multipath generic_mp;
        bool fpin_must_reload;
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index e65fb75c..7ee2729f 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1277,6 +1277,10 @@ cli_shutdown (void * v, struct strbuf *reply, void * 
data)
 static int
 cli_getprstatus (void * v, struct strbuf *reply, void * data)
 {
+       static const char * const prflag_str[] = {
+               [PRFLAG_UNSET] = "unset\n",
+               [PRFLAG_SET] = "set\n",
+       };
        struct multipath * mpp;
        struct vectors * vecs = (struct vectors *)data;
        char * param = get_keyparam(v, KEY_MAP);
@@ -1287,10 +1291,7 @@ cli_getprstatus (void * v, struct strbuf *reply, void * 
data)
        if (!mpp)
                return 1;
 
-       condlog(3, "%s: prflag = %u", param, (unsigned int)mpp->prflag);
-
-       if (print_strbuf(reply, "%d", mpp->prflag) < 0)
-               return 1;
+       append_strbuf_str(reply, prflag_str[mpp->prflag]);
 
        condlog(3, "%s: reply = %s", param, get_strbuf_str(reply));
 
@@ -1310,8 +1311,8 @@ cli_setprstatus(void * v, struct strbuf *reply, void * 
data)
        if (!mpp)
                return 1;
 
-       if (!mpp->prflag) {
-               mpp->prflag = 1;
+       if (mpp->prflag != PRFLAG_SET) {
+               mpp->prflag = PRFLAG_SET;
                condlog(2, "%s: prflag set", param);
        }
 
@@ -1332,8 +1333,8 @@ cli_unsetprstatus(void * v, struct strbuf *reply, void * 
data)
        if (!mpp)
                return 1;
 
-       if (mpp->prflag) {
-               mpp->prflag = 0;
+       if (mpp->prflag != PRFLAG_UNSET) {
+               mpp->prflag = PRFLAG_UNSET;
                condlog(2, "%s: prflag unset", param);
        }
 
diff --git a/multipathd/main.c b/multipathd/main.c
index f7212d7b..722235c7 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -647,9 +647,9 @@ fail:
 
        sync_map_state(mpp);
 
-       if (!mpp->prflag)
+       if (mpp->prflag == PRFLAG_UNSET)
                update_map_pr(mpp);
-       if (mpp->prflag)
+       if (mpp->prflag == PRFLAG_SET)
                pr_register_active_paths(mpp);
 
        if (retries < 0)
@@ -1200,7 +1200,7 @@ ev_add_path (struct path * pp, struct vectors * vecs, int 
need_do_map)
        int start_waiter = 0;
        int ret;
        int ro;
-       unsigned char prflag = 0;
+       unsigned char prflag = PRFLAG_UNSET;
 
        /*
         * need path UID to go any further
@@ -1330,7 +1330,7 @@ rescan:
        if (retries >= 0) {
                if (start_waiter)
                        update_map_pr(mpp);
-               if (mpp->prflag && !prflag)
+               if (mpp->prflag == PRFLAG_SET && prflag == PRFLAG_UNSET)
                                pr_register_active_paths(mpp);
                condlog(2, "%s [%s]: path added to devmap %s",
                        pp->dev, pp->dev_t, mpp->alias);
@@ -2492,7 +2492,7 @@ check_path (struct vectors * vecs, struct path * pp, 
unsigned int ticks)
                }
 
                if (newstate == PATH_UP || newstate == PATH_GHOST) {
-                       if (pp->mpp->prflag) {
+                       if (pp->mpp->prflag == PRFLAG_SET) {
                                /*
                                 * Check Persistent Reservation.
                                 */
@@ -2865,7 +2865,7 @@ configure (struct vectors * vecs, enum force_reload_types 
reload_type)
                if (remember_wwid(mpp->wwid) == 1)
                        trigger_paths_udev_change(mpp, true);
                update_map_pr(mpp);
-               if (mpp->prflag)
+               if (mpp->prflag == PRFLAG_SET)
                        pr_register_active_paths(mpp);
        }
 
@@ -3840,7 +3840,7 @@ void *  mpath_pr_event_handler_fn (void * pathp )
        {
                condlog(0,"%s: Reservation registration failed. Error: %d", 
pp->dev, ret);
        }
-       mpp->prflag = 1;
+       mpp->prflag = PRFLAG_SET;
 
        free(param);
 out:
-- 
2.17.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel

Reply via email to