Whamcloud - gitweb
LU-3386 lproc: fix "imports" output format 44/10344/7
authorAndreas Dilger <andreas.dilger@intel.com>
Tue, 17 Jun 2014 13:53:41 +0000 (09:53 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 23 Jun 2014 00:02:36 +0000 (00:02 +0000)
There was no comma being printed in the import flags listing since
commit 62660c799b because the "first" marker wasn't being set false.

Fix the output format to put a space around the '[' and ']' list
delimiters.

Make the "unknown" connect flag be a single word.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: Iee725b503ec771773d456b3436480c6e52500c1e
Reviewed-on: http://review.whamcloud.com/10344
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/lprocfs_status.c
lustre/tests/conf-sanity.sh
lustre/tests/recovery-small.sh

index e894f33..d81ebc3 100644 (file)
@@ -814,10 +814,12 @@ EXPORT_SYMBOL(lprocfs_stats_collect);
  */
 #define flag2seqstr(flag)                                              \
        do {                                                            \
-               if (imp->imp_##flag)                                    \
+               if (imp->imp_##flag) {                                  \
                        seq_printf(m, "%s" #flag, first ? "" : ", ");   \
+                       first = false;                                  \
+               }                                                       \
        } while (0)
-static int obd_import_flags2seqstr(struct obd_import *imp, struct seq_file *m)
+static void obd_import_flags2seqstr(struct obd_import *imp, struct seq_file *m)
 {
        bool first = true;
 
@@ -829,10 +831,16 @@ static int obd_import_flags2seqstr(struct obd_import *imp, struct seq_file *m)
        flag2seqstr(invalid);
        flag2seqstr(deactive);
        flag2seqstr(replayable);
+       flag2seqstr(delayed_recovery);
+       flag2seqstr(no_lock_replay);
+       flag2seqstr(vbr_failed);
        flag2seqstr(pingable);
-       return 0;
+       flag2seqstr(resend_replay);
+       flag2seqstr(no_pinger_recover);
+       flag2seqstr(need_mne_swab);
+       flag2seqstr(connect_tried);
 }
-#undef flags2seqstr
+#undef flag2seqstr
 
 static const char *obd_connect_names[] = {
        "read_only",
@@ -910,7 +918,7 @@ static void obd_connect_seq_flags2str(struct seq_file *m, __u64 flags, char *sep
                }
        }
        if (flags & ~(mask - 1))
-               seq_printf(m, "%sunknown flags "LPX64,
+               seq_printf(m, "%sunknown_"LPX64,
                           first ? "" : sep, flags & ~(mask - 1));
 }
 
@@ -926,7 +934,7 @@ int obd_connect_flags2str(char *page, int count, __u64 flags, char *sep)
        }
        if (flags & ~(mask - 1))
                ret += snprintf(page + ret, count - ret,
-                               "%sunknown flags "LPX64,
+                               "%sunknown_"LPX64,
                                ret ? sep : "", flags & ~(mask - 1));
        return ret;
 }
@@ -1003,20 +1011,20 @@ int lprocfs_import_seq_show(struct seq_file *m, void *data)
                      "    name: %s\n"
                      "    target: %s\n"
                      "    state: %s\n"
-                     "    connect_flags: [",
+                     "    connect_flags: [ ",
                      obd->obd_name,
                      obd2cli_tgt(obd),
                      ptlrpc_import_state_name(imp->imp_state));
        obd_connect_seq_flags2str(m, imp->imp_connect_data.ocd_connect_flags,
                                        ", ");
-       seq_printf(m, "]\n");
+       seq_printf(m, " ]\n");
        obd_connect_data_seqprint(m, ocd);
-       seq_printf(m, "    import_flags: [");
+       seq_printf(m, "    import_flags: [ ");
        obd_import_flags2seqstr(imp, m);
 
-       seq_printf(m, "]\n"
+       seq_printf(m, " ]\n"
                      "    connection:\n"
-                     "       failover_nids: [");
+                     "       failover_nids: [ ");
        spin_lock(&imp->imp_lock);
        j = 0;
        list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
@@ -1024,7 +1032,7 @@ int lprocfs_import_seq_show(struct seq_file *m, void *data)
                           libcfs_nid2str(conn->oic_conn->c_peer.nid));
                j++;
        }
-       seq_printf(m, "]\n"
+       seq_printf(m, " ]\n"
                      "       current_connection: %s\n"
                      "       connection_attempts: %u\n"
                      "       generation: %u\n"
@@ -1137,7 +1145,7 @@ int lprocfs_state_seq_show(struct seq_file *m, void *data)
                        &imp->imp_state_hist[(k + j) % IMP_STATE_HIST_LEN];
                if (ish->ish_state == 0)
                        continue;
-               seq_printf(m, " - ["CFS_TIME_T", %s]\n",
+               seq_printf(m, " - [ "CFS_TIME_T", %s ]\n",
                           ish->ish_time,
                ptlrpc_import_state_name(ish->ish_state));
        }
index 6446ac6..5165889 100644 (file)
@@ -1233,22 +1233,30 @@ test_30b() {
        NEW=$(echo $OSTNID | sed "s/$ORIGVAL/$NEWVAL@/")
        echo "Using fake nid $NEW"
 
-       TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
+       TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
+               grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
        set_conf_param_and_check client "$TEST" \
                "$FSNAME-OST0000.failover.node" $NEW ||
                error "didn't add failover nid $NEW"
-       NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
+       NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
+               grep failover_nids)
        echo $NIDS
-       NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
+       # The NIDS value is the failover nid strings and "[" and "]". So
+       # we need to subtract the space taken by the delimiters. This has
+       # changed from earlier version of Lustre but this test is run only
+       # locally so this change will not break interop. See LU-3386
+       NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
        echo "should have 2 failover nids: $NIDCOUNT"
        [ $NIDCOUNT -eq 2 ] || error "Failover nid not added"
-       do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" || error "conf_param delete failed"
+       do_facet mgs "$LCTL conf_param -d $FSNAME-OST0000.failover.node" ||
+               error "conf_param delete failed"
        umount_client $MOUNT
        mount_client $MOUNT || return 3
 
-       NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
+       NIDS=$($LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
+               grep failover_nids)
        echo $NIDS
-       NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 1))
+       NIDCOUNT=$(($(echo "$NIDS" | wc -w) - 3))
        echo "only 1 final nid should remain: $NIDCOUNT"
        [ $NIDCOUNT -eq 1 ] || error "Failover nids not removed"
 
index afaef41..62d2051 100755 (executable)
@@ -428,8 +428,9 @@ test_19a() {
 
        # let the client reconnect
        client_reconnect
-       EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state | \
-           awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
+       EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
+               awk -F"[ [,]" '/EVICTED ]$/ \
+                       { if (mx<$5) {mx=$5;} } END { print mx }')
 
        [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
                (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
@@ -457,8 +458,9 @@ test_19b() {
 
        # let the client reconnect
        client_reconnect
-       EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state | \
-           awk -F"[ [,]" '/EVICTED]$/ { if (mx<$4) {mx=$4;} } END { print mx }')
+       EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
+               awk -F"[ [,]" '/EVICTED ]$/ \
+                       { if (mx < $5) {mx = $5;} } END { print mx }')
 
        [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
                (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;