Whamcloud - gitweb
LU-15253 mdt: object version race 20/45620/8
authorAndriy Skulysh <c17819@cray.com>
Mon, 31 Aug 2020 08:14:34 +0000 (11:14 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Sep 2024 05:53:54 +0000 (05:53 +0000)
MDT object version should be obtained under LDLM lock.

Change-Id: Ib828a4065d56e80cbe488a3fdfc6c5da808b20d0
HPE-bug-id: LUS-9280
Signed-off-by: Andriy Skulysh <andriy.skulysh@hpe.com>
Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Vitaly Fertman <vitaly.fertman@hpe.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/45620
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/mdt/mdt_reint.c

index e7a562b..cc22c77 100644 (file)
@@ -1223,12 +1223,6 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
        if (IS_ERR(mp))
                RETURN(PTR_ERR(mp));
 
-       if (!mdt_object_remote(mp)) {
-               rc = mdt_version_get_check_save(info, mp, 0);
-               if (rc)
-                       GOTO(put_parent, rc);
-       }
-
        if (!uc->uc_rbac_fscrypt_admin &&
            mp->mot_obj.lo_header->loh_attr & LOHA_FSCRYPT_MD)
                GOTO(put_parent, rc = -EPERM);
@@ -1240,6 +1234,12 @@ static int mdt_reint_unlink(struct mdt_thread_info *info,
        if (rc != 0)
                GOTO(put_parent, rc);
 
+       if (!mdt_object_remote(mp)) {
+               rc = mdt_version_get_check_save(info, mp, 0);
+               if (rc)
+                       GOTO(unlock_parent, rc);
+       }
+
        if (info->mti_spec.sp_rm_entry) {
                if (!mdt_is_dne_client(req->rq_export))
                        /* Return -ENOTSUPP for old client */
@@ -1468,14 +1468,6 @@ static int mdt_reint_link(struct mdt_thread_info *info,
        if (IS_ERR(mp))
                RETURN(PTR_ERR(mp));
 
-       rc = mdt_version_get_check_save(info, mp, 0);
-       if (rc)
-               GOTO(put_parent, rc);
-
-       rc = mdt_check_enc(info, mp);
-       if (rc)
-               GOTO(put_parent, rc);
-
        /* step 2: find source */
        ms = mdt_object_find(info->mti_env, info->mti_mdt, rr->rr_fid1);
        if (IS_ERR(ms))
@@ -1494,6 +1486,14 @@ static int mdt_reint_link(struct mdt_thread_info *info,
        if (rc != 0)
                GOTO(put_source, rc);
 
+       rc = mdt_version_get_check_save(info, mp, 0);
+       if (rc)
+               GOTO(unlock_parent, rc);
+
+       rc = mdt_check_enc(info, mp);
+       if (rc)
+               GOTO(unlock_parent, rc);
+
        CFS_FAIL_TIMEOUT(OBD_FAIL_MDS_RENAME3, 5);
 
        lhs = &info->mti_lh[MDT_LH_CHILD];
@@ -2883,8 +2883,6 @@ lock_parents:
        }
 
        tgt_vbr_obj_set(info->mti_env, mdt_obj2dt(mold));
-       /* save version after locking */
-       mdt_version_get_save(info, mold, 2);
 
        /* find mnew object:
         * mnew target object may not exist now
@@ -2964,6 +2962,9 @@ lock_parents:
                if (rc < 0)
                        GOTO(out_unlock_new, rc);
 
+               /* save version after locking */
+               mdt_version_get_save(info, mold, 2);
+
                /* Check if @msrcdir is subdir of @mnew, before locking child
                 * to avoid reverse locking.
                 */
@@ -3006,6 +3007,7 @@ lock_parents:
                if (rc != 0)
                        GOTO(out_put_old, rc);
 
+               mdt_version_get_save(info, mold, 2);
                mdt_enoent_version_save(info, 3);
        }