Whamcloud - gitweb
LU-15526 mdt: enable remote PDO lock 33/46733/5
authorLai Siyao <lai.siyao@whamcloud.com>
Fri, 7 Jul 2023 15:06:02 +0000 (11:06 -0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 31 Aug 2023 06:23:22 +0000 (06:23 +0000)
Once parent directory is located on remote MDT, enqueue two locks like
local PDO lock if it's locked in LCK_PW mode. With this change,
creating directories (either local or remote) under one directory will
hardly trigger commit-on-sharing (unless their PDO hashes equal).

Updated sanityn 33c.

Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I28030c45fbf137f5912863ae5eacfc8372db6754
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/46733
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_dlm.h
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/tests/sanityn.sh

index e2f63cf..33b5f0d 100644 (file)
@@ -140,25 +140,25 @@ enum ldlm_side {
  *       NL  CR  CW  PR  PW  EX GROUP COS TXN
  *  NL    1   1   1   1   1   1   1   1   1
  *  CR    1   1   1   1   1   0   0   0   1
- *  CW    1   1   1   0   0   0   0   0   1
+ *  CW    1   1   1   0   0   0   0   0   0
  *  PR    1   1   0   1   0   0   0   0   1
  *  PW    1   1   0   0   0   0   0   0   0
  *  EX    1   0   0   0   0   0   0   0   0
  *  GROUP 1   0   0   0   0   0   1   0   0
  *  COS   1   0   0   0   0   0   0   1   0
- *  TXN   1   1   1   1   0   0   0   0   1
+ *  TXN   1   1   0   1   0   0   0   0   1
  * </PRE>
  */
 /** @{ */
 #define LCK_COMPAT_EX    LCK_NL
 #define LCK_COMPAT_PW    (LCK_COMPAT_EX | LCK_CR)
 #define LCK_COMPAT_PR    (LCK_COMPAT_PW | LCK_PR | LCK_TXN)
-#define LCK_COMPAT_CW    (LCK_COMPAT_PW | LCK_CW | LCK_TXN)
+#define LCK_COMPAT_CW    (LCK_COMPAT_PW | LCK_CW)
 #define LCK_COMPAT_CR    (LCK_COMPAT_CW | LCK_PR | LCK_PW | LCK_TXN)
 #define LCK_COMPAT_NL    (LCK_COMPAT_CR | LCK_EX | LCK_GROUP | LCK_COS)
 #define LCK_COMPAT_GROUP (LCK_NL | LCK_GROUP)
 #define LCK_COMPAT_COS   (LCK_NL | LCK_COS)
-#define LCK_COMPAT_TXN   (LCK_COMPAT_PR | LCK_CW)
+#define LCK_COMPAT_TXN   LCK_COMPAT_PR
 /** @} Lock Compatibility Matrix */
 
 extern enum ldlm_mode lck_compat_array[];
index 2041ca1..620aea2 100644 (file)
@@ -3832,9 +3832,16 @@ int mdt_object_pdo_lock(struct mdt_thread_info *info, struct mdt_object *obj,
        mdt_lock_pdo_mode(info, obj, lh);
        if (lh->mlh_pdo_mode != LCK_NL) {
                if (pdo_lock) {
-                       rc = mdt_fid_lock(info->mti_env, ns, &lh->mlh_pdo_lh,
-                                         lh->mlh_pdo_mode, policy, res_id,
-                                         dlmflags, cookie);
+                       if (mdt_object_remote(obj)) {
+                               rc = mdt_remote_object_lock_try(info, obj,
+                                       &lh->mlh_pdo_lh, lh->mlh_pdo_mode,
+                                       policy, res_id, false);
+                               lh->mlh_pdo_remote = 1;
+                       } else {
+                               rc = mdt_fid_lock(info->mti_env, ns,
+                                       &lh->mlh_pdo_lh, lh->mlh_pdo_mode,
+                                       policy, res_id, dlmflags, cookie);
+                       }
                        if (rc) {
                                mdt_object_unlock(info, obj, lh, 1);
                                return rc;
@@ -3843,8 +3850,12 @@ int mdt_object_pdo_lock(struct mdt_thread_info *info, struct mdt_object *obj,
                res_id->name[LUSTRE_RES_ID_HSH_OFF] = lh->mlh_pdo_hash;
        }
 
-       rc = mdt_fid_lock(info->mti_env, ns, &lh->mlh_reg_lh, lh->mlh_reg_mode,
-                         policy, res_id, dlmflags, cookie);
+       if (mdt_object_remote(obj))
+               rc = mdt_remote_object_lock_try(info, obj, &lh->mlh_rreg_lh,
+                       lh->mlh_rreg_mode, policy, res_id, false);
+       else
+               rc = mdt_fid_lock(info->mti_env, ns, &lh->mlh_reg_lh,
+                       lh->mlh_reg_mode, policy, res_id, dlmflags, cookie);
        if (rc)
                mdt_object_unlock(info, obj, lh, 1);
        else if (CFS_FAIL_PRECHECK(OBD_FAIL_MDS_PDO_LOCK) &&
@@ -4028,7 +4039,8 @@ int mdt_object_check_lock(struct mdt_thread_info *info,
 /**
  * take parent UPDATE lock
  *
- * if parent is local, take PDO lock by name hash, otherwise take regular lock.
+ * if parent is local or mode is LCK_PW, take PDO lock, otherwise take regular
+ * lock.
  *
  * \param info struct mdt_thread_info
  * \param obj  parent object
@@ -4046,7 +4058,8 @@ int mdt_parent_lock(struct mdt_thread_info *info, struct mdt_object *obj,
 
        ENTRY;
        LASSERT(obj && lname);
-       if (mdt_object_remote(obj)) {
+       LASSERT(mode == LCK_PW || mode == LCK_PR);
+       if (mdt_object_remote(obj) && mode == LCK_PR) {
                __u64 ibits = MDS_INODELOCK_UPDATE;
 
                mdt_lock_reg_init(lh, mode);
@@ -4250,7 +4263,11 @@ void mdt_object_unlock(struct mdt_thread_info *info, struct mdt_object *o,
 {
        ENTRY;
 
-       mdt_save_lock(info, &lh->mlh_pdo_lh, lh->mlh_pdo_mode, decref);
+       if (lh->mlh_pdo_remote)
+               mdt_save_remote_lock(info, o, &lh->mlh_pdo_lh,
+                                    lh->mlh_pdo_mode, decref);
+       else
+               mdt_save_lock(info, &lh->mlh_pdo_lh, lh->mlh_pdo_mode, decref);
        mdt_save_lock(info, &lh->mlh_reg_lh, lh->mlh_reg_mode, decref);
        mdt_save_remote_lock(info, o, &lh->mlh_rreg_lh, lh->mlh_rreg_mode,
                             decref);
index 71fef0d..2f65e74 100644 (file)
@@ -408,6 +408,7 @@ struct mdt_lock_handle {
        struct lustre_handle    mlh_pdo_lh;
        enum ldlm_mode          mlh_pdo_mode;
        unsigned int            mlh_pdo_hash;
+       unsigned int            mlh_pdo_remote:1;
 
        /* Remote regular lock */
        struct lustre_handle    mlh_rreg_lh;
index 6dbe10b..fb77297 100755 (executable)
@@ -1361,7 +1361,6 @@ test_33_run() {
        echo $1
        echo "  $2"
        eval $2
-#      bash -c "$2"
 }
 
 test_33c() {
@@ -1376,13 +1375,15 @@ test_33c() {
        mkdir_on_mdt0 $DIR/$tdir
        sync_all_data
 
-       op_trigger_solc "create remote dir and local dir" \
-               "$LFS mkdir -i 1 $DIR/$tdir/remote" \
-               "$LFS mkdir -i 0 $DIR/$tdir/local"
-       (( MDSCOUNT > 2 )) &&
-       op_trigger_solc "create remote dirs on different MDTs" \
-               "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
-               "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
+       if (( MDS1_VERSION < $(version_code 2.15.55.204) )); then
+               op_trigger_solc "create remote dir and local dir" \
+                       "$LFS mkdir -i 1 $DIR/$tdir/remote" \
+                       "$LFS mkdir -i 0 $DIR/$tdir/local"
+               (( MDSCOUNT > 2 )) &&
+               op_trigger_solc "create remote dirs on different MDTs" \
+                       "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
+                       "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
+       fi
        op_trigger_solc "create file on 2nd stripe under striped directory" \
                "$LFS mkdir -i 0 -c 2 $DIR/$tdir/striped" \
                "touch $DIR2/$tdir/striped/subfile"
@@ -1392,10 +1393,17 @@ test_33c() {
        $LFS mkdir -i 0 -c 2 $DIR/$tdir/striped
        sync_all_data
        do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
-       if (( MDS1_VERSION >= $(version_code 2.15.55.133) )); then
+       if (( MDS1_VERSION >= $(version_code 2.15.55.204) )); then
                test_33_run "create file on 2nd stripe after setattr" \
                        "chmod 777 $DIR/$tdir/striped; \
                         touch $DIR2/$tdir/striped/subfile"
+               test_33_run "create remote dir and local dir" \
+                       "$LFS mkdir -i 1 $DIR/$tdir/remote" \
+                       "$LFS mkdir -i 0 $DIR/$tdir/local"
+               (( MDSCOUNT > 2 )) &&
+               test_33_run "create remote dirs on different MDTs" \
+                       "$LFS mkdir -i 1 $DIR/$tdir/remote.1" \
+                       "$LFS mkdir -i 2 $DIR/$tdir/remote.2"
        fi
        test_33_run "create local dir after remote dir creation transaction commit" \
                "$LFS mkdir -i 1 $DIR/$tdir/remote.3; \