Whamcloud - gitweb
LU-16335 mdt: skip target check for rm_entry 29/49329/6
authorLai Siyao <lai.siyao@whamcloud.com>
Wed, 7 Dec 2022 02:53:25 +0000 (21:53 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 19 Jan 2023 15:31:44 +0000 (15:31 +0000)
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 <lai.siyao@whamcloud.com>
Change-Id: I824c7581af05c7494cf03c0c9bc999ca1abfec01
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49329
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: jsimmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_reint.c
lustre/tests/sanity.sh
lustre/tests/test-framework.sh

index 64aa3bb..41ad354 100644 (file)
@@ -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;
 
index 7a62f51..fb04f81 100755 (executable)
@@ -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
 #
index 478b6c5..75ce9f4 100755 (executable)
@@ -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