From 250108ad754cfa932306d7edae10de14d40aeb4e Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 7 Mar 2022 15:29:26 -0500 Subject: [PATCH] LU-15609 flr: Don't assume RDONLY implies SOM In lov_io_slice_mirror_init, the client code assumes that the LCM_FL_RDONLY flag in the layout implies SOM and skips glimpse if it sees one. The RDONLY flag means the mirrors are in sync, which has historically implied SOM is valid. To start with, using LCM_FL_RDONLY to imply SOM is sort of a layering violation. SOM is only communicated from the MDS when it is valid, and the client already skips glimpse in that case, so this duplicates functionality from the higher layers. More seriously, patch: "LU-14526 flr: mirror split downgrade SOM" (https://review.whamcloud.com/43168/) Made it possible to have LCM_FL_RDONLY but not strict SOM, so this assumption is no longer correct. The fix is to not look at LCM_FL_RDONLY when deciding whether to glimpse a file for size. Fixes: d87b6f4d1c ("LU-14526 flr: mirror split downgrade SOM") Signed-off-by: Patrick Farrell Change-Id: I5ed0a2124005bc58c1ed11681c9bd642cffcd1b5 Reviewed-on: https://review.whamcloud.com/46666 Tested-by: jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/obd_support.h | 1 - lustre/lov/lov_io.c | 5 ----- lustre/tests/sanity-flr.sh | 45 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index a927d2c..2e2ad79 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -684,7 +684,6 @@ extern char obd_jobid_var[]; #define OBD_FAIL_UNKNOWN_LMV_STRIPE 0x1901 /* FLR */ -#define OBD_FAIL_FLR_GLIMPSE_IMMUTABLE 0x1A00 #define OBD_FAIL_FLR_LV_DELAY 0x1A01 #define OBD_FAIL_FLR_LV_INC 0x1A02 #define OBD_FAIL_FLR_RANDOM_PICK_MIRROR 0x1A03 diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 381ae56..cc95993 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -551,11 +551,6 @@ static int lov_io_slice_init(struct lov_io *lio, case CIT_GLIMPSE: lio->lis_pos = 0; lio->lis_endpos = OBD_OBJECT_EOF; - - if (lov_flr_state(obj) == LCM_FL_RDONLY && - !OBD_FAIL_CHECK(OBD_FAIL_FLR_GLIMPSE_IMMUTABLE)) - /* SoM is accurate, no need glimpse */ - GOTO(out, result = 1); break; case CIT_MISC: diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index 4d14a8f..e50979d 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -1061,9 +1061,6 @@ test_31() { $LFS mirror create -N -o 0 -N -o 1 $tf || error "creating mirrored file $tf failed" - #define OBD_FAIL_GLIMPSE_IMMUTABLE 0x1A00 - $LCTL set_param fail_loc=0x1A00 - local ost_idx for ((ost_idx = 1; ost_idx <= 2; ost_idx++)); do cancel_lru_locks osc @@ -2173,6 +2170,48 @@ test_44c() { } run_test 44c "lfs mirror split reduces block size of a file" +test_44d() { + local tf=$DIR/$tdir/$tfile + local size1 + local size2 + local size3 + local size4 + + stack_trap "rm -f $tf" + + mkdir -p $DIR/$tdir || error "create directroy failed" + + dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed" + sync + size1=$(stat -c "%s" $tf) + echo " ** before mirror ops, file size=$size1" + + $LFS mirror extend -N2 -c1 $tf || error "mirror extend $tfile failed" + sync + size2=$(stat -c "%s" $tf) + echo " ** after mirror extend, file size=$size2" + + (($size1 == $size2)) || + error "mirror extend should not change size, before: $size1, after $size2" + + $LFS mirror split -d --mirror-id=2 $tf || + error "mirror split $tfile failed" + + size2=$(stat -c "%s" $tf) + echo " ** after mirror split, file size=$size2" + (($size1 == $size2)) || + error "mirror split should not change size, before: $size1, after $size2" + + # Remount client to clear cached size information + remount_client $MOUNT + size2=$(stat -c "%s" $tf) + echo " ** after mirror split & remount, file size=$size2" + (($size1 == $size2)) || + error "mirror extend should not change size, before: $size1, after $size2" + +} +run_test 44d "lfs mirror split does not break size" + test_45() { [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" -- 1.8.3.1