From 7a8d5d50145e6f3898bb382360857dcc080a4a78 Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Wed, 14 Mar 2018 20:11:18 +0000 Subject: [PATCH] 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 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 Reviewed-by: Qu Wenruo Signed-off-by: David Sterba --- .../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 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 new file mode 100644 index 0000000000000000000000000000000000000000..8adf0071328806fa6981f6ef225084e517d1bc3e GIT binary patch literal 3244 zcmV;d3{&&{H+ooF000E$*0e?f03iV!0000G&sfanlm85CT>wRyj;C3^v%$$4d1wo3 z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=ps`>|WP1cQu?kUL<77wB&hGzYt`M0=lV#So{@_Iygr{o5Fn9|9HMk+a=FmqKk8_QB99ArRuR7>#!y%L9G!{j6!ncOTk_*3awa zkN;`~%$XI@o0Ahz7)ZNo_ z2c`k7Oh;fsno7uR0!pBEg5BgjohMu8?^TN11DabusTj ze)_pSN^Ba6Wp^2aiQUvs2r>?R1ocR&>Q=DkRQbI>pgveJcmHt~_=uIcP3k7)2^GDc zN537UWwtmza_!k~6snP|;niI(9;M^(9c^6$;QOu}{65*q*%Fd|N&ck?tRCcNBmAhX z2F3n;IubrupC)EJ-_;I9Z+}0XRSRX-ats!dr@lFlB;jzLrz2nNCO!9`9{vD7cva-# e`Wb})0f-rZs2TvH_gU7l#Ao{g000001X)^Ms5!_0 literal 0 HcmV?d00001 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 0000000..63f692b --- /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 +# +# +# 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.7.4