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;
+ /* set a small enough blocks in the SoM */
+ ma->ma_attr.la_blocks >>= 1;
+ }
buf->lb_len = sizeof(mrd);
buf->lb_buf = &mrd;
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;
+ 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);
- 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);
}
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"