From 0ee03999a24c3e5e2652155237809671414630b9 Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 3 Oct 2012 18:10:54 +0400 Subject: [PATCH] LU-1943 osd: ldiskfs osd to set param.ddp_inodespace so that grants code do proper reservation for metadata overhead. Signed-off-by: Alex Zhuravlev Change-Id: Ia63e60215d98ab4d950a86137a594a87d0569299 Reviewed-on: http://review.whamcloud.com/4167 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Johann Lombardi --- lustre/osd-ldiskfs/osd_handler.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 51365cd..32ff79b 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -919,6 +919,17 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d, return result; } +/** + * Estimate space needed for file creations. We assume the largest filename + * which is 2^64 - 1, hence a filename of 20 chars. + * This is 28 bytes per object which is 28MB for 1M objects ... no so bad. + */ +#ifdef __LDISKFS_DIR_REC_LEN +#define PER_OBJ_USAGE __LDISKFS_DIR_REC_LEN(20) +#else +#define PER_OBJ_USAGE LDISKFS_DIR_REC_LEN(20) +#endif + /* * Concurrency: doesn't access mutable data. */ @@ -936,6 +947,15 @@ static void osd_conf_get(const struct lu_env *env, param->ddp_max_nlink = LDISKFS_LINK_MAX; param->ddp_block_shift = sb->s_blocksize_bits; param->ddp_mount_type = LDD_MT_LDISKFS; + param->ddp_maxbytes = sb->s_maxbytes; + /* Overhead estimate should be fairly accurate, so we really take a tiny + * error margin which also avoids fragmenting the filesystem too much */ + param->ddp_grant_reserved = 2; /* end up to be 1.9% after conversion */ + /* inode are statically allocated, so per-inode space consumption + * is the space consumed by the directory entry */ + param->ddp_inodespace = PER_OBJ_USAGE; + /* per-fragment overhead to be used by the client code */ + param->ddp_grant_frag = 6 * LDISKFS_BLOCK_SIZE(sb); param->ddp_mntopts = 0; if (test_opt(sb, XATTR_USER)) param->ddp_mntopts |= MNTOPT_USERXATTR; -- 1.8.3.1