From: Bobi Jam Date: Mon, 14 Feb 2022 11:50:04 +0000 (+0800) Subject: LU-15486 lod: mirroring a plain file in mirrored-layout dir X-Git-Tag: 2.15.51~9 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8005a374cac2ba726a88cec3c1bb331fc96153a1 LU-15486 lod: mirroring a plain file in mirrored-layout dir If a file does not have a mirror in a directory with a default FLR mirror, then "lfs mirror extend" on the file fails with "cannot create volatile file: Invalid argument". This comes from the the non-striped file layout generated from LOD inheriting its FLR state from the default FLR while it contains no mirror in it, and lov_init_composite() will complain about it. if (equi(flr_state == LCM_FL_NONE, comp->lo_mirror_count > 1)) RETURN(-EINVAL); Signed-off-by: Bobi Jam Change-Id: I5e849acb2327ce735d0008271bfd48fa7293161c Reviewed-on: https://review.whamcloud.com/46517 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- diff --git a/lustre/lod/lod_lov.c b/lustre/lod/lod_lov.c index 5444c63..fe8c3d4 100644 --- a/lustre/lod/lod_lov.c +++ b/lustre/lod/lod_lov.c @@ -914,7 +914,10 @@ int lod_generate_lovea(const struct lu_env *env, struct lod_object *lo, lcm->lcm_magic = cpu_to_le32(LOV_MAGIC_COMP_V1); lcm->lcm_entry_count = cpu_to_le16(comp_cnt); lcm->lcm_mirror_count = cpu_to_le16(mirror_cnt - 1); - lcm->lcm_flags = cpu_to_le16(lo->ldo_flr_state); + if (mirror_cnt > 1) + lcm->lcm_flags = cpu_to_le16(lo->ldo_flr_state); + else + lcm->lcm_flags = LCM_FL_NONE; offset = sizeof(*lcm) + sizeof(*lcme) * comp_cnt; LASSERT(offset % sizeof(__u64) == 0); diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index c268fdc..2cb697b 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -816,6 +816,36 @@ test_0j() { } run_test 0j "test lfs mirror read/write commands" +test_0k() { + [[ $OSTCOUNT -lt 3 ]] && skip "need >= 3 OSTs" && return + + mkdir $DIR/$tdir + # default FLR with 2 mirrors + $LFS setstripe -N -c1 -i0 -N -c1 -i1 $DIR/$tdir || + error "set default layout failed" + + # plain file extension under default FLR dir + echo $tfile >> $DIR/$tdir/$tfile.append || error "create $tfile.append failed" + echo -n " before extend $tfile.append, mirror count = " + $LFS getstripe -N $DIR/$tdir/$tfile.append + + $LFS mirror extend -N -c1 -i2 $DIR/$tdir/$tfile.append || + error "mirror extend failed" + echo -n " after extend $tfile.append, mirror count = " + $LFS getstripe -N $DIR/$tdir/$tfile.append + + # normal file extension under default FLR dir + touch $DIR/$tdir/$tfile || error "create $tfile failed" + echo -n " before extend $tfile, mirror count = " + $LFS getstripe -N $DIR/$tdir/$tfile + + $LFS mirror extend -N -c1 -i2 $DIR/$tdir/$tfile || + error "mirror extend $tfile failed" + echo -n " after extend $tfile, mirror count = " + $LFS getstripe -N $DIR/$tdir/$tfile +} +run_test 0k "mirroring a file in directory with default FLR layout" + test_1() { local tf=$DIR/$tfile local mirror_count=16 # LUSTRE_MIRROR_COUNT_MAX