From ae98c5fdaaf37daeb328b7110cbcf42754752c9d Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Tue, 6 Dec 2022 21:53:25 -0500 Subject: [PATCH] LU-16335 mdt: skip target check for rm_entry For "lfs rm_entry", target may not exist, sanity check of it may fail thus causes rm_entry fail. Add sanity 832. Signed-off-by: Lai Siyao Change-Id: I824c7581af05c7494cf03c0c9bc999ca1abfec01 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49329 Reviewed-by: Andreas Dilger Reviewed-by: Qian Yingjin Reviewed-by: jsimmons Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/mdt/mdt_reint.c | 34 +++++++++++++++++----------------- lustre/tests/sanity.sh | 18 ++++++++++++++++++ lustre/tests/test-framework.sh | 7 +++++++ 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/lustre/mdt/mdt_reint.c b/lustre/mdt/mdt_reint.c index 64aa3bb..41ad354 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -1141,6 +1141,23 @@ relock: if (rc != 0) GOTO(put_parent, rc); + if (info->mti_spec.sp_rm_entry) { + struct lu_ucred *uc = mdt_ucred(info); + + if (!mdt_is_dne_client(req->rq_export)) + /* Return -ENOTSUPP for old client */ + GOTO(unlock_parent, rc = -ENOTSUPP); + + if (!cap_raised(uc->uc_cap, CAP_SYS_ADMIN)) + GOTO(unlock_parent, rc = -EPERM); + + ma->ma_need = MA_INODE; + ma->ma_valid = 0; + rc = mdo_unlink(info->mti_env, mdt_object_child(mp), + NULL, &rr->rr_name, ma, no_name); + GOTO(unlock_parent, rc); + } + if (info->mti_spec.sp_cr_flags & MDS_OP_WITH_FID) { *child_fid = *rr->rr_fid2; } else { @@ -1207,23 +1224,6 @@ relock: child_lh = &info->mti_lh[MDT_LH_CHILD]; mdt_lock_reg_init(child_lh, LCK_EX); - if (info->mti_spec.sp_rm_entry) { - struct lu_ucred *uc = mdt_ucred(info); - - if (!mdt_is_dne_client(req->rq_export)) - /* Return -ENOTSUPP for old client */ - GOTO(put_child, rc = -ENOTSUPP); - - if (!cap_raised(uc->uc_cap, CAP_SYS_ADMIN)) - GOTO(put_child, rc = -EPERM); - - ma->ma_need = MA_INODE; - ma->ma_valid = 0; - rc = mdo_unlink(info->mti_env, mdt_object_child(mp), - NULL, &rr->rr_name, ma, no_name); - GOTO(put_child, rc); - } - if (mdt_object_remote(mc)) { struct mdt_body *repbody; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 7a62f51..fb04f81 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -28878,6 +28878,24 @@ test_831() { } run_test 831 "throttling unlink/setattr queuing on OSP" +test_832() { + (( $MDSCOUNT >= 2 )) || skip "needs >= 2 MDTs" + (( $MDS1_VERSION >= $(version_code 2.15.52) )) || + skip "Need MDS version 2.15.52+" + is_rmentry_supported || skip "rm_entry not supported" + + mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed" + mkdir $DIR/$tdir/local_dir || error "mkdir local_dir failed" + mkdir_on_mdt -i 1 $DIR/$tdir/remote_dir || + error "mkdir remote_dir failed" + $LFS mkdir -c $MDSCOUNT $DIR/$tdir/striped_dir || + error "mkdir striped_dir failed" + touch $DIR/$tdir/file || error "touch file failed" + $LFS rm_entry $DIR/$tdir/* || error "lfs rm_entry $tdir/* failed" + [ -z "$(ls -A $DIR/$tdir)" ] || error "$tdir not empty" +} +run_test 832 "lfs rm_entry" + # # tests that do cleanup/setup should be run at the end # diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 478b6c5..75ce9f4 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -10817,6 +10817,13 @@ statx_supported() { return $? } +# lfs rm_entry is disabled on native client +is_rmentry_supported() { + $LFS rm_entry $DIR/dir/not/exists > /dev/null + # is return code ENOENT? + (( $? == 2 )) +} + # # wrappers for createmany and unlinkmany # to set debug=0 if number of creates is high enough -- 1.8.3.1