Whamcloud - gitweb
LU-14647 flr: mmap write/punch does not stale other mirrors
authorBobi Jam <bobijam@whamcloud.com>
Wed, 28 Apr 2021 05:07:36 +0000 (13:07 +0800)
committerLi Xi <lixi@ddn.com>
Thu, 29 Jul 2021 14:16:25 +0000 (14:16 +0000)
mmap write and punch/fallocate do not stale other mirrors and makes
FLR file contains different content in different mirrors.

Lustre-change: https://review.whamcloud.com/43470/
Lustre-commit: 03511484c668355c77e54e4b01600183236d8673

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I93a3eb5ba898e3bf0ce108718506b742ed485da5
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/44258
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/include/cl_object.h
lustre/llite/llite_mmap.c
lustre/llite/vvp_io.c
lustre/lov/lov_io.c
lustre/tests/sanity-flr.sh

index 8001fbb..d1b9f22 100644 (file)
@@ -2461,6 +2461,11 @@ static inline int cl_io_is_mkwrite(const struct cl_io *io)
        return io->ci_type == CIT_FAULT && io->u.ci_fault.ft_mkwrite;
 }
 
+static inline int cl_io_is_fault_writable(const struct cl_io *io)
+{
+       return io->ci_type == CIT_FAULT && io->u.ci_fault.ft_writable;
+}
+
 /**
  * True, iff \a io is a truncate(2).
  */
index 871a3bd..4752ec6 100644 (file)
@@ -119,6 +119,9 @@ restart:
        else if (vma->vm_flags & VM_RAND_READ)
                io->ci_rand_read = 1;
 
+       if (vma->vm_flags & VM_WRITE)
+               fio->ft_writable = 1;
+
        rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
        if (rc == 0) {
                struct vvp_io *vio = vvp_env_io(env);
index b7062b8..06f730b 100644 (file)
@@ -367,7 +367,8 @@ static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
                io->ci_need_write_intent = 0;
 
                LASSERT(io->ci_type == CIT_WRITE || cl_io_is_fallocate(io) ||
-                       cl_io_is_trunc(io) || cl_io_is_mkwrite(io));
+                       cl_io_is_trunc(io) || cl_io_is_mkwrite(io) ||
+                       cl_io_is_fault_writable(io));
 
                CDEBUG(D_VFSTRACE, DFID" write layout, type %u "DEXT"\n",
                       PFID(lu_object_fid(&obj->co_lu)), io->ci_type,
index 593d116..832432a 100644 (file)
@@ -227,8 +227,9 @@ static int lov_io_mirror_write_intent(struct lov_io *lio,
        *ext = (typeof(*ext)) { lio->lis_pos, lio->lis_endpos };
        io->ci_need_write_intent = 0;
 
-       if (!(io->ci_type == CIT_WRITE || cl_io_is_trunc(io) ||
-             cl_io_is_mkwrite(io)))
+       if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
+             cl_io_is_fallocate(io) || cl_io_is_trunc(io) ||
+             cl_io_is_fault_writable(io)))
                RETURN(0);
 
        /*
@@ -601,7 +602,8 @@ static int lov_io_slice_init(struct lov_io *lio,
        /* check if it needs to instantiate layout */
        if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
              cl_io_is_fallocate(io) ||
-             (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0)))
+             (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0)) ||
+             cl_io_is_fault_writable(io))
                GOTO(out, result = 0);
 
        /*
index 09fc405..eb7188d 100644 (file)
@@ -1964,7 +1964,8 @@ test_44c() {
        mkdir -p $DIR/$tdir || error "create directroy failed"
 
        dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed"
-       sync
+       sync $tf
+       sleep 1
        block1=$(( $(stat -c "%b*%B" $tf) ))
        echo " ** before mirror ops, file blocks=$((block1/1024)) KiB"
 
@@ -2520,6 +2521,32 @@ test_50b() {
 }
 run_test 50b "mirror rsync handles sparseness"
 
+test_50c() {
+       local tf=$DIR/$tdir/$tfile
+
+       test_mkdir $DIR/$tdir
+
+       $LFS setstripe -N2 -c-1 $tf || error "create FLR $tf failed"
+       verify_flr_state $tf "ro"
+
+       # fallocate add punch mode in v2_14_51-78 (cb037f305c)
+       if [ "$FSTYPE" == "ldiskfs" ] &&
+                       [ $OST1_VERSION -ge $(version_code 2.14.51) ]; then
+               # ZFS does not support fallocate for now
+               fallocate -p -o 1MiB -l 1MiB $tf ||
+                       error "punch hole in $tf failed"
+               verify_flr_state $tf "wp"
+       fi
+
+       dd if=/dev/zero of=$tf bs=4096 count=4 || error "write $tf failed"
+       $LFS mirror resync $tf || error "mirror resync $tf failed"
+       verify_flr_state $tf "ro"
+
+       $MULTIOP $tf OSMWUc || error "$MULTIOP $tf failed"
+       verify_flr_state $tf "wp"
+}
+run_test 50c "punch_hole/mmap_write stale other mirrors"
+
 test_60a() {
        $LCTL get_param osc.*.import | grep -q 'connect_flags:.*seek' ||
                skip "OST does not support SEEK_HOLE"