Whamcloud - gitweb
LU-12248 lov: fix ost objects calculation in lod_statfs 77/34777/4
authorLi Dongyang <dongyangli@ddn.com>
Tue, 30 Apr 2019 05:29:19 +0000 (15:29 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 10 May 2019 07:12:43 +0000 (07:12 +0000)
Wen OSTs report fewer free objects than MDTs, the statfs
objects results are presented with the numbers reported
by OSTs. Fix the calculation of OST objetcs to make it
work with statfs aggregation via the MDT.

Make the lfs code consistent with ll_statfs_internal()
and lod_statfs().

Fixes: a829595add ("LU-11721 lod: limit statfs ffree if less ...")

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Change-Id: I838a1527ed6411a412b63e2855ca7247755a3bcf
Reviewed-on: https://review.whamcloud.com/34777
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
lustre/lod/lod_dev.c
lustre/utils/lfs.c

index 8285524..98c1369 100644 (file)
@@ -1379,8 +1379,8 @@ static int lod_statfs(const struct lu_env *env,
                        sfs->os_bfree = 0;
                        sfs->os_granted = 0;
                }
-               ost_files += sfs->os_files;
-               ost_ffree += sfs->os_ffree;
+               ost_files += ost_sfs.os_files;
+               ost_ffree += ost_sfs.os_ffree;
                ost_sfs.os_bavail += ost_sfs.os_granted;
                lod_statfs_sum(sfs, &ost_sfs, &bs);
                LASSERTF(bs == ost_sfs.os_bsize, "%d != %d\n",
index 30617b6..e7a043e 100644 (file)
@@ -4963,6 +4963,7 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags,
                { .st_op = LL_STATFS_LOV,       .st_name = "OST" },
                { .st_name = NULL } };
        struct ll_stat_type *tp;
+       __u64 ost_files = 0;
        __u64 ost_ffree = 0;
        __u32 index;
        __u32 type;
@@ -5070,6 +5071,7 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags,
                                sum.os_ffree += stat_buf.os_ffree;
                                sum.os_files += stat_buf.os_files;
                        } else /* if (tp->st_op == LL_STATFS_LOV) */ {
+                               ost_files += stat_buf.os_files;
                                ost_ffree += stat_buf.os_ffree;
                        }
                        sum.os_blocks += stat_buf.os_blocks *
@@ -5083,11 +5085,12 @@ static int mntdf(char *mntdir, char *fsname, char *pool, enum mntdf_flags flags,
 
        close(fd);
 
-       /* If we don't have as many objects free on the OST as inodes
-        * on the MDS, we reduce the total number of inodes to
-        * compensate, so that the "inodes in use" number is correct.
-        * Matches ll_statfs_internal() so the results are consistent. */
-       if (ost_ffree < sum.os_ffree) {
+       /* If we have _some_ OSTs, but don't have as many free objects on the
+        * OST as inodes on the MDTs, reduce the reported number of inodes
+        * to compensate, so that the "inodes in use" number is correct.
+        * This should be kept in sync with ll_statfs_internal().
+        */
+       if (ost_files && ost_ffree < sum.os_ffree) {
                sum.os_files = (sum.os_files - sum.os_ffree) + ost_ffree;
                sum.os_ffree = ost_ffree;
        }