Whamcloud - gitweb
LU-14647 flr: mmap write/punch does not stale other mirrors 70/43470/5
authorBobi Jam <bobijam@whamcloud.com>
Wed, 28 Apr 2021 05:07:36 +0000 (13:07 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 27 May 2021 18:17:15 +0000 (18:17 +0000)
mmap write and punch/fallocate do not stale other mirrors and makes
FLR file contains different content in different mirrors.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I93a3eb5ba898e3bf0ce108718506b742ed485da5
Reviewed-on: https://review.whamcloud.com/43470
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.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 cb38515..1fc8f1b 100644 (file)
@@ -2455,6 +2455,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 1b24893..8873f70 100644 (file)
@@ -111,6 +111,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);
@@ -123,7 +126,6 @@ restart:
                io->ci_lockreq = CILR_MANDATORY;
                vio->vui_fd = fd;
        } else {
-               LASSERT(rc < 0);
                cl_io_fini(env, io);
                if (io->ci_need_restart)
                        goto restart;
index 6d752b9..de2da6c 100644 (file)
@@ -368,7 +368,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 74ec3b4..9ffd102 100644 (file)
@@ -226,8 +226,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);
 
        /*
@@ -581,7 +582,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 400f87e..c26c203 100644 (file)
@@ -2608,6 +2608,30 @@ 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"
+
+       if [[ "$FSTYPE" == "ldiskfs" ]]; 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"