From 485953b0eb71d82fe806799d6b061b62fe0e4602 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. Lustre-change: https://review.whamcloud.com/49329 Lustre-commit: ae98c5fdaaf37daeb328b7110cbcf42754752c9d Signed-off-by: Lai Siyao Change-Id: I824c7581af05c7494cf03c0c9bc999ca1abfec01 Reviewed-by: Andreas Dilger Reviewed-by: Qian Yingjin Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49712 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 ee4dd23..28d1a38 100644 --- a/lustre/mdt/mdt_reint.c +++ b/lustre/mdt/mdt_reint.c @@ -1145,6 +1145,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 (!md_capable(uc, CFS_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 { @@ -1211,23 +1228,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 (!md_capable(uc, CFS_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 8ab135f..eb11bc2 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -28050,6 +28050,24 @@ test_822() { } run_test 822 "test precreate failure" +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 825502f..d529f91 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -10804,6 +10804,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