From 5e2b17964fd880a9763ba66151aab6091fb4813c Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 3 Mar 2017 02:40:46 -0700 Subject: [PATCH] LU-9176 osd-zfs: improve statfs estimate for ZFS When a ZFS filesystem is newly formatted, there are 128 OI ZAPs and 96 object directories, but only a handful of regular files. This skews the average MDT file size to be much larger than regular files, which in turn makes the estimated total number of files on the MDT much too small. Improve the inode size estimate when the filesystem has few files to be closer to the expected long term average so that the reported total inode count is reasonable for a new or otherwise empty filesystem. Signed-off-by: Andreas Dilger Change-Id: Ic40af2057d8b21e0ee4d9bb3b13b7f6786d0d406 Reviewed-on: https://review.whamcloud.com/25743 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Ned Bass Reviewed-by: Oleg Drokin --- lustre/osd-zfs/osd_handler.c | 6 +++--- lustre/osd-zfs/osd_internal.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index 5233718..5307f92 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -394,9 +394,9 @@ uint64_t osd_objs_count_estimate(uint64_t usedbytes, uint64_t usedobjs, CLASSERT(OSD_DNODE_MIN_BLKSHIFT > 0); CLASSERT(OSD_DNODE_EST_BLKSHIFT > 0); - est_usedblocks = (usedbytes >> est_maxblockshift) + - (OSD_DNODE_EST_COUNT >> OSD_DNODE_EST_BLKSHIFT); - est_usedobjs = usedobjs + OSD_DNODE_EST_COUNT; + est_usedblocks = ((OSD_DNODE_EST_COUNT << OSD_DNODE_EST_BLKSHIFT) + + usedbytes) >> est_maxblockshift; + est_usedobjs = OSD_DNODE_EST_COUNT + usedobjs; if (est_usedobjs <= est_usedblocks) { /* diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index b3b9ea4..54c9a6b 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -85,8 +85,8 @@ /* Statfs {minimum, safe estimate, and maximum} dnodes per block */ #define OSD_DNODE_MIN_BLKSHIFT (DNODES_PER_BLOCK_SHIFT) -#define OSD_DNODE_EST_BLKSHIFT (DNODE_BLOCK_SHIFT - 12) /* est 4KB/dnode */ -#define OSD_DNODE_EST_COUNT 1024 +#define OSD_DNODE_EST_BLKSHIFT (12) /* est 4KB/dnode */ +#define OSD_DNODE_EST_COUNT 4096 #define OSD_GRANT_FOR_LOCAL_OIDS (2ULL << 20) /* 2MB for last_rcvd, ... */ -- 1.8.3.1