Whamcloud - gitweb
LU-13983 llite: rmdir releases inode on client 11/40011/4
authorLai Siyao <lai.siyao@whamcloud.com>
Tue, 22 Sep 2020 11:05:51 +0000 (19:05 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 19 Oct 2020 03:13:40 +0000 (03:13 +0000)
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 <lai.siyao@whamcloud.com>
Change-Id: I9181151de1830b48986afec30c83120e9f112a85
Reviewed-on: https://review.whamcloud.com/40011
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/namei.c
lustre/tests/sanity.sh

index b84dfd7..4d0babd 100644 (file)
@@ -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);
        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));
                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);
 }
 
        RETURN(rc);
 }
 
index a6d2294..4117554 100755 (executable)
@@ -8642,7 +8642,7 @@ num_objects() {
                awk '/lustre_inode_cache/ { print $2; exit }' /proc/slabinfo
 }
 
                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
        [ $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
 }
                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()
 
 export ORIG_CSUM=""
 set_checksums()