xfstests: 297: simple sparse copy testcase for btrfs
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Koen De Wit
Signed-off-by Koen De Wit <[email protected]>
Sorry for the late review. Better late than never?
cc'ing linux-btrfs - in general a good idea so btrfs experts can evaluate the test as well.
Quoted 53 lines
---
297 | 75
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++297.out | 10 ++++++++ 2 files changed, 85 insertions(+), 0 deletions(-)create mode 100644 297
create mode 100644 297.out297 new file +39
-0@@ -0,0 +1,75 @@ +#! /bin/bash +# FS QA Test No. 297 +# +# Tests file clone functionality of btrfs ("reflinks"): +# - Reflink a file +# - Reflink the reflinked file +# - Modify the original file +# - Modify the reflinked file +# +#----------------------------------------------------------------------- +# Copyright (c) 2013, Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# +# creator [email protected] + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{
297 line 49
Quoted 10 lines
297 new file +10
-0+ cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +# real QA test starts here +_supported_fs btrfs
I wonder if it'd be nice to make the test generic, but test whether the filesystem supports reflinks, and bail if not.
297 line 52
Quoted 3 lines
297 new file +3
-0+_supported_os Linux + +_require_cp_reflink
where does _require_cp_reflink come from?
Also, as for missing bits, need to add new tests to the group with each patch (I see you added them all in the last patch you sent).
297 line 55
Quoted 3 lines
297 new file +3
-0+ +TESTDIR1=$TEST_DIR/test-$seq.$$ +mkdir $TESTDIR1
This has some remote possibility of failure, right, if we happen to run across the same pid.
How about:
+TESTDIR1=$TEST_DIR/test-$seq
+rm -rf TESTDIR1=$TEST_DIR/test-$seq
+mkdir $TESTDIR1
297 line 62
Quoted 7 lines
297 new file +7
-0+ +_catfiles() { + for F in original copy1 copy2 + do + md5sum $TESTDIR1/$F | $AWK_PROG 'END {print $1}' + done +}
Just a nitpick I guess but maybe _checksum_files would be more accurate. It'd also be nicer to provide more context in the output - what file is the checksum for? What are we testing?
So maybe:
+_checksum_files() {
+ for F in original copy1 copy2
+ do
+ md5sum $TESTDIR1/$F | _filter_test_dir
+ done
+}
so then we'll have the filenames in the output.
And then, putting echos in make both the test and the output more self-documenting:
+echo "Create the original file filled with 0x61"
297 line 63
Quoted 1 line
297 new file +1
-0+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 9000' $TESTDIR1/original > /dev/null
+echo "And make 2 reflink copies to it"
297 line 65
Quoted 2 lines
297 new file +2
-0+cp --reflink $TESTDIR1/original $TESTDIR1/copy1 +cp --reflink $TESTDIR1/copy1 $TESTDIR1/copy2
+# Ensure that they all have the same md5sums at this point +echo "Original md5sums:"
297 line 66
Quoted 1 line
297 new file +1
-0+_catfiles
+echo "Overwrite original file with 0x62"
297 line 67
Quoted 1 line
297 new file +1
-0+$XFS_IO_PROG -c 'pwrite -S 0x62 0 9000' $TESTDIR1/original > /dev/null
+echo "md5sums after overwriting original"
297 line 68
Quoted 1 line
297 new file +1
-0+_catfiles
+echo "Overwrite copy1 with 0x63"
297 line 69
Quoted 1 line
297 new file +1
-0+$XFS_IO_PROG -c 'pwrite -S 0x63 0 9000' $TESTDIR1/copy1 > /dev/null
+echo "md5sums after overwriting copy1:"
297 line 74
Quoted 5 lines
297 new file +5
-0+_catfiles + +# success, all done +status=0 +exit
Then the test output looks like:
Create the original file filled with 0x61
And make 2 reflink copies to it
Original md5sums:
42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/original 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/copy1 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/copy2 Overwrite original file with 0x62 md5sums after overwriting original: 4a847a25439532bf48b68c9e9536ed5b TEST_DIR/test-307/original 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/copy1 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/copy2 Overwrite copy1 with 0x63 md5sums after overwriting copy1: 4a847a25439532bf48b68c9e9536ed5b TEST_DIR/test-307/original e271cd47d9f62ebc96cb4e67ae4d16db TEST_DIR/test-307/copy1 42d69d1a6d333a7ebdf64792a555e392 TEST_DIR/test-307/copy2
so if anything goes wrong, we'll have more context in the output.
What do you think?
Thanks,
-Eric
Quoted 17 lines
297.out new file +10
-0@@ -0,0 +1,10 @@ +QA output created by 297 +42d69d1a6d333a7ebdf64792a555e392 +42d69d1a6d333a7ebdf64792a555e392 +42d69d1a6d333a7ebdf64792a555e392 +4a847a25439532bf48b68c9e9536ed5b +42d69d1a6d333a7ebdf64792a555e392 +42d69d1a6d333a7ebdf64792a555e392 +4a847a25439532bf48b68c9e9536ed5b +e271cd47d9f62ebc96cb4e67ae4d16db +42d69d1a6d333a7ebdf64792a555e392
Koen,
Thanks for submitting several new tests. Are you still interested in these tests and willing to address the comments?
Thanks
--Rich
Thanks for the reviews Eric and Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs