From f2d1c4ee463c7cb02a8fcbb8a0ea75f37b1a7bab 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. Lustre-change: https://review.whamcloud.com/43470/ Lustre-commit: 03511484c668355c77e54e4b01600183236d8673 Signed-off-by: Bobi Jam Change-Id: I93a3eb5ba898e3bf0ce108718506b742ed485da5 Reviewed-by: Wang Shilong Reviewed-by: Andreas Dilger Reviewed-by: John L. Hammond Reviewed-on: https://review.whamcloud.com/44258 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Li Xi --- lustre/include/cl_object.h | 5 +++++ lustre/llite/llite_mmap.c | 3 +++ lustre/llite/vvp_io.c | 3 ++- lustre/lov/lov_io.c | 8 +++++--- lustre/tests/sanity-flr.sh | 29 ++++++++++++++++++++++++++++- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 8001fbb..d1b9f22 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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). */ diff --git a/lustre/llite/llite_mmap.c b/lustre/llite/llite_mmap.c index 871a3bd..4752ec6 100644 --- a/lustre/llite/llite_mmap.c +++ b/lustre/llite/llite_mmap.c @@ -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); diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index b7062b8..06f730b 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -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, diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 593d116..832432a 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -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); /* diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 09fc405..eb7188d 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -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" -- 1.8.3.1