diff options
author | Filipe Manana <fdmanana@suse.com> | 2018-03-14 20:11:18 +0000 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-03-30 22:15:54 +0200 |
commit | 7a8d5d50145e6f3898bb382360857dcc080a4a78 (patch) | |
tree | 4f90ac242667053d5b5502e7c15e8a4367fd6a65 /tests | |
parent | 457a288cb5c7dccd88632dab5a903bd00a2142f0 (diff) |
Btrfs-progs: add fsck test for filesystem with shared prealloc extents
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"
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz | bin | 0 -> 3244 bytes | |||
-rwxr-xr-x | tests/fsck-tests/030-reflinked-prealloc-extents/test.sh | 42 |
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz b/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz Binary files differnew file mode 100644 index 00000000..8adf0071 --- /dev/null +++ b/tests/fsck-tests/030-reflinked-prealloc-extents/reflinked-prealloc-extents.img.xz diff --git a/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh new file mode 100755 index 00000000..63f692bc --- /dev/null +++ b/tests/fsck-tests/030-reflinked-prealloc-extents/test.sh @@ -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 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 |