From: Anand Suveer Jain <asj@kernel.org>
To: Qu Wenruo <wqu@suse.com>,
fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] fstests: generic: add a basic cachestat test case
Date: Tue, 7 Jul 2026 19:09:30 +0800 [thread overview]
Message-ID: <43a58866-1bb4-474a-a4da-d5cae5ff02f3@kernel.org> (raw)
In-Reply-To: <20260707001807.31931-1-wqu@suse.com>
On 7/7/26 08:18, Qu Wenruo wrote:
> The test case is inspired by LTP, where there is a regression on 64K
> page size systems with btrfs, that after a fsync, cachestat() still
> report dirty pages.
>
> The test case itself is pretty simple, fill the file with a buffered write that is
> 1/2/4/8/16 page sized, call cachestat() to make sure the cached/dirtied
> number match the page number.
>
> Then do a fsync(), and make sure the dirty page number reduced to 0
> meanwhile cached is still the same.
>
> Link: https://bugzilla.suse.com/show_bug.cgi?id=1270397
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> tests/generic/798 | 57 +++++++++++++++++++++++++++++++++++++++++++
> tests/generic/798.out | 2 ++
> 2 files changed, 59 insertions(+)
> create mode 100755 tests/generic/798
> create mode 100644 tests/generic/798.out
>
> diff --git a/tests/generic/798 b/tests/generic/798
> new file mode 100755
> index 00000000..4328475e
> --- /dev/null
> +++ b/tests/generic/798
> @@ -0,0 +1,57 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 SUSE S.A. All Rights Reserved.
> +#
> +# FS QA Test 798
> +#
> +# Basic tests for cachestate()
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +_require_xfs_io_command "cachestat"
> +_require_scratch
> +
> +pagesize=$(_get_page_size)
> +
> +for num_page in 1 2 4 8 16; do
> + size=$(($pagesize * $num_page))
> +
> + echo "=== Test with $num_page pages ===" >> $seqres.full
> + _scratch_mkfs > /dev/null
> + _scratch_mount
> +
> + # Basic cached number reporting
> + $XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" \
> + $SCRATCH_MNT/foobar >> $seqres.full
> + $XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar > $tmp.output
> + cat $tmp.output >> $seqres.full
> + cached=$(cat $tmp.output | cut -f1 -d, | awk '{print $2}')
> + dirtied=$(cat $tmp.output | cut -f2 -d, | awk '{print $2}')
> +
> + if [ "$cached" -ne "$num_page" ]; then
> + _fail "cached not matching the page number"
> + fi
> +
> + if [ "$cached" -ne "$dirtied" ]; then
> + _fail "dirited not matching the page number"
> + fi
> + $XFS_IO_PROG -c "fsync" $SCRATCH_MNT/foobar >> $seqres.full
> +
> + # Test dirty page number reporting after a fsync.
> + $XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar > $tmp.output
> + cat $tmp.output >> $seqres.full
> + _scratch_unmount
> + cached=$(cat $tmp.output | cut -f1 -d, | awk '{print $2}')
> + dirtied=$(cat $tmp.output | cut -f2 -d, | awk '{print $2}')
> +
> + if [ "$cached" -ne "$num_page" ]; then
> + _fail "cached not matching the page number"
> + fi
> + if [ "$dirtied" -ne 0 ]; then
> + _fail "dirtied pages not zero"
> + fi
> +done
> +
> +echo "Silence is golden"
> +_exit 0
> diff --git a/tests/generic/798.out b/tests/generic/798.out
> new file mode 100644
> index 00000000..216d6e93
> --- /dev/null
> +++ b/tests/generic/798.out
> @@ -0,0 +1,2 @@
> +QA output created by 798
> +Silence is golden
Nice.
Reviewed-by: Anand Jain <asj@kernel.org>
Thanks
next prev parent reply other threads:[~2026-07-07 11:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 0:18 [PATCH] fstests: generic: add a basic cachestat test case Qu Wenruo
2026-07-07 11:09 ` Anand Suveer Jain [this message]
2026-07-07 11:17 ` Filipe Manana
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=43a58866-1bb4-474a-a4da-d5cae5ff02f3@kernel.org \
--to=asj@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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