xfstests: btrfs/027: simple sparse copy testcase for btrfs
PATCH RESEND 1/1 xfstests: btrfs/027: 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 <[email protected]>
Signed-off-by Eric Sandeen <[email protected]>
---
Originally submitted as test 297, btrfs/308
common/rc +21 -0
@@ -2078,6 +2078,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
tests/btrfs/027 new file +90 -0
90 lines not on this page · raw message
tests/btrfs/027.out new file +16 -0
@@ -0,0 +1,16 @@ +QA output created by 027 +Create the original file and reflink to copy1, copy2 +Original md5sums: +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/original +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/copy1 +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/copy2 +Overwrite original file with new data +md5sums after overwriting original: +4a847a25439532bf48b68c9e9536ed5b TEST_DIR/test-027/original +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/copy1 +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/copy2 +Overwrite copy1 with different new data +md5sums after overwriting copy1: +4a847a25439532bf48b68c9e9536ed5b TEST_DIR/test-027/original +e271cd47d9f62ebc96cb4e67ae4d16db TEST_DIR/test-027/copy1 +42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-027/copy2
tests/btrfs/group +1 -0
@@ -27,3 +27,4 @@ 022 auto 023 auto 024 auto quick +027 auto quick
Signature · 1 line
1.7.1