From: Li Dongyang Date: Tue, 30 Apr 2019 05:29:19 +0000 (+1000) Subject: LU-12248 lov: fix ost objects calculation in lod_statfs X-Git-Tag: 2.12.54~82 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7a6ac6f91273d7b14243509266d38cbbe1eeb550 LU-12248 lov: fix ost objects calculation in lod_statfs 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 Change-Id: I838a1527ed6411a412b63e2855ca7247755a3bcf Reviewed-on: https://review.whamcloud.com/34777 Reviewed-by: Andreas Dilger Reviewed-by: Wang Shilong Tested-by: Jenkins Tested-by: Maloo --- diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 8285524..98c1369 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -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", diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 30617b6..e7a043e 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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; }