Whamcloud - gitweb
LU-13693 lfs: check early for MDS_OPEN_DIRECTORY 59/39159/4
authorJohn L. Hammond <jhammond@whamcloud.com>
Tue, 23 Jun 2020 18:00:55 +0000 (13:00 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 4 Jul 2020 03:05:52 +0000 (03:05 +0000)
In mdt_reint_open() check earlier for MDS_OPEN_DIRECTORY/O_DIRECTORY
to avoid breaking leases used by lfs mirror when calling lfs
getstripe. Add a multi client version of sanity test_210 to sanityn.

Signed-off-by: John L. Hammond <jhammond@whamcloud.com>
Change-Id: I1860fc76c8014da3e637d83b487cb28b037ba71b
Reviewed-on: https://review.whamcloud.com/39159
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/tests/sanityn.sh

index bb46c20..5aa5314 100644 (file)
@@ -1529,6 +1529,14 @@ int mdt_reint_open(struct mdt_thread_info *info, struct mdt_lock_handle *lhc)
                                result = -MDT_EREMOTE_OPEN;
                         GOTO(out_child, result);
                } else if (mdt_object_exists(child)) {
+                       /* Check early for MDS_OPEN_DIRECTORY/O_DIRECTORY to
+                        * avoid opening regular files from lfs getstripe
+                        * since doing so breaks the leases used by lfs
+                        * mirror. See LU-13693. */
+                       if (open_flags & MDS_OPEN_DIRECTORY &&
+                           S_ISREG(lu_object_attr(&child->mot_obj)))
+                               GOTO(out_child, result = -ENOTDIR);
+
                        /* We have to get attr & LOV EA & HSM for this
                         * object. */
                        mdt_prep_ma_buf_from_rep(info, child, ma);
index 1af29dd..5dae9be 100755 (executable)
@@ -3011,6 +3011,27 @@ test_51d() {
 }
 run_test 51d "layout lock: losing layout lock should clean up memory map region"
 
+test_51e() {
+       local pid
+
+       $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc &
+       pid=$!
+       sleep 1
+
+       $LFS getstripe $DIR2/$tfile
+       kill -USR1 $pid
+       wait $pid || error "multiop failed"
+
+       $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
+       pid=$!
+       sleep 1
+
+       $LFS getstripe $DIR2/$tfile
+       kill -USR1 $pid
+       wait $pid || error "multiop failed"
+}
+run_test 51e "lfs getstripe does not break leases, part 2"
+
 test_54_part1()
 {
        echo "==> rename vs getattr vs setxattr should not deadlock"