From: Arshad Hussain Date: Mon, 14 Feb 2022 10:02:08 +0000 (+0530) Subject: LU-15551 ofd: Return EOPNOTSUPP instead of EPROTO X-Git-Tag: 2.15.0-RC3~25 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=2f496148c31dd435681e595129834cecdaec82dc;p=fs%2Flustre-release.git LU-15551 ofd: Return EOPNOTSUPP instead of EPROTO Modify server to return -EOPNOTSUPP instead of -EPROTO for unsupported fallocate modes Test-Parameters: serverversion=2.14.0 testlist=sanity env=ONLY=150 Test-Parameters: serverversion=2.14.0 testlist=sanity-flr env=ONLY=50 Test-Parameters: serverversion=2.14.0 testlist=ost-pools env=ONLY="29 31" Test-Parameters: serverversion=2.14.0 testlist=sanity-benchmark env=ONLY=fsx Test-Parameters: serverversion=2.14.0 testlist=sanity-dom env=ONLY=fsx Test-Parameters: serverversion=2.14.0 testlist=sanityn env=ONLY=16 Fixes: 7462e8cad730 ("LU-14160 fallocate: Add punch mode to fallocate") Signed-off-by: arshad.hussain@aeoncomputing.com Change-Id: Id203c0b9abbdd674af33f1f78e81ae7fe105e90f Reviewed-on: https://review.whamcloud.com/46516 Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Tested-by: jenkins Reviewed-by: Oleg Drokin Tested-by: Oleg Drokin --- diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index c0914a6..7fcb5ac 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -1987,10 +1987,12 @@ static int ofd_fallocate_hdl(struct tgt_session_info *tsi) /* * fallocate start and end are passed in o_size, o_blocks * on the wire. + * Return -EOPNOTSUPP to also handle older clients not + * supporting newer server modes */ if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) != (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) - RETURN(err_serious(-EPROTO)); + RETURN(-EOPNOTSUPP); start = oa->o_size; end = oa->o_blocks; diff --git a/lustre/tests/sanity-flr.sh b/lustre/tests/sanity-flr.sh index c5d4b7d..f39bdc2 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -2720,8 +2720,8 @@ test_50c() { if [[ "$FSTYPE" == "ldiskfs" ]]; then # ZFS does not support fallocate for now - fallocate -p -o 1MiB -l 1MiB $tf || - error "punch hole in $tf failed" + out=$(fallocate -p -o 1MiB -l 1MiB $tf 2>&1) || + skip_eopnotsupp "$out|punch hole in $tf failed" verify_flr_state $tf "wp" fi @@ -2763,7 +2763,7 @@ test_50d() { elif [[ ! $prt =~ "unsupported" ]]; then error "punch hole in $file failed: $prt" else - skip "Fallocate punch is not supported" + skip "Fallocate punch is not supported: $prt" fi echo " ** verify sparseness" diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 22fde7f..a437b57 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14647,7 +14647,7 @@ test_150b() { touch $DIR/$tfile stack_trap "rm -f $DIR/$tfile; wait_delete_completed" - check_fallocate $DIR/$tfile || error "fallocate failed" + check_fallocate $DIR/$tfile || skip_eopnotsupp "fallocate failed" } run_test 150b "Verify fallocate (prealloc) functionality" @@ -14697,8 +14697,7 @@ test_150c() { $LFS setstripe -E1M $striping -E16M -c3 -Eeof -c 4 $DIR/$tfile || error "Create $DIR/$tfile failed" - fallocate -l $((1048576 * 512)) $DIR/$tfile || - error "fallocate failed" + fallocate -l $((1048576 * 512)) $DIR/$tfile || error "fallocate failed" bytes=$(($(stat -c '%b * %B' $DIR/$tfile))) want=$((512 * 1048576)) @@ -14802,8 +14801,8 @@ test_150f() { error "dd failed for bs 4096 and count 5" # Call fallocate with punch range which is within the file range - fallocate -p --offset 4096 -l $length $DIR/$tfile || - error "fallocate failed: offset 4096 and length $length" + out=$(fallocate -p --offset 4096 -l $length $DIR/$tfile 2>&1) || + skip_eopnotsupp "$out|fallocate: offset 4096 and length $length" # client must see changes immediately after fallocate size=$(stat -c '%s' $DIR/$tfile) blocks=$(stat -c '%b' $DIR/$tfile) @@ -14833,8 +14832,8 @@ test_150f() { want_blocks_after=40 # 512 sized blocks # Punch overlaps two blocks and less than blocksize - fallocate -p --offset 4000 -l 3000 $DIR/$tfile || - error "fallocate failed: offset 4000 length 3000" + out=$(fallocate -p --offset 4000 -l 3000 $DIR/$tfile 2>&1) || + skip_eopnotsupp "$out|fallocate: offset 4000 length 3000" size=$(stat -c '%s' $DIR/$tfile) blocks=$(stat -c '%b' $DIR/$tfile) @@ -14918,8 +14917,8 @@ test_150g() { # Call fallocate to punch all except 2 blocks. We leave the # first and the last block echo "fallocate -p --offset $BS -l $punch_size $DIR/$tfile" - fallocate -p --offset $BS -l $punch_size $DIR/$tfile || - error "fallocate failed: offset $BS length $punch_size" + out=$(fallocate -p --offset $BS -l $punch_size $DIR/$tfile 2>&1) || + skip_eopnotsupp "$out|fallocate: offset $BS length $punch_size" size_after=$(stat -c '%s' $DIR/$tfile) blocks_after=$(stat -c '%b' $DIR/$tfile) diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index abc2222..25eb353 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -6451,6 +6451,19 @@ skip() { exit 0 } +# +# For interop testing treate EOPNOTSUPP as success +# and skip +# +skip_eopnotsupp() { + local retstr=$@ + + echo $retstr | awk -F'|' '{print $1}' | + grep -E unsupported\|"(Operation not supported)" + (( $? == 0 )) || error "$retstr" + skip $retstr +} + build_test_filter() { EXCEPT="$EXCEPT $(testslist_filter)"