Re: [PATCH] fstests: btrfs/340: add support for older kernels/progs

Zorro Lang <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-btrfs
Message-ID <agdMkn0SyWLZsj3h@zlang-mailbox>
On Thu, May 14, 2026 at 03:25:02PM +0930, Qu Wenruo wrote:
> The test case will fail on older distros like SLE12-SP5, there are two
> problems on the test case itself:
> 
> - Requires "--sync" option from "btrfs qgroup show" subcommand
>   That option was introduecd in v4.9.1, thus there are still some older
>   distros using that very old version.
> 
> - Not all kernels support quick inherit
>   The kernel commit introducing the quick inherit is 6.9, thus some
>   supported LTS kernels do not have that commit.
> 
>   In that case qgroup will just be marked inconsistent, this will cause
>   the later "btrfs qgroup show" command to output a warning due to the
>   inconsistent flag.
> 
> Fix both problems by:
> 
> - Require "--sync" option from "btrfs qgroup show" subcommand
>   So older distros will just skip the test.
> 
> - Redirect all output from "btrfs qgroup show" to $seqres.full
>   So older kernels can still pass the test case by marking qgroup
>   inconsitent.
> 
> Reported-by: Long An <[email protected]>
> Signed-off-by: Qu Wenruo <[email protected]>
> ---
>  tests/btrfs/340 | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/btrfs/340 b/tests/btrfs/340
> index 872f790cb975..fc0b8d48adaa 100755
> --- a/tests/btrfs/340
> +++ b/tests/btrfs/340
> @@ -39,7 +39,14 @@ _btrfs qgroup show -p --sync $SCRATCH_MNT >> $seqres.full
>  # without marking qgroup inconsistent.
>  _btrfs subv snap -i 1/1 $SCRATCH_MNT/subv1 $SCRATCH_MNT/snap1
>  echo "After quick inherit:" >> $seqres.full
> -_btrfs qgroup show -p --sync $SCRATCH_MNT >> $seqres.full
> +# Sync the fs so that the qgroup numbers are properly updated.
> +_btrfs filesystem sync $SCRATCH_MNT

Just out of curiosity, `sync $SCRATCH_MNT` can achieve the same effect here, right?
Regardless, it definitely makes more sense to use Btrfs's own sync command in this
context.

Reviewed-by: Zorro Lang <[email protected]>

> +
> +# Redirect all output to seqres.full including stderr.
> +# For older kernels without quick inherit support, it will mark
> +# qgroup inconsistent, which can pollute the golden output.
> +# Here we rely on the final btrfs check to catch any qgroup number errors.
> +_btrfs qgroup show -p $SCRATCH_MNT >> $seqres.full
>  
>  echo "Silence is golden"
>  _exit 0
> -- 
> 2.54.0
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.