Skip to contentSkip to conversation

generic/798: exclude nfs from cachestat dirty page reporting test

PATCH In review Avinesh Kumar 4 participants 9 messages Aug 24 – Aug 26

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/798: exclude nfs from cachestat dirty page reporting test

From: Avinesh Kumar <[email protected]>

generic/798 checks cachestat() page cache dirty state between write and fsync operations.

On NFS, the client flushes dirty pages to the server during close() to enforce its close-to-open consistency model. Because the test uses separate xfs_io invocations, the file is closed after writing, leaving pages already clean by the time the subsequent cachestat command executes, causing the test to fail.

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...

Exclude 'nfs' from running this test.

---
 tests/generic/798 | 6 ++++++
 1 file changed, 6 insertions(+)
tests/generic/798 +6 -0
index 0fe37646..80b2acc9 100755
@@ -16,6 +16,12 @@ _require_scratch
 _exclude_scratch_mount_option "dax"
 _exclude_scratch_mount_option "sync"
 
+# NFS flushes dirty data back to the server on close() as part of its
+# close-to-open cache consistency model, so a page written and closed in
+# one xfs_io invocation is no longer dirty by the time cachestat runs in
+# a later invocation.
+_exclude_fs nfs
+
 pagesize=$(_get_page_size)
 
 _scratch_mkfs > /dev/null
Signature · 1 line
2.55.0
#1 lore raw
Quoted 36 lines · Avinesh Kumar

From: Avinesh Kumar <[email protected]>

generic/798 checks cachestat() page cache dirty state between write and fsync operations.

On NFS, the client flushes dirty pages to the server during close() to enforce its close-to-open consistency model. Because the test uses separate xfs_io invocations, the file is closed after writing, leaving pages already clean by the time the subsequent cachestat command executes, causing the test to fail.

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...

Exclude 'nfs' from running this test.

---
 tests/generic/798 | 6 ++++++
 1 file changed, 6 insertions(+)
tests/generic/798 +0 -0
index 0fe37646..80b2acc9 100755

tests/generic/798 _require_scratch · line 23

Quoted 8 lines
tests/generic/798 +5 -0
@@ -16,6 +16,12 @@ _require_scratch
 _exclude_scratch_mount_option "dax"
 _exclude_scratch_mount_option "sync"
 
+# NFS flushes dirty data back to the server on close() as part of its
+# close-to-open cache consistency model, so a page written and closed in
+# one xfs_io invocation is no longer dirty by the time cachestat runs in
+# a later invocation.
+_exclude_fs nfs

Could you just chain all the xfs_io commands together into a single invocation?

$XFS_IO_PROG -f \
	-c "pwrite -b $pagesize 0 $size" \
	-c "cachestat 0 $size" \
	-c "fsync" \
	-c "cachestat 0 $size" \
	$SCRATCH_MNT/foobar

to solve this problem?

--D

Quoted 8 lines
tests/generic/798 +1 -0
+
 pagesize=$(_get_page_size)
 
 _scratch_mkfs > /dev/null
Signature · 1 line
2.55.0
#2 lore raw

Hello Darrick,

Quoted 17 lines

tests/generic/798 _require_scratch · line 23

Quoted 13 lines
tests/generic/798 +5 -0
index 0fe37646..80b2acc9 100755
@@ -16,6 +16,12 @@ _require_scratch
  _exclude_scratch_mount_option "dax"
  _exclude_scratch_mount_option "sync"
 
+# NFS flushes dirty data back to the server on close() as part of its
+# close-to-open cache consistency model, so a page written and closed in
+# one xfs_io invocation is no longer dirty by the time cachestat runs in
+# a later invocation.
+_exclude_fs nfs

Could you just chain all the xfs_io commands together into a single invocation?

Quoted 9 lines
$XFS_IO_PROG -f \
	-c "pwrite -b $pagesize 0 $size" \
	-c "cachestat 0 $size" \
	-c "fsync" \
	-c "cachestat 0 $size" \
	$SCRATCH_MNT/foobar

to solve this problem?

Thanks for the review and this suggestion. Chaining all xfs_io commands together seems to work, with also passing '-q' to pwrite to suppress these lines -

    +wrote 4096/4096 bytes at offset 0
    +4 KiB, 1 ops; 0.0000 sec (355.114 MiB/sec and 90909.0909 ops/sec)

I am sending revised patch.

Regards,
Avinesh

#3 lore raw

PATCH v2 1/1 generic/798: chain xfs_io commands into a single invocation

In reply to Darrick J. Wong

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

---
 tests/generic/798 | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tests/generic/798 +14 -4
index 0fe37646..171878ee 100755
@@ -27,12 +27,22 @@ for num_page in 1 2 4 8 16; do
 	echo "=== Test with $num_page pages ==="
 
 	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
 	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+		$XFS_IO_PROG -f \
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
 done
 
 _scratch_unmount
Signature · 1 line
2.55.0
#4 lore raw

Re: [PATCH v2] generic/798: chain xfs_io commands into a single invocation

Quoted 42 lines · Avinesh Kumar

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

---
 tests/generic/798 | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
tests/generic/798 +0 -4
index 0fe37646..171878ee 100755
@@ -27,12 +27,22 @@ for num_page in 1 2 4 8 16; do
 	echo "=== Test with $num_page pages ==="
 
 	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.

tests/generic/798 for num_page in 1 2 4 8 16; do · line 40

Quoted 10 lines
tests/generic/798 +9 -0
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
 	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+		$XFS_IO_PROG -f \

Not sure why there are two $XFS_IO_PROG invocations here??

Also the first line of the second invocation should only be indented one tab, not two.

--D

Quoted 12 lines
tests/generic/798 +5 -0
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
 done
 
 _scratch_unmount
Signature · 1 line
2.55.0
#5 lore raw

PATCH v3 1/1 generic/798: chain xfs_io commands into a single invocation

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

---
 tests/generic/798 | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
tests/generic/798 +14 -5
index 0fe37646..5c81b429 100755
@@ -27,12 +27,21 @@ for num_page in 1 2 4 8 16; do
 	echo "=== Test with $num_page pages ==="
 
 	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.
-	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
+	$XFS_IO_PROG -f \
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
 done
 
 _scratch_unmount
Signature · 1 line
2.55.0
Reviewed-by on v3 1/1
#6 lore raw

Re: [PATCH v3] generic/798: chain xfs_io commands into a single invocation

Quoted 20 lines · Avinesh Kumar

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...
Quoted 5 lines

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

Looks good now!

--D

Quoted 39 lines
---
 tests/generic/798 | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
tests/generic/798 +14 -5
index 0fe37646..5c81b429 100755
@@ -27,12 +27,21 @@ for num_page in 1 2 4 8 16; do
 	echo "=== Test with $num_page pages ==="
 
 	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.
-	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
+	$XFS_IO_PROG -f \
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
 done
 
 _scratch_unmount
Signature · 1 line
2.55.0
Reviewed-by on v3 1/1
#7 lore raw

Re: [PATCH v3] generic/798: chain xfs_io commands into a single invocation

In reply to Avinesh Kumar
Quoted 20 lines · Avinesh Kumar

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

    --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
    +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
    @@ -1,16 +1,16 @@
     QA output created by 798
     === Test with 1 pages ===
    -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
    +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
     === Test with 2 pages ===
    -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
    ...
Quoted 6 lines

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

---

This change is good to me,

Quoted 38 lines
 tests/generic/798 | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
tests/generic/798 +14 -5
index 0fe37646..5c81b429 100755
@@ -27,12 +27,21 @@ for num_page in 1 2 4 8 16; do
 	echo "=== Test with $num_page pages ==="
 
 	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.
-	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
+	$XFS_IO_PROG -f \
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
 done
 
 _scratch_unmount
Signature · 1 line
2.55.0
Reviewed-by on v3 1/1
#8 lore raw

Re: [PATCH v3] generic/798: chain xfs_io commands into a single invocation

In reply to Avinesh Kumar
Quoted 20 lines · Avinesh Kumar

From: Avinesh Kumar <[email protected]>

The write, cachestat, fsync, and cachestat calls were each run as separate xfs_io invocations, closing and reopening the file in between. Some filesystems flush dirty data back on close(), clearing the dirty bit before the first cachestat ever ran, causing test failure

- output mismatch (see /opt/xfstests/results//generic/798.out.bad)

     --- tests/generic/798.out	2026-08-20 05:25:39.000000000 -0400
     +++ /opt/xfstests/results//generic/798.out.bad	2026-08-21 12:30:39.831381108 -0400
     @@ -1,16 +1,16 @@
      QA output created by 798
      === Test with 1 pages ===
     -Cached: 1, Dirty: 1, Writeback: 0, Evicted: 0, Recently Evicted: 0
     +Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
      Cached: 1, Dirty: 0, Writeback: 0, Evicted: 0, Recently Evicted: 0
      === Test with 2 pages ===
     -Cached: 2, Dirty: 2, Writeback: 0, Evicted: 0, Recently Evicted: 0
     ...
Quoted 5 lines

Run the whole sequence on one open file descriptor instead by chaining all xfs_io commands in single invocation.

Thanks,
Qu

Quoted 35 lines
---
  tests/generic/798 | 19 ++++++++++++++-----
  1 file changed, 14 insertions(+), 5 deletions(-)
tests/generic/798 +14 -5
index 0fe37646..5c81b429 100755
@@ -27,12 +27,21 @@ for num_page in 1 2 4 8 16; do
  	echo "=== Test with $num_page pages ==="
 
  	rm -f $SCRATCH_MNT/foobar
-	$XFS_IO_PROG -f -c "pwrite -b $pagesize 0 $size" $SCRATCH_MNT/foobar > /dev/null
-	# Basic cached number reporting
-	$XFS_IO_PROG -c "cachestat 0 $size" $SCRATCH_MNT/foobar
 
-	# Test dirty page number reporting after a fsync.
-	$XFS_IO_PROG -c "fsync" -c "cachestat 0 $size" $SCRATCH_MNT/foobar
+	# Basic cached number reporting and test dirty page number
+	# reporting after a fsync.
+	#
+	# Do the whole write+cachestat+fsync+cachestat sequence in a
+	# single xfs_io invocation. Some filesystems (e.g. NFS) flush
+	# dirty data back to the server as part of their own close()-time
+	# cache consistency, which would clear the dirty bits before the
+	# second xfs_io process ever got to run cachestat.
+	$XFS_IO_PROG -f \
+		-c "pwrite -q -b $pagesize 0 $size" \
+		-c "cachestat 0 $size" \
+		-c "fsync" \
+		-c "cachestat 0 $size" \
+		$SCRATCH_MNT/foobar
  done
 
  _scratch_unmount