Whamcloud - gitweb
LU-4775 lfsck: dump all visibile lfsck parameter correctly 90/9690/2
authorFan Yong <fan.yong@intel.com>
Tue, 4 Mar 2014 06:19:41 +0000 (14:19 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 25 Mar 2014 15:29:51 +0000 (15:29 +0000)
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 <fan.yong@intel.com>
Change-Id: I462c79e80be5b384a291b30980a95698a8dd9d19
Reviewed-on: http://review.whamcloud.com/9690
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
lustre/lfsck/lfsck_lib.c

index c8e26f0..3b1fe0c 100644 (file)
@@ -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;
 }