From 03511484c668355c77e54e4b01600183236d8673 Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Wed, 28 Apr 2021 13:07:36 +0800 Subject: [PATCH] LU-14647 flr: mmap write/punch does not stale other mirrors 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 Change-Id: I93a3eb5ba898e3bf0ce108718506b742ed485da5 Reviewed-on: https://review.whamcloud.com/43470 Tested-by: jenkins Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 5 +++++ lustre/llite/llite_mmap.c | 4 +++- lustre/llite/vvp_io.c | 3 ++- lustre/lov/lov_io.c | 8 +++++--- lustre/tests/sanity-flr.sh | 24 ++++++++++++++++++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index cb38515..1fc8f1b 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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). */ diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index 1b24893..8873f70 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -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; diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 6d752b9..de2da6c 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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, diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 74ec3b4..9ffd102 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -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); /* diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 400f87e..c26c203 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -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" -- 1.8.3.1