summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaohiro Aota <naohiro.aota@wdc.com>2023-09-21 18:41:58 +0900
committerZorro Lang <zlang@kernel.org>2023-09-23 02:24:07 +0800
commit150670eb921647fb02b4faea0d45c394ffe8aef8 (patch)
tree5d5aa3e957adeba7aa37aa3f6b3ae6a8ab6f770e
parente3121832fc2ba3447662ad8821c99c548aa53de9 (diff)
btrfs/239: call fsync to create tree-log dedicated block group for zoned mode
Running btrfs/239 on a zoned device often fails with the following error. btrfs/239 5s ... - output mismatch (see /host/btrfs/239.out.bad) --- tests/btrfs/239.out 2023-09-21 16:56:37.735204924 +0900 +++ /host/btrfs/239.out.bad 2023-09-21 18:22:45.401433408 +0900 @@ -1,4 +1,6 @@ QA output created by 239 +/testdir/dira still exists +/dira does not exists File SCRATCH_MNT/testdir/file1 data: 0000000 ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab * ... This happens because "testdir" and "dira" are not logged on the first fsync (fsync $SCRATCH_MNT/testdir), but are written as a full commit. That prevents updating the log on "mv" time, leaving them pre-mv state. The full commit is induced by the creation of a new block group. On the zoned mode, we use a dedicated block group for tree-log. That block group is created on-demand or assigned to a metadata block group if there is none. On the first mount of a file system, we need to create one because there is only one metadata block group available for the regular metadata. That creation of a new block group forces tree-log to be a full commit on that transaction, which prevents logging "testdir" and "dira". Fix the issue by calling fsync before the first "sync", which creates the dedicated block group and let the files be properly logged. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-xtests/btrfs/23912
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/btrfs/239 b/tests/btrfs/239
index 3fbeaedd..5a2dbe58 100755
--- a/tests/btrfs/239
+++ b/tests/btrfs/239
@@ -83,6 +83,18 @@ done
#
mkdir $SCRATCH_MNT/testdir/dira
+# This fsync is for the zoned mode. On the zoned mode, we use a dedicated block
+# group for tree-log. That block group is created on-demand or assigned to a
+# metadata block group if there is none. On the first mount of a file system, we
+# need to create one because there is only one metadata block group available
+# for the regular metadata. That creation of a new block group forces tree-log
+# to be a full commit on that transaction, which prevents logging "testdir" and
+# "dira" and screws up the result.
+#
+# Calling fsync here will create the dedicated block group, and let them be
+# logged.
+$XFS_IO_PROG -c "fsync" $SCRATCH_MNT
+
# Make sure everything done so far is durably persisted.
sync