From e1bd38e27a810bad7a25813ebc1ca0535c9d7228 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Wed, 11 Nov 2020 14:51:09 +0800 Subject: [PATCH] LU-14131 osd-ldiskfs: reduce credits for overwritting If all blocks are mapped which means this is overwritting case or space has been allocated by fallocate. There is no need to modify exten tree, and we only need 1 credits for inode. Signed-off-by: Wang Shilong Change-Id: I907861d4862256a8a23a81812953e2330e1d9925 Reviewed-on: https://review.whamcloud.com/40604 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_io.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index d65421c..2814cfe 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1154,6 +1154,13 @@ static int osd_declare_write_commit(const struct lu_env *env, quota_space += PAGE_SIZE; } + credits++; /* inode */ + /* + * overwrite case, no need to modify tree and + * allocate blocks. + */ + if (!newblocks) + goto out_declare; /* * each extent can go into new leaf causing a split * 5 is max tree depth: inode + 4 index blocks @@ -1167,12 +1174,10 @@ static int osd_declare_write_commit(const struct lu_env *env, depth = ext_depth(inode); depth = max(depth, 1) + 1; newblocks += depth; - credits++; /* inode */ credits += depth * 2 * extents; } else { depth = 3; newblocks += depth; - credits++; /* inode */ credits += depth * extents; } @@ -1196,6 +1201,7 @@ static int osd_declare_write_commit(const struct lu_env *env, else credits += newblocks; +out_declare: osd_trans_declare_op(env, oh, OSD_OT_WRITE, credits); /* make sure the over quota flags were not set */ -- 1.8.3.1