From 4a4794364eb05f7f6cb4600af986951353d034f4 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Tue, 22 Sep 2020 19:05:51 +0800 Subject: [PATCH] LU-13983 llite: rmdir releases inode on client Same as file unlink, rmdir should release inode on client, to achieve this, ll_rmdir() update inode i_nlink after rmdir, then the last iput() will release the inode. Signed-off-by: Lai Siyao Change-Id: I9181151de1830b48986afec30c83120e9f112a85 Reviewed-on: https://review.whamcloud.com/40011 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yingjin Qian Reviewed-by: Oleg Drokin --- lustre/llite/namei.c | 20 ++++++++++++++++---- lustre/tests/sanity.sh | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index b84dfd7..4d0babd 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -1692,13 +1692,25 @@ static int ll_rmdir(struct inode *dir, struct dentry *dchild) op_data->op_fid2 = op_data->op_fid3; rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); - if (!rc) - ll_update_times(request, dir); + if (!rc) { + struct mdt_body *body; - ptlrpc_req_finished(request); - if (!rc) + ll_update_times(request, dir); ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_RMDIR, ktime_us_delta(ktime_get(), kstart)); + + /* + * The server puts attributes in on the last unlink, use them + * to update the link count so the inode can be freed + * immediately. + */ + body = req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY); + if (body->mbo_valid & OBD_MD_FLNLINK) + set_nlink(dchild->d_inode, body->mbo_nlink); + } + + ptlrpc_req_finished(request); + RETURN(rc); } diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index a6d2294..4117554 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -8642,7 +8642,7 @@ num_objects() { awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo } -test_76() { # Now for b=20433, added originally in b=1443 +test_76a() { # Now for b=20433, added originally in b=1443 [ $PARALLEL == "yes" ] && skip "skip parallel run" cancel_lru_locks osc @@ -8677,8 +8677,36 @@ test_76() { # Now for b=20433, added originally in b=1443 fi done } -run_test 76 "confirm clients recycle inodes properly ====" +run_test 76a "confirm clients recycle inodes properly ====" +test_76b() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" + [ $CLIENT_VERSION -ge $(version_code 2.13.55) ] || skip "not supported" + + local count=512 + local before=$(num_objects) + + for i in $(seq $count); do + mkdir $DIR/$tdir + rmdir $DIR/$tdir + done + + local after=$(num_objects) + local wait=0 + + while (( after > before )); do + sleep 1 + after=$(num_objects) + wait=$((wait + 1)) + (( wait % 5 == 0 )) && echo "wait $wait seconds objects: $after" + if (( wait > 60 )); then + error "inode slab grew from $before to $after" + fi + done + + echo "slab objects before: $before, after: $after" +} +run_test 76b "confirm clients recycle directory inodes properly ====" export ORIG_CSUM="" set_checksums() -- 1.8.3.1