Skip to contentSkip to conversation

generic: regression test for refluxfs fixes

PATCH In review Darrick J. Wong 3 participants 11 messages Aug 21 – Sep 28

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 generic: regression test for refluxfs fixes

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits

---
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out
.gitignore +1 -0
index d52ba4ad30852b..b5d85c9451f0a8 100644
@@ -126,6 +126,7 @@ tags
 /src/pwrite_mmap_blocked
 /src/randholes
 /src/readdir-while-renames
+/src/refluxfs
 /src/rename
 /src/renameat2
 /src/resvtest
src/Makefile +1 -1
index 0ff607ae15930d..04a73b76546241 100644
@@ -36,7 +36,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	fscrypt-crypt-util bulkstat_null_ocount splice-test chprojid_fail \
 	detached_mounts_propagation ext4_resize t_readdir_3 splice2pipe \
 	uuid_ioctl t_snapshot_deleted_subvolume fiemap-fault min_dio_alignment \
-	rw_hint btrfs_ioctl
+	rw_hint btrfs_ioctl refluxfs
 
 EXTRA_EXECS = dmerror fill2attr fill2fs fill2fs_check scaleread.sh \
 	      btrfs_crc32c_forged_name.py popdir.pl popattr.py \
src/refluxfs.c new file +461 -0

461 lines not on this page · raw message

tests/generic/1956 new file +58 -0

58 lines not on this page · raw message

tests/generic/1956.out new file +2 -0
new file mode 100644
index 00000000000000..55d8be979b1486
@@ -0,0 +1,2 @@
+QA output created by 1956
+corruption not observed
#2 lore raw
In reply to Darrick J. Wong
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#3 lore raw
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

(FWIW it works fine on my system even with large block size)

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#4 lore raw
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#5 lore raw
Quoted 47 lines · Zorro Lang
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Quoted 3 lines

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Oh.

Quoted 7 lines
Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

It should on a 1k fsblock filesystem the kernel will just mash four blocks. Though I guess for a 64k fsblock filesystem it'll fall back to pagecache writes and fail to trigger it.

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

--D

Quoted 136 lines

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#6 lore raw
Quoted 62 lines · Darrick J. Wong
Quoted 47 lines · Zorro Lang
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Quoted 3 lines

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Oh.

Quoted 7 lines
Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

Quoted 7 lines

It should on a 1k fsblock filesystem the kernel will just mash four blocks. Though I guess for a 64k fsblock filesystem it'll fall back to pagecache writes and fail to trigger it.

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

I just reproduced it on XFS with a 1024 block size. Apologies for the delay, the reproduce rate on my side was quite low, so I ran it in a while true loop and finally triggered the bug (I'm still waiting for the 65536 blocksize xfs testing result).

Thanks,
Zorro

Quoted 140 lines

--D

Quoted 136 lines

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#7 lore raw
Quoted 67 lines · Zorro Lang
Quoted 66 lines · Darrick J. Wong
Quoted 47 lines · Zorro Lang
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Quoted 3 lines

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Oh.

Quoted 7 lines
Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

It should on a 1k fsblock filesystem the kernel will just mash four blocks. Though I guess for a 64k fsblock filesystem it'll fall back to pagecache writes and fail to trigger it.

Quoted 8 lines
Quoted 3 lines

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

I just reproduced it on XFS with a 1024 block size. Apologies for the delay, the reproduce rate on my side was quite low, so I ran it in a while true loop and finally triggered the bug (I'm still waiting for the 65536 blocksize xfs testing result).

Did that ever complete? I noticed this test hasn't been merged yet.

--D

Quoted 145 lines

Thanks,
Zorro

Quoted 140 lines

--D

Quoted 136 lines

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#8 lore raw
Quoted 72 lines · Darrick J. Wong
Quoted 71 lines · Zorro Lang
Quoted 69 lines · Darrick J. Wong
Quoted 47 lines · Zorro Lang
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Quoted 3 lines

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Oh.

Quoted 7 lines
Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

It should on a 1k fsblock filesystem the kernel will just mash four blocks. Though I guess for a 64k fsblock filesystem it'll fall back to pagecache writes and fail to trigger it.

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

Quoted 6 lines
Quoted 4 lines

I just reproduced it on XFS with a 1024 block size. Apologies for the delay, the reproduce rate on my side was quite low, so I ran it in a while true loop and finally triggered the bug (I'm still waiting for the 65536 blocksize xfs testing result).

Did that ever complete? I noticed this test hasn't been merged yet.

Hi Darrick,

64k can reproduce that bug. Just due to I saw your previous comment mentioned:

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

so I thought we were waiting on your next revision to tweak this patch for easier reproduction.

The current version looks good to me as well. I can help clean up the "#if 0" parts. If you don't have any further changes, I can merge this now.

Thanks,
Zorro

Quoted 149 lines

--D

Quoted 145 lines

Thanks,
Zorro

Quoted 140 lines

--D

Quoted 136 lines

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

Review

Quoted 8 lines
(quoted diff) +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
(quoted diff) +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

Review

Quoted 9 lines
(quoted diff) +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
(quoted diff) +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
(quoted diff) +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

Review

Quoted 10 lines
(quoted diff) +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
(quoted diff) +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

Review

Quoted 13 lines
(quoted diff) +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#9 lore raw
Quoted 88 lines · Zorro Lang
Quoted 72 lines · Darrick J. Wong
Quoted 71 lines · Zorro Lang
Quoted 69 lines · Darrick J. Wong
Quoted 47 lines · Zorro Lang
Quoted 40 lines · Darrick J. Wong
Quoted 31 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch
Quoted 7 lines

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126

Quoted 5 lines

126 is probably su trying to communicate that it couldn't actually run refluxfs. _require_test_program should have _notrun if the binary didn't build, so ... I don't know what's going on here. Does $seqres.full have anything interesting to say? Or does su'ing to fsgqa not work?

Quoted 3 lines

Wow, you reminded me! The /root/ directory doesn't has 'x' permission for others, so this $qa_user can't run /root/git/xfstests-dev/src/refluxfs . My bad, now it works :)

Oh.

Quoted 7 lines
Quoted 2 lines

(FWIW it works fine on my system even with large block size)

It's fine with large block size? In my review comments below, I questioned the hardcoded "BLK=4096". While it might not fail on an XFS with a non-4k block size, it probably won't trigger the bug either on an unfixed kernel, right?

It should on a 1k fsblock filesystem the kernel will just mash four blocks. Though I guess for a 64k fsblock filesystem it'll fall back to pagecache writes and fail to trigger it.

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

Quoted 6 lines
Quoted 4 lines

I just reproduced it on XFS with a 1024 block size. Apologies for the delay, the reproduce rate on my side was quite low, so I ran it in a while true loop and finally triggered the bug (I'm still waiting for the 65536 blocksize xfs testing result).

Did that ever complete? I noticed this test hasn't been merged yet.

Hi Darrick,

64k can reproduce that bug. Just due to I saw your previous comment mentioned:

I dunno. Changing BLK to 65536 seems to make it reproduce reliably here on every fsblock size between 1k and 64k so I'll make that modification and resend it.

Quoted 5 lines

so I thought we were waiting on your next revision to tweak this patch for easier reproduction.

The current version looks good to me as well. I can help clean up the "#if 0" parts. If you don't have any further changes, I can merge this now.

Oh, heh. Silly me, let me send the latest version in my tree.

--D

Quoted 152 lines

Thanks,
Zorro

Quoted 149 lines

--D

Quoted 145 lines

Thanks,
Zorro

Quoted 140 lines

--D

Quoted 136 lines

Thanks,
Zorro

Quoted 132 lines

--D

Quoted 128 lines

...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

Review

Quoted 8 lines
(quoted diff) +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

Quoted 8 lines
(quoted diff) +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

Review

Quoted 9 lines
(quoted diff) +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
(quoted diff) +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 4 lines
(quoted diff) +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

Review

Quoted 10 lines
(quoted diff) +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Quoted 4 lines
(quoted diff) +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

Review

Quoted 13 lines
(quoted diff) +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Thanks,
Zorro

#10 lore raw
In reply to Zorro Lang
Quoted 81 lines · Zorro Lang
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Regression test for refluxfs as found by Qualys.

---
v2: add co-author credits
---

Hi Darrick,

I just gave this patch a try on linux v7.2+ which contains the commit 2f4acd0fcd862e, but the test still fails as shown below on both xfs and btrfs. Did I miss anything?

root@bogon:~/git/linux# git tag --contains 2f4acd0fcd862e
v7.2
v7.2-rc4
v7.2-rc5
v7.2-rc6
v7.2-rc7
root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- xfs (debug)
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- -f /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:41:51.884222239 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)

HINT: You _MAY_ be missing kernel fix:
2f4acd0fcd862e xfs: resample the data fork mapping after cycling ILOCK

Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

root@bogon:~/git/xfstests-dev# ./check generic/1956
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 bogon 7.2.0-mainline+ #3 SMP PREEMPT_DYNAMIC Mon Aug 24 20:34:26 CST 2026
MKFS_OPTIONS  -- /dev/sdc1
MOUNT_OPTIONS -- -o context=system_u:object_r:root_t:s0 /dev/sdc1 /mnt/scratch

generic/1956 - output mismatch (see /root/git/xfstests-dev/results//generic/1956.out.bad)
--- tests/generic/1956.out 2026-08-24 14:19:18.790104900 +0800
+++ /root/git/xfstests-dev/results//generic/1956.out.bad 2026-08-24 21:44:35.654443414 +0800
@@ -1,2 +1,2 @@
QA output created by 1956
-corruption not observed
+unknown outcome 126
...
(Run 'diff -u /root/git/xfstests-dev/tests/generic/1956.out /root/git/xfstests-dev/results//generic/1956.out.bad' to see the entire diff)
Ran: generic/1956
Failures: generic/1956
Failed 1 of 1 tests

Quoted 10 lines
 .gitignore             |    1 
 src/Makefile           |    2 
 src/refluxfs.c         |  461 ++++++++++++++++++++++++++++++++++++++++++++++++
 tests/generic/1956     |   58 ++++++
 tests/generic/1956.out |    2 
 5 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 src/refluxfs.c
 create mode 100755 tests/generic/1956
 create mode 100644 tests/generic/1956.out

[snip]

Quoted 10 lines

src/refluxfs.c line 48

Quoted 8 lines
src/refluxfs.c new file +8 -0
+#ifndef FICLONE
+#define FICLONE _IOW(0x94, 9, int)
+#endif
+#ifndef XFS_SUPER_MAGIC
+#define XFS_SUPER_MAGIC 0x58465342
+#endif
+
+#define BLK 4096

This's a hard code, what if the fs blocksize or pagesize isn't 4096?

It reproduced the problem on 1k and 64k fsblocks before I'd patched the kernel. AFAICT "BLK" really just means the application buffer size for doing IO and doesn't actually have to match the fs blocksize.

Quoted 31 lines
Quoted 8 lines
src/refluxfs.c new file +8 -0
+
+/* ---- configuration (overridable via CLI) --------------------------------- */
+static const char *target_path   = "/etc/passwd";
+static const char *clone_dir     = "/var/tmp";
+static int         nr_writers    = 32;
+static int         nr_pressure   = 8;
+static int         budget_s      = 300;
+

[snip]

src/refluxfs.c line 127

Quoted 9 lines
src/refluxfs.c new file +9 -0
+
+#if 0
+static int is_xfs(const char *p)
+{
+    struct statfs s;
+    if (statfs(p, &s)) return -1;
+    return s.f_type == XFS_SUPER_MAGIC;
+}
+#endif

If this's useless, how about remove them?

Quoted 5 lines
src/refluxfs.c new file +5 -0
+
+/* FIEMAP: is the target's first extent already shared (refcount > 1)?
+ * If so the race can never see refcount==1. */
+static int target_first_extent_shared(void)
+{

[snip]

Quoted 16 lines
Quoted 4 lines
src/refluxfs.c new file +4 -0
+#if 0
+    /* 2. target on XFS */
+    int x = is_xfs(target_path);
+    if (x < 0) die(1, "statfs target", NULL);

src/refluxfs.c line 197

Quoted 10 lines
src/refluxfs.c new file +10 -0
+    if (!x) {
+        BAD("target is not on XFS (f_type != XFS_SUPER_MAGIC).");
+        INFO("RefluXFS only affects XFS with reflink=1 (mkfs.xfs default since");
+        INFO("xfsprogs 5.1.0; backported by Red Hat for RHEL 8 GA).  Default root");
+        INFO("fs on RHEL/CentOS/Rocky/Alma/OL/CloudLinux 8+, Fedora Server 31+,");
+        INFO("Amazon Linux 2023.");
+        exit(1);
+    }
+    OK("target is on XFS");
+#endif

Same

Will remove both of these dead code sections.

Quoted 7 lines
Quoted 4 lines
src/refluxfs.c new file +4 -0
+
+    /* 3. clone_dir on the same superblock */
+    if (access(clone_dir, W_OK)) die(1, "clone dir not writable",
+        "Need a writable directory on the SAME XFS filesystem as the target.");

[snip]

Quoted 16 lines

src/refluxfs.c line 336

Quoted 13 lines
src/refluxfs.c new file +13 -0
+static void *pressure(void *arg)
+{
+    char p[600];
+    snprintf(p, sizeof p, "%s/press.%d", workdir, (int)(intptr_t)arg);
+    int fd = open(p, O_RDWR|O_CREAT|O_TRUNC, 0600);
+    if (fd < 0) return NULL;
+    char b = 0;
+    while (!atomic_load(&stop)) {
+        /* return values irrelevant -- goal is XFS log traffic, not the data */
+        (void)!pwrite(fd, &b, 1, 0);
+        (void)!ftruncate(fd, BLK);
+        fdatasync(fd);
+        (void)!ftruncate(fd, 0);

As this's a generic test case, the pressure() works for XFS CIL, does it work for other filesystems?

Neither of them (btrfs, ocfs2) are vulnerable to this problem because they don't have the design flaw in the first place. So I don't know how to answer that question.

It's probably not necessary to run this testcase against other filesystems but as there's nothing xfs-specific in the test case, why not let them run on the others?

--D