From 5ab7b4309f8ac9efe5c4455691d1f28b9d42f17d Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Tue, 4 Mar 2014 14:19:41 +0800 Subject: [PATCH] LU-4775 lfsck: dump all visibile lfsck parameter correctly We missed to handle "LPF_BROADCAST" and "LPF_ORPHAN" when dump the lfsck parameters and caused the output via /proc interface incomplete and bad formatted. Signed-off-by: Fan Yong Change-Id: I462c79e80be5b384a291b30980a95698a8dd9d19 Reviewed-on: http://review.whamcloud.com/9690 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Reviewed-by: Alex Zhuravlev --- lustre/lfsck/lfsck_lib.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index c8e26f0..3b1fe0c 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -92,6 +92,8 @@ const char *lfsck_param_names[] = { "failout", "dryrun", "all_targets", + "broadcast", + "orphan", NULL }; @@ -904,8 +906,9 @@ int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[], int flag; int rc; int i; + bool newline = (bits != 0 ? false : true); - rc = snprintf(*buf, *len, "%s:%c", prefix, bits != 0 ? ' ' : '\n'); + rc = snprintf(*buf, *len, "%s:%c", prefix, newline ? '\n' : ' '); if (rc <= 0) return -ENOSPC; @@ -915,8 +918,11 @@ int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[], if (flag & bits) { bits &= ~flag; if (names[i] != NULL) { + if (bits == 0) + newline = true; + rc = snprintf(*buf, *len, "%s%c", names[i], - bits != 0 ? ',' : '\n'); + newline ? '\n' : ','); if (rc <= 0) return -ENOSPC; @@ -925,6 +931,16 @@ int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[], } } } + + if (!newline) { + rc = snprintf(*buf, *len, "\n"); + if (rc <= 0) + return -ENOSPC; + + *buf += rc; + *len -= rc; + } + return save - *len; } -- 1.8.3.1