Whamcloud - gitweb
b=22327 "lfs df" does not print stats for all mountpoints
authorDmitry Zogin <dmitry.zogin@sun.com>
Fri, 19 Mar 2010 02:14:23 +0000 (22:14 -0400)
committerRobert Read <rread@sun.com>
Thu, 1 Apr 2010 22:43:47 +0000 (15:43 -0700)
 1. print all mounted lustre filesystems with "lfs df"
 2. sanityn test_24b added

lustre/doc/lfs.1
lustre/tests/sanityn.sh
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index d0e96ac..224797f 100644 (file)
@@ -90,9 +90,13 @@ Changelog consumers must be registered on the MDT node using \fBlctl\fR.
 .B check 
 Display the status of MDS or OSTs (as specified in the command) or all the servers (MDS and OSTs)
 .TP
-.B df
-Report filesystem disk space usage or inodes usage of each MDT/OST. Can limit
-the scope to a specific OST pool
+.B df [-i] [-h] [--pool|-p <fsname>[.<pool>] [path]
+Report filesystem disk space usage or inodes usage (with \fB-i\fR) of each
+MDT/OST, or a subset of OSTs if a pool is specified with \fB-p\fR.  By default
+print the usage of all mounted Lustre filesystems, otherwise if \fBpath\fR is
+specified print only the usage of that filesystem.  If \fB-h\fR is given, the
+output is printed in \fIh\fRuman readable format, using SI base-2 suffixes
+for \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes.
 .TP
 .B find 
 To search the directory tree rooted at the given dir/file name for the files that match the given parameters: \fB--atime\fR (file was last accessed N*24 hours ago), \fB--ctime\fR (file's status was last changed N*24 hours ago), \fB--mtime\fR (file's data was last modified N*24 hours ago), \fB--obd\fR (file has an object on a specific OST or OSTs), \fB--size\fR (file has size in bytes, or \fBk\fRilo-, \fBM\fRega-, \fBG\fRiga-, \fBT\fRera-, \fBP\fReta-, or \fBE\fRxabytes if a suffix is given), \fB--type\fR (file has the type: \fBb\fRlock, \fBc\fRharacter, \fBd\fRirectory, \fBp\fRipe, \fBf\fRile, sym\fBl\fRink, \fBs\fRocket, or \fBD\fRoor (Solaris)), \fB--uid\fR (file has specific numeric user ID), \fB--user\fR (file owned by specific user, numeric user ID allowed), \fB--gid\fR (file has specific group ID), \fB--group\fR (file belongs to specific group, numeric group ID allowed). The option \fB--maxdepth\fR limits find to decend at most N levels of directory tree. The options \fB--print\fR and \fB--print0\fR print full file name, followed by a newline or NUL character correspondingly.  Using \fB!\fR before an option negates its meaning (\fIfiles NOT matching the parameter\fR).  Using \fB+\fR before a numeric value means \fIfiles with the parameter OR MORE\fR, while \fB-\fR before a numeric value means \fIfiles with the parameter OR LESS\fR.
index 35d9d3c..e2747dc 100644 (file)
@@ -439,7 +439,7 @@ test_23() { # Bug 5972
 }
 run_test 23 " others should see updated atime while another read===="
 
-test_24() {
+test_24a() {
        touch $DIR1/$tfile
        lfs df || error "lfs df failed"
        lfs df -ih || error "lfs df -ih failed"
@@ -455,7 +455,14 @@ test_24() {
        lctl --device %$OSC recover
        lfs df || error "lfs df with reactivated OSC failed"
 }
-run_test 24 "lfs df [-ih] [path] test ========================="
+run_test 24a "lfs df [-ih] [path] test ========================="
+
+test_24b() {
+       touch $DIR1/$tfile
+       fsnum=`lfs df | grep -c "filesystem summary:"`
+       [ $fsnum -eq 2 ] || error "lfs df shows $fsnum != 2 filesystems."
+}
+run_test 24b "lfs df should show both filesystems ==============="
 
 test_25() {
        [ `lctl get_param -n mdc.*-mdc-*.connect_flags | grep -c acl` -lt 2 ] && \
index 6725737..14ea0a2 100644 (file)
@@ -1132,7 +1132,7 @@ static int lfs_df(int argc, char **argv)
         char *mntdir = NULL;
         int ishow = 0, cooked = 0;
         int c, rc = 0;
-        char fsname[PATH_MAX], *pool_name = NULL;
+        char fsname[PATH_MAX] = "", *pool_name = NULL;
         struct option long_opts[] = {
                 {"pool", required_argument, 0, 'p'},
                 {0, 0, 0, 0}
@@ -1188,6 +1188,8 @@ static int lfs_df(int argc, char **argv)
                         if (rc)
                                 break;
                         printf("\n");
+                        fsname[0] = '\0'; /* avoid matching in next loop */
+                        mntdir[0] = '\0'; /* avoid matching in next loop */
                 }
         }
 
index 7750e7e..516111e 100644 (file)
@@ -520,6 +520,9 @@ static int get_root_path(int want, char *fsname, int *outfd, char *path,
                 if (!llapi_is_lustre_mnt(&mnt))
                         continue;
 
+                if ((want & WANT_INDEX) && (idx++ != index))
+                        continue;
+
                 mntlen = strlen(mnt.mnt_dir);
                 ptr = strrchr(mnt.mnt_fsname, '/');
                 if (!ptr && !len) {
@@ -528,9 +531,6 @@ static int get_root_path(int want, char *fsname, int *outfd, char *path,
                 }
                 ptr++;
 
-                if ((want & WANT_INDEX) && (idx++ != index))
-                        continue;
-
                 /* Check the fsname for a match, if given */
                 if (!(want & WANT_FSNAME) && fsname != NULL &&
                     (strlen(fsname) > 0) && (strcmp(ptr, fsname) != 0))