public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-nfs@vger.kernel.org
Subject: Re: [PATCH v2] nfs: test files written size as expected
Date: Wed, 2 Aug 2023 09:36:40 -0700	[thread overview]
Message-ID: <20230802163640.GY11352@frogsfrogsfrogs> (raw)
In-Reply-To: <20230802054646.2197854-1-zlang@kernel.org>

On Wed, Aug 02, 2023 at 01:46:46PM +0800, Zorro Lang wrote:
> Test nfs and its underlying fs, make sure file size as expected
> after writting a file, and the speculative allocation space can
> be shrunken.
> 
> Signed-off-by: Zorro Lang <zlang@kernel.org>
> ---
> 
> Last year I sent a patch to fstests@, but it sometimes fails on the upstream
> kernel that year:
> 
>   https://lore.kernel.org/fstests/Y3vTbHqT64gsQ573@magnolia/
> 
> And we didn't get a proper reason for that, so that patch was blocked. Now
> I found this case test passed on current upstream linux [1] (after loop
> running it a whole night). So I think it's time to rebase and re-send this
> patch to get review.
> 
> Thanks,
> Zorro
> 
> [1]
> FSTYP         -- nfs
> PLATFORM      -- Linux/x86_64 xxxx 6.5.0-rc4 #1 SMP PREEMPT_DYNAMIC Tue Aug  1 15:32:55 EDT 2023
> MKFS_OPTIONS  -- xxxx.redhat.com:/mnt/xfstests/scratch/nfs-server
> MOUNT_OPTIONS -- -o vers=4.2 -o context=system_u:object_r:root_t:s0 xxxx.redhat.com:/mnt/xfstests/scratch/nfs-server /mnt/xfstests/scratch/nfs-client
> 
> nfs/002 4s ...  4s
> Ran: nfs/002
> Passed all 1 tests
> 
>  tests/nfs/002     | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  tests/nfs/002.out |  2 ++
>  2 files changed, 48 insertions(+)
>  create mode 100755 tests/nfs/002
>  create mode 100644 tests/nfs/002.out
> 
> diff --git a/tests/nfs/002 b/tests/nfs/002
> new file mode 100755
> index 00000000..b4b6554c
> --- /dev/null
> +++ b/tests/nfs/002
> @@ -0,0 +1,46 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2023 Red Hat, Inc.  All Rights Reserved.
> +#
> +# FS QA Test 002
> +#
> +# Make sure nfs gets expected file size after writting a big sized file. It's
> +# not only testing nfs, test its underlying fs too. For example a known old bug
> +# on xfs (underlying fs) caused nfs get larger file size (e.g. 16M) after
> +# writting 10M data to a file. It's fixed by a series of patches around
> +# 579b62faa5fb16 ("xfs: add background scanning to clear eofblocks inodes")

Er... has this been banging around in the trunk for 11 years? ;)

> +#
> +. ./common/preamble
> +_begin_fstest auto quick rw
> +
> +# real QA test starts here
> +_supported_fs nfs
> +# Need a series of patches related with this patch
> +_fixed_by_kernel_commit 579b62faa5fb16 \
> +	"xfs: add background scanning to clear eofblocks inodes"
> +_require_test
> +
> +localfile=$TEST_DIR/testfile.$seq
> +rm -rf $localfile
> +
> +$XFS_IO_PROG -f -t -c "pwrite 0 10m" -c "fsync" $localfile >>$seqres.full 2>&1
> +block_size=`stat -c '%B' $localfile`
> +iblocks_expected=$((10 * 1024 * 1024 / $block_size))
> +# Try several times for the speculative allocated file size can be shrunken
> +res=1
> +for ((i=0; i<10; i++));do
> +	iblocks_real=`stat -c '%b' $localfile`
> +	if [ "$iblocks_expected" = "$iblocks_real" ];then

What happens if real < expected?  Should there be some sort of bail out
for unexpected things like that?

> +		res=0
> +		break
> +	fi
> +	sleep 10
> +done

Though I guess the runtime is capped at ~100s so maybe it doesn't
matter practically.

(What happens if xfs blockgc only runs every 5 minutes?)

--D

> +if [ $res -ne 0 ];then
> +	echo "Write $iblocks_expected blocks, but get $iblocks_real blocks"
> +fi
> +
> +echo "Silence is golden"
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/nfs/002.out b/tests/nfs/002.out
> new file mode 100644
> index 00000000..61705c7c
> --- /dev/null
> +++ b/tests/nfs/002.out
> @@ -0,0 +1,2 @@
> +QA output created by 002
> +Silence is golden
> -- 
> 2.40.1
> 

  reply	other threads:[~2023-08-02 16:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02  5:46 [PATCH v2] nfs: test files written size as expected Zorro Lang
2023-08-02 16:36 ` Darrick J. Wong [this message]
2023-08-02 17:24   ` Zorro Lang
2023-08-02 17:43     ` Darrick J. Wong
2023-08-02 19:25       ` Zorro Lang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230802163640.GY11352@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox