From: Wang Shilong Date: Mon, 7 Dec 2020 03:06:08 +0000 (+0800) Subject: LU-14186 lov: instantiate components layout for fallocate X-Git-Tag: 2.14.0-RC1~69 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7e25e6c7d0a710ea25aa0ca277e61fbd18ab3dd3 LU-14186 lov: instantiate components layout for fallocate fallocate() need send intent lock to MDS to instantiate layout like PFL. Signed-off-by: Wang Shilong Change-Id: Ie14574ca0981ea00aa1867489d2a40b75eb511cc Reviewed-on: https://review.whamcloud.com/40885 Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: Yingjin Qian Reviewed-by: Arshad Hussain Tested-by: Maloo --- diff --git a/lustre/llite/vvp_io.c b/lustre/llite/vvp_io.c index 7099633..fc7872e 100644 --- a/lustre/llite/vvp_io.c +++ b/lustre/llite/vvp_io.c @@ -367,7 +367,7 @@ 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 || + LASSERT(io->ci_type == CIT_WRITE || cl_io_is_fallocate(io) || cl_io_is_trunc(io) || cl_io_is_mkwrite(io)); CDEBUG(D_VFSTRACE, DFID" write layout, type %u "DEXT"\n", diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 0724043..f20c8f4 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -578,6 +578,7 @@ 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))) GOTO(out, result = 0); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 66c2903..a590831 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13433,17 +13433,33 @@ test_150c() { [ $OST1_VERSION -lt $(version_code 2.13.50) ] && skip "Need OST version at least 2.13.53" - $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed" - fallocate -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed" + $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed" + fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed" sync; sync_all_data cancel_lru_locks $OSC sleep 5 - bytes=$(($(stat -c '%b * %B' $DIR/$tdir))) + bytes=$(($(stat -c '%b * %B' $DIR/$tfile))) want=$((OSTCOUNT * 1048576)) # Must allocate all requested space, not more than 5% extra (( $bytes >= $want && $bytes < $want * 105 / 100 )) || error "bytes $bytes is not $want" + + rm -f $DIR/$tfile + # verify fallocate on PFL file + $LFS setstripe -E1M -c1 -E16M -c3 -Eeof -c 4 $DIR/$tfile || + error "Create $DIR/$tfile failed" + fallocate -l $((1048576 * 1024)) $DIR/$tfile || + error "fallocate failed" + sync; sync_all_data + cancel_lru_locks $OSC + sleep 5 + bytes=$(($(stat -c '%b * %B' $DIR/$tfile))) + want=$((1024 * 1048576)) + + # Must allocate all requested space, not more than 5% extra + (( $bytes >= $want && $bytes < $want * 105 / 100 )) || + error "bytes $bytes is not $want" } run_test 150c "Verify fallocate Size and Blocks"