Whamcloud - gitweb
LU-12125 mds: allow parallel regular file rename 86/41186/5
authorAndreas Dilger <adilger@whamcloud.com>
Sat, 9 Jan 2021 09:08:06 +0000 (02:08 -0700)
committerOleg Drokin <green@whamcloud.com>
Sat, 6 Mar 2021 02:35:20 +0000 (02:35 +0000)
Allow rename of non-directory files in the same directory to be done
in parallel, by only taking the DLM lock on the parent FID, without
also locking the global LUSTRE_BFL_FID (Big Filesystem Lock).

Older clients may not send the renamed file mode in mds_rec_rename.
In this case, the LUSTRE_BFL_FID lock will still be taken, and is not
worse than before parallel rename was allowed.

Similarly, if (for whatever reason) there is a mix of MDS versions
running in the same filesystem, at worst older MDSes will continue to
unnecessarily lock LUSTRE_BFL_FID before doing the file rename.

If MDT0000 is on an older MDS, but newer MDSes are doing renames of
non-directories, the newer MDSes will *not* lock LUSTRE_BFL_FID first,
but there will still be proper serialization from the parent directory
FID lock for other renames affecting the parent and the source/target
entries.  That MDT0000 is unaware of the rename is the whole point.

In case of a race, where the file mode sent by the client is stale,
this is also not a concern, because the file mode is rechecked later
under lock and the rename fails if the source and target mode differ.

Test-Parameters: testlist=racer env=DURATION=3600
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: If330b53eb6db46e40f50fd7834a83e80db3ebbe5
Reviewed-on: https://review.whamcloud.com/41186
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_reint.c

index a06ccef..6760847 100644 (file)
@@ -2604,11 +2604,22 @@ static int mdt_reint_rename(struct mdt_thread_info *info,
                    mdt_object_remote(msrcdir))
                        GOTO(out_put_tgtdir, rc = -EXDEV);
 
-               rc = mdt_rename_lock(info, &rename_lh);
-               if (rc != 0) {
-                       CERROR("%s: can't lock FS for rename: rc = %d\n",
-                              mdt_obd_name(mdt), rc);
-                       GOTO(out_put_tgtdir, rc);
+               /* This may be further relaxed in the future for different
+                * source and target parents. Start with only same-directory
+                * renames of non-directory files for simplicity and because
+                * this is by far the most common use case.
+                */
+               if (msrcdir != mtgtdir || S_ISDIR(ma->ma_attr.la_mode)) {
+                       rc = mdt_rename_lock(info, &rename_lh);
+                       if (rc != 0) {
+                               CERROR("%s: cannot lock for rename: rc = %d\n",
+                                      mdt_obd_name(mdt), rc);
+                               GOTO(out_put_tgtdir, rc);
+                       }
+               } else {
+                       CDEBUG(D_INFO, "%s: samedir rename "DFID"/"DNAME"\n",
+                              mdt_obd_name(mdt), PFID(rr->rr_fid1),
+                              PNAME(&rr->rr_name));
                }
        }