btrfs: simple sparse copy testcase for btrfs

Tests file clone functionality of btrfs ("reflinks"):
   - Reflink a file
   - Reflink the reflinked file
   - Modify the original file
   - Modify the reflinked file

[sandeen: add helpers, make several mostly-cosmetic
 changes to the original testcase]

Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Koen De Wit
2014-01-20 13:56:34 +11:00
committed by Dave Chinner
parent a050cb00c7
commit c8d9f19638
4 changed files with 128 additions and 0 deletions
+21
View File
@@ -2102,6 +2102,27 @@ _require_ugid_map()
fi
}
_require_cp_reflink()
{
cp --help | grep -q reflink || \
_notrun "This test requires a cp with --reflink support."
}
# Given 2 files, verify that they have the same mapping but different
# inodes - i.e. an undisturbed reflink
# Silent if so, make noise if not
_verify_reflink()
{
# not a hard link or symlink?
cmp -s <(stat -c '%i' $1) <(stat -c '%i' $2) \
&& echo "$1 and $2 are not reflinks: same inode number"
# same mapping?
diff -u <($XFS_IO_PROG -c "fiemap" $1 | grep -v $1) \
<($XFS_IO_PROG -c "fiemap" $2 | grep -v $2) \
|| echo "$1 and $2 are not reflinks: different extents"
}
_create_loop_device()
{
file=$1