Skip to contentSkip to conversation

Btrfs-progs: add fsck test for filesystem with shared prealloc extents

PATCH Superseded [email protected] 3 participants 5 messages Mar 13, 2018 – Mar 19, 2018 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Btrfs-progs: add fsck test for filesystem with shared prealloc extents

From: Filipe Manana <[email protected]>

Verify that a filesystem check operation (fsck) does not report the following scenario as an error:

An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent.

Such scenario can be created with the following steps for example:

mkfs.btrfs -f /dev/sdb
mount /dev/sdb /mnt

touch /mnt/foo
xfs_io -c "falloc 0 256K" /mnt/foo
sync

xfs_io -c "pwrite -S 0xab -b 0 256K" /mnt/foo
touch /mnt/bar
xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
xfs_io -c "fsync" /mnt/bar

<power fail>
mount /dev/sdb /mnt
umount /mnt

This scenario is fixed by the following patch for the filesystem checker:

"Btrfs-progs: check, fix false error reports for shared prealloc extents"

---
 .../reflinked-prealloc-extents.img.xz              | Bin 0 -> 3244 bytes
 .../030-reflinked-prealloc-extents/test.sh         |  42 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz
 create mode 100755 tests/fsck-tests/030-reflinked-prealloc-extents/test.sh
tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e
GIT binary patch
tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.11.0
Reviewed-by on v1 2/2
#1 lore raw
Quoted 34 lines · On 2018年03月14日 02:47, [email protected] wrote:

From: Filipe Manana <[email protected]>

Verify that a filesystem check operation (fsck) does not report the following scenario as an error:

An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent.

Such scenario can be created with the following steps for example:

mkfs.btrfs -f /dev/sdb
mount /dev/sdb /mnt

touch /mnt/foo
xfs_io -c "falloc 0 256K" /mnt/foo
sync

xfs_io -c "pwrite -S 0xab -b 0 256K" /mnt/foo
touch /mnt/bar
xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
xfs_io -c "fsync" /mnt/bar

<power fail>
mount /dev/sdb /mnt
umount /mnt

Quoted 5 lines

This scenario is fixed by the following patch for the filesystem checker:

"Btrfs-progs: check, fix false error reports for shared prealloc extents"

Checked the image manually, looks good.

Thanks,
Qu

Quoted 128 lines
---
 .../reflinked-prealloc-extents.img.xz              | Bin 0 -> 3244 bytes
 .../030-reflinked-prealloc-extents/test.sh         |  42 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz
 create mode 100755 tests/fsck-tests/030-reflinked-prealloc-extents/test.sh
tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e
GIT binary patch
tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file +42 -0
new file mode 100755
index 00000000..4d3ef7da
@@ -0,0 +1,42 @@
+#!/bin/bash
+#
+# Verify that a filesystem check operation (fsck) does not report the following
+# scenario as an error:
+#
+# An extent is shared between two inodes, as a result of clone/reflink operation,
+# and for one of the inodes, lets call it inode A, the extent is referenced
+# through a file extent item as a prealloc extent, while for the other inode,
+# call it inode B, the extent is referenced through a regular file extent item,
+# that is, it was written to. The goal of this test is to make sure a filesystem
+# check operation will not report "odd csum items" errors for the prealloc
+# extent at inode A, because this scenario is valid since the extent was written
+# through inode B and therefore it is expected to have checksum items in the
+# filesystem's checksum btree for that shared extent.
+#
+# Such scenario can be created with the following steps for example:
+#
+# mkfs.btrfs -f /dev/sdb
+# mount /dev/sdb /mnt
+#
+# touch /mnt/foo
+# xfs_io -c "falloc 0 256K" /mnt/foo
+# sync
+#
+# xfs_io -c "pwrite -S 0xab -b 0 256K" /mnt/foo
+# touch /mnt/bar
+# xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
+# xfs_io -c "fsync" /mnt/bar
+#
+# <power fail>
+# mount /dev/sdb /mnt
+# umount /mnt
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_check "$TOP/btrfs" check "$1"
+}
+
+check_all_images
#2 lore raw

PATCH v2 2/2 Btrfs-progs: add fsck test for filesystem with shared prealloc extents

In reply to [email protected]

From: Filipe Manana <[email protected]>

Verify that a filesystem check operation (fsck) does not report the following scenario as an error:

An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent.

Such scenario can be created with the following steps for example:

mkfs.btrfs -f /dev/sdb
mount /dev/sdb /mnt

touch /mnt/foo
xfs_io -c "falloc 0 256K" /mnt/foo
sync

xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo
touch /mnt/bar
xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
xfs_io -c "fsync" /mnt/bar

<power fail>
mount /dev/sdb /mnt
umount /mnt

This scenario is fixed by the following patch for the filesystem checker:

"Btrfs-progs: check, fix false error reports for shared prealloc extents"

---

V2: No changes, only added Qu's reviewed-by tag.

 .../reflinked-prealloc-extents.img.xz              | Bin 0 -> 3244 bytes
 .../030-reflinked-prealloc-extents/test.sh         |  42 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz
 create mode 100755 tests/fsck-tests/030-reflinked-prealloc-extents/test.sh
tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e
GIT binary patch
tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.11.0
#3 lore raw

PATCH v3 2/2 Btrfs-progs: add fsck test for filesystem with shared prealloc extents

In reply to [email protected]

From: Filipe Manana <[email protected]>

Verify that a filesystem check operation (fsck) does not report the following scenario as an error:

An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent.

Such scenario can be created with the following steps for example:

mkfs.btrfs -f /dev/sdb
mount /dev/sdb /mnt

touch /mnt/foo
xfs_io -c "falloc 0 256K" /mnt/foo
sync

xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo
touch /mnt/bar
xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
xfs_io -c "fsync" /mnt/bar

<power fail>
mount /dev/sdb /mnt
umount /mnt

This scenario is fixed by the following patch for the filesystem checker:

"Btrfs-progs: check, fix false error reports for shared prealloc extents"

---

V3: No changes.
V2: No changes, only added Qu's reviewed-by tag.

 .../reflinked-prealloc-extents.img.xz              | Bin 0 -> 3244 bytes
 .../030-reflinked-prealloc-extents/test.sh         |  42 +++++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz
 create mode 100755 tests/fsck-tests/030-reflinked-prealloc-extents/test.sh
tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e
GIT binary patch
tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file +42 -0

42 lines not on this page · raw message

Signature · 1 line
2.11.0
Applied
#4 lore raw
Quoted 34 lines · On Wed, Mar 14, 2018 at 08:11:18PM +0000, [email protected] wrote:

From: Filipe Manana <[email protected]>

Verify that a filesystem check operation (fsck) does not report the following scenario as an error:

An extent is shared between two inodes, as a result of clone/reflink operation, and for one of the inodes, lets call it inode A, the extent is referenced through a file extent item as a prealloc extent, while for the other inode, call it inode B, the extent is referenced through a regular file extent item, that is, it was written to. The goal of this test is to make sure a filesystem check operation will not report "odd csum items" errors for the prealloc extent at inode A, because this scenario is valid since the extent was written through inode B and therefore it is expected to have checksum items in the filesystem's checksum btree for that shared extent.

Such scenario can be created with the following steps for example:

mkfs.btrfs -f /dev/sdb
mount /dev/sdb /mnt

touch /mnt/foo
xfs_io -c "falloc 0 256K" /mnt/foo
sync

xfs_io -c "pwrite -S 0xab 0 256K" /mnt/foo
touch /mnt/bar
xfs_io -c "reflink /mnt/foo 0 0 256K" /mnt/bar
xfs_io -c "fsync" /mnt/bar

<power fail>
mount /dev/sdb /mnt
umount /mnt

Quoted 6 lines

This scenario is fixed by the following patch for the filesystem checker:

"Btrfs-progs: check, fix false error reports for shared prealloc extents"

Applied, thanks.