From aa6773d95b0212e5bfe2a187e679322c1ac9eb8e Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 17 Jun 2014 09:53:41 -0400 Subject: [PATCH] LU-3386 lproc: fix "imports" output format 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 Signed-off-by: James Simmons Change-Id: Iee725b503ec771773d456b3436480c6e52500c1e Reviewed-on: http://review.whamcloud.com/10344 Reviewed-by: Bob Glossman Tested-by: Jenkins Reviewed-by: John L. Hammond Reviewed-by: Nathaniel Clark Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/obdclass/lprocfs_status.c | 34 +++++++++++++++++++++------------- lustre/tests/conf-sanity.sh | 20 ++++++++++++++------ lustre/tests/recovery-small.sh | 10 ++++++---- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index e894f33..d81ebc3 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -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)); } diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index 6446ac6..5165889 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -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" diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index afaef41..62d2051 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -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; -- 1.8.3.1