Whamcloud - gitweb
LU-14526 flr: mirror split downgrade SOM 68/43168/11
authorBobi Jam <bobijam@whamcloud.com>
Tue, 30 Mar 2021 11:20:26 +0000 (19:20 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 May 2021 02:03:58 +0000 (02:03 +0000)
After mirror split, the file's blocks on SoM is not accurate, this
patch downgrade the SoM from STRICT so that size glimpse does not
trust the SoM from the MDS.

Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Change-Id: I02350c24190d96af93fed8c1b8a0bc6beb2c4bc2
Reviewed-on: https://review.whamcloud.com/43168
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Yingjin Qian <qian@ddn.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/mdt/mdt_open.c
lustre/tests/sanity-flr.sh

index 877c723..6361301 100644 (file)
@@ -2162,8 +2162,11 @@ int mdt_close_handle_layouts(struct mdt_thread_info *info,
                        mrd.mrd_obj = NULL;
                }
 
                        mrd.mrd_obj = NULL;
                }
 
-               if (ma->ma_attr_flags & MDS_CLOSE_LAYOUT_SPLIT)
+               if (ma->ma_attr_flags & MDS_CLOSE_LAYOUT_SPLIT) {
                        mrd.mrd_mirror_id = data->cd_mirror_id;
                        mrd.mrd_mirror_id = data->cd_mirror_id;
+                       /* set a small enough blocks in the SoM */
+                       ma->ma_attr.la_blocks >>= 1;
+               }
 
                buf->lb_len = sizeof(mrd);
                buf->lb_buf = &mrd;
 
                buf->lb_len = sizeof(mrd);
                buf->lb_buf = &mrd;
@@ -2171,11 +2174,18 @@ int mdt_close_handle_layouts(struct mdt_thread_info *info,
                                  XATTR_LUSTRE_LOV,
                                  ma->ma_attr_flags & MDS_CLOSE_LAYOUT_SPLIT ?
                                  LU_XATTR_SPLIT : LU_XATTR_MERGE);
                                  XATTR_LUSTRE_LOV,
                                  ma->ma_attr_flags & MDS_CLOSE_LAYOUT_SPLIT ?
                                  LU_XATTR_SPLIT : LU_XATTR_MERGE);
-               if (rc == 0 && ma->ma_attr.la_valid & (LA_SIZE | LA_BLOCKS)) {
+               if (rc == 0 && ma->ma_attr.la_valid & (LA_SIZE | LA_BLOCKS |
+                                                      LA_LSIZE | LA_LBLOCKS)) {
                        int rc2;
                        int rc2;
+                       enum lustre_som_flags lsf;
+
+                       if (ma->ma_attr.la_valid & (LA_SIZE | LA_BLOCKS))
+                               lsf = SOM_FL_STRICT;
+                       else
+                               lsf = SOM_FL_LAZY;
 
                        mutex_lock(&o->mot_som_mutex);
 
                        mutex_lock(&o->mot_som_mutex);
-                       rc2 = mdt_set_som(info, o, SOM_FL_STRICT,
+                       rc2 = mdt_set_som(info, o, lsf,
                                          ma->ma_attr.la_size,
                                          ma->ma_attr.la_blocks);
                        mutex_unlock(&o->mot_som_mutex);
                                          ma->ma_attr.la_size,
                                          ma->ma_attr.la_blocks);
                        mutex_unlock(&o->mot_som_mutex);
index 671be84..400f87e 100644 (file)
@@ -2039,6 +2039,42 @@ test_44() {
 }
 run_test 44 "lfs mirror split check"
 
 }
 run_test 44 "lfs mirror split check"
 
+test_44c() {
+       local tf=$DIR/$tdir/$tfile
+
+       stack_trap "rm -f $tf"
+
+       [ $MDS1_VERSION -ge $(version_code 2.14.52) ] ||
+               skip "Need MDS version at least 2.14.52"
+
+       [ "$FSTYPE" != "zfs" ] || skip "ZFS file's block number is not accurate"
+
+       mkdir -p $DIR/$tdir || error "create directroy failed"
+
+       dd if=/dev/zero of=$tf bs=1M count=10 || error "dd write $tfile failed"
+       sync
+       block1=$(( $(stat -c "%b*%B" $tf) ))
+       echo " ** before mirror ops, file blocks=$((block1/1024)) KiB"
+
+       $LFS mirror extend -N2 -c1 $tf || error "mirror extend $tfile failed"
+       sync
+       block2=$(( $(stat -c "%b*%B" $tf) ))
+       echo " ** after mirror extend, file blocks=$((block2/1024)) KiB"
+
+       $LFS mirror split -d --mirror-id=2 $tf ||
+               error "mirror split $tfile failed"
+       $LFS mirror split -d --mirror-id=3 $tf ||
+               error "mirror split $tfile failed"
+       sync
+       lfs getsom $tf
+       block3=$(( $(stat -c "%b*%B" $tf) ))
+       echo " ** after mirror split, file blocks=$((block3/1024)) KiB"
+
+       [[ $block1 -eq $block3 ]] ||
+               error "mirror split does not reduce block# $block3 != $block1"
+}
+run_test 44c "lfs mirror split reduces block size of a file"
+
 test_45() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
 
 test_45() {
        [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"