From 5ad69eae24a4f1a6bc02a9fa9d66b0ed1a57fe84 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Mon, 14 Feb 2022 15:32:08 +0530 Subject: [PATCH] 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,sanityn,sanity-benchmark,sanity-flr,sanity-quota,sanity-dom,parallel-scale-cifs Fixes: 48457868a02a ("LU-3606 fallocate: Implement fallocate preallocate operation") Signed-off-by: arshad.hussain@aeoncomputing.com Change-Id: Id203c0b9abbdd674af33f1f78e81ae7fe105e90f --- lustre/ofd/ofd_dev.c | 5 ++++- lustre/tests/sanity-flr.sh | 2 +- lustre/tests/sanity.sh | 26 +++++++++++++++----------- lustre/tests/test-framework.sh | 13 +++++++++++++ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index c0914a6..126d8a7 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -1990,7 +1990,10 @@ static int ofd_fallocate_hdl(struct tgt_session_info *tsi) */ if ((oa->o_valid & (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) != (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS)) - RETURN(err_serious(-EPROTO)); + /* Return -EOPNOTSUPP to also handle older + * clients not supporting newer server modes + */ + 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 c267697..43a5b1f 100644 --- a/lustre/tests/sanity-flr.sh +++ b/lustre/tests/sanity-flr.sh @@ -2718,7 +2718,7 @@ 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" + skip_eopnotsupp "punch hole in $tf failed" verify_flr_state $tf "wp" fi diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d37c6b5e..3787ce3 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14645,7 +14645,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" @@ -14656,7 +14656,8 @@ test_150bb() { stack_trap "rm -f $DIR/$tfile; wait_delete_completed" dd if=/dev/urandom of=$DIR/$tfile bs=1M count=20 || error "dd failed" > $DIR/$tfile - fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed" + fallocate -l $((1048576 * 20)) $DIR/$tfile || + skip_eopnotsupp "fallocate failed" # precomputed md5sum for 20MB of zeroes local expect="8f4e33f3dc3e414ff94e5fb6905cba8c" local sum=($(md5sum $DIR/$tfile)) @@ -14666,7 +14667,8 @@ test_150bb() { check_set_fallocate 1 > $DIR/$tfile - fallocate -l $((1048576 * 20)) $DIR/$tfile || error "fallocate failed" + fallocate -l $((1048576 * 20)) $DIR/$tfile || + skip_eopnotsupp "fallocate failed" sum=($(md5sum $DIR/$tfile)) [[ "${sum[0]}" == "$expect" ]] || error "fallocate zero is not zero" @@ -14679,7 +14681,8 @@ test_150c() { stack_trap "rm -f $DIR/$tfile; wait_delete_completed" $LFS setstripe -c $OSTCOUNT -S1M $DIR/$tfile || error "setstripe failed" - fallocate -l ${OSTCOUNT}m $DIR/$tfile || error "fallocate failed" + fallocate -l ${OSTCOUNT}m $DIR/$tfile || + skip_eopnotsupp "fallocate failed" local bytes=$(($(stat -c '%b * %B' $DIR/$tfile))) local want=$((OSTCOUNT * 1048576)) @@ -14696,7 +14699,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" + skip_eopnotsupp "fallocate failed" bytes=$(($(stat -c '%b * %B' $DIR/$tfile))) want=$((512 * 1048576)) @@ -14715,7 +14718,8 @@ test_150d() { stack_trap "rm -f $DIR/$tfile; wait_delete_completed" $LFS setstripe -E1M $striping -E eof -c $OSTCOUNT -S1M $DIR/$tdir || error "setstripe failed" - fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || error "fallocate failed" + fallocate -o 1G -l ${OSTCOUNT}m $DIR/$tdir || + skip_eopnotsupp "fallocate failed" local bytes=$(($(stat -c '%b * %B' $DIR/$tdir))) local want=$((OSTCOUNT * 1048576)) @@ -14747,7 +14751,7 @@ test_150e() { fi fallocate -l${space}k $DIR/$tfile || - error "fallocate ${space}k $DIR/$tfile failed" + skip_eopnotsupp "fallocate ${space}k $DIR/$tfile failed" echo "'fallocate -l ${space}k $DIR/$tfile' succeeded" # get size immediately after fallocate. This should be correctly @@ -14801,7 +14805,7 @@ test_150f() { # 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" + skip_eopnotsupp "fallocate failed: offset 4096 and length $length" # client must see changes immediately after fallocate size=$(stat -c '%s' $DIR/$tfile) blocks=$(stat -c '%b' $DIR/$tfile) @@ -14832,7 +14836,7 @@ test_150f() { # Punch overlaps two blocks and less than blocksize fallocate -p --offset 4000 -l 3000 $DIR/$tfile || - error "fallocate failed: offset 4000 length 3000" + skip_eopnotsupp "fallocate failed: offset 4000 length 3000" size=$(stat -c '%s' $DIR/$tfile) blocks=$(stat -c '%b' $DIR/$tfile) @@ -14894,7 +14898,7 @@ test_150g() { echo "Verify fallocate punch: Very large Range" fallocate -l${space}k $DIR/$tfile || - error "fallocate ${space}k $DIR/$tfile failed" + skip_eopnotsupp "fallocate ${space}k $DIR/$tfile failed" # write 1M at the end, start and in the middle yes 'A' | dd of=$DIR/$tfile bs=$BS count=256 || error "dd failed: bs $BS count 256" @@ -14917,7 +14921,7 @@ test_150g() { # 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" + skip_eopnotsupp "fallocate failed: 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..1a05ac0 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 EOPNOTSUPP=95 + local skip_str="Operation Not Supported" + local retval=$? + + (( $retval == $EOPNOTSUPP )) || error "$@" + skip $skip_str +} + build_test_filter() { EXCEPT="$EXCEPT $(testslist_filter)" -- 1.8.3.1