Whamcloud - gitweb
LU-13668 mdt: change lock mode for lease 64/38964/23
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 17 Jun 2020 14:05:28 +0000 (17:05 +0300)
committerOleg Drokin <green@whamcloud.com>
Sat, 11 Sep 2021 06:19:49 +0000 (06:19 +0000)
make it PW so that lfs getstripe and open-for-read do not
interrupt replication.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I20f4bbbc4e7bf9055333aba1b8cca80aa899c664
Reviewed-on: https://review.whamcloud.com/38964
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Patrick Farrell <farr0186@gmail.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/tests/sanity-pcc.sh
lustre/tests/sanity.sh

index e211d36..5bbcd29 100644 (file)
@@ -867,8 +867,8 @@ static int mdt_object_open_lock(struct mdt_thread_info *info,
                        GOTO(out, rc = -EPROTO);
                }
 
-               /* XXX: only exclusive open is supported. */
-               lm = LCK_EX;
+               /* should conflict with new opens for write/execute */
+               lm = LCK_PW;
                *ibits = MDS_INODELOCK_OPEN;
 
                /* never grant LCK_EX layout lock to client */
@@ -986,8 +986,11 @@ static int mdt_object_open_lock(struct mdt_thread_info *info,
                        PFID(mdt_object_fid(obj)),
                        atomic_read(&obj->mot_open_count), open_count);
 
-               if (atomic_read(&obj->mot_open_count) > open_count)
-                       GOTO(out, rc = -EBUSY);
+               if (atomic_read(&obj->mot_open_count) > open_count) {
+                       /* fail if anyone *else* has opened file for write */
+                       if (mdt_write_read(obj) > 1)
+                               GOTO(out, rc = -EBUSY);
+               }
        }
        GOTO(out, rc);
 
index 5e6dce5..36c0714 100644 (file)
@@ -1048,7 +1048,7 @@ test_12() {
        sleep 3
        wait_request_state $(path2fid $file) RESTORE SUCCEED
        $LFS hsm_remove $file || error "hsm remove $file failed"
-       wait $pid && error "RW-PCC attach $file should fail"
+       wait $pid
        do_facet $SINGLEAGT "[ -f $lpcc_path ]" &&
                error "RW-PCC cached file '$lpcc_path' should be removed"
 
index c0aac29..45b4494 100755 (executable)
@@ -18178,23 +18178,23 @@ test_208() {
        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
 
        echo "==== test 2: verify lease can be broken by upcoming open"
-       $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
+       $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
        local PID=$!
        sleep 1
 
-       $MULTIOP $DIR/$tfile oO_RDONLY:c
+       $MULTIOP $DIR/$tfile oO_RDWR:c
        kill -USR1 $PID && wait $PID || error "break lease error"
 
        echo "==== test 3: verify lease can't be granted if an open already exists"
-       $MULTIOP $DIR/$tfile oO_RDONLY:_c &
+       $MULTIOP $DIR/$tfile oO_RDWR:_c &
        local PID=$!
        sleep 1
 
-       $MULTIOP $DIR/$tfile oO_RDONLY:eReUc && error "apply lease should fail"
+       $MULTIOP $DIR/$tfile oO_RDWR:eReUc && error "apply lease should fail"
        kill -USR1 $PID && wait $PID || error "open file error"
 
        echo "==== test 4: lease can sustain over recovery"
-       $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc &
+       $MULTIOP $DIR/$tfile oO_RDWR:eR_E+eUc &
        PID=$!
        sleep 1
 
@@ -18203,7 +18203,7 @@ test_208() {
        kill -USR1 $PID && wait $PID || error "lease broken over recovery"
 
        echo "==== test 5: lease broken can't be regained by replay"
-       $MULTIOP $DIR/$tfile oO_RDONLY:eR_E-eUc &
+       $MULTIOP $DIR/$tfile oO_RDWR:eR_E-eUc &
        PID=$!
        sleep 1