Whamcloud - gitweb
LU-12248 lov: fix ost objects calculation in lod_statfs 16/34816/3
authorLi Dongyang <dongyangli@ddn.com>
Tue, 30 Apr 2019 05:29:19 +0000 (15:29 +1000)
committerOleg Drokin <green@whamcloud.com>
Sat, 8 Jun 2019 02:32:51 +0000 (02:32 +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().

Lustre-change: https://review.whamcloud.com/34777
Lustre-commit: 7a6ac6f91273d7b14243509266d38cbbe1eeb550

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/34816
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lod/lod_dev.c
lustre/utils/lfs.c

index 96e0e2a..0e5b632 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 be687d1..9d897af 100644 (file)
@@ -4766,6 +4766,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;
@@ -4873,6 +4874,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 *
@@ -4886,11 +4888,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;
        }