All of lore.kernel.org
 help / color / mirror / Atom feed
From: Koen De Wit <koen.de.wit@oracle.com>
To: xfs@oss.sgi.com
Cc: linux-btrfs@vger.kernel.org, Koen De Wit <koen.de.wit@oracle.com>
Subject: [PATCH RESEND] xfstests: btrfs: cross-subvolume sparse copy
Date: Tue, 21 Jan 2014 12:40:48 +0100	[thread overview]
Message-ID: <1390304448-25752-1-git-send-email-koen.de.wit@oracle.com> (raw)

This testscript creates reflinks to files on different subvolumes,
overwrites the original files and reflinks, and moves reflinked files
between subvolumes.

Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
---

Originally submitted as test 302, btrfs/316

diff --git a/tests/btrfs/030 b/tests/btrfs/030
new file mode 100644
index 0000000..5ebc555
--- /dev/null
+++ b/tests/btrfs/030
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 030
+#
+# Testing cross-subvolume sparse copy on btrfs
+#    - Create two subvolumes, mount one of them
+#    - Create a file on each (sub/root)volume,
+#      reflink them on the other volumes
+#    - Change one original and two reflinked files
+#    - Move reflinked files between subvolumes
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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
+#-----------------------------------------------------------------------
+
+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()
+{
+    umount $SCRATCH_MNT
+    rm -rf $TESTDIR1
+    rm -rf $TESTDIR2
+    btrfs subvolume delete $SUBVOL1 >> $seqres.full
+    btrfs subvolume delete $SUBVOL2 >> $seqres.full
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_scratch
+_require_cp_reflink
+
+_checksum_files() {
+    for F in file1 file2 file3
+    do
+        echo "$F:"
+        for D in $TESTDIR1 $SCRATCH_MNT $SUBVOL2
+        do
+            _md5_checksum $D/$F
+        done
+    done
+}
+
+TESTDIR1=$TEST_DIR/test-$seq-1
+TESTDIR2=$TEST_DIR/test-$seq-2
+SUBVOL1=$TEST_DIR/subvol-$seq-1
+SUBVOL2=$TEST_DIR/subvol-$seq-2
+
+_scratch_unmount 2>/dev/null
+rm -rf $seqres.full
+rm -rf $TESTDIR1 $TESTDIR2
+btrfs subvol delete $SUBVOL1 >/dev/null 2>&1
+btrfs subvol delete $SUBVOL2 >/dev/null 2>&1
+
+mkdir $TESTDIR1
+mkdir $TESTDIR2
+btrfs subvolume create $SUBVOL1 >> $seqres.full
+btrfs subvolume create $SUBVOL2 >> $seqres.full
+_mount -t btrfs -o subvol=subvol-$seq-1 $TEST_DEV $SCRATCH_MNT
+
+echo "Create initial files"
+# TESTDIR1/file1 is very small and will be inlined
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 10' $TESTDIR1/file1 \
+    >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 13000' $SCRATCH_MNT/file2 \
+    >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x63 0 17000' $SUBVOL2/file3 \
+    >> $seqres.full
+
+echo "Create reflinks to the initial files on other subvolumes"
+cp --reflink $TESTDIR1/file1 $SUBVOL1
+cp --reflink $TESTDIR1/file1 $SUBVOL2
+cp --reflink $SUBVOL1/file2 $TESTDIR1/
+cp --reflink $SUBVOL1/file2 $SUBVOL2
+cp --reflink $SUBVOL2/file3 $TESTDIR1/
+cp --reflink $SUBVOL2/file3 $SUBVOL1
+
+echo "Verify the reflinks"
+_verify_reflink $SCRATCH_MNT/file2 $TESTDIR1/file2
+_verify_reflink $SCRATCH_MNT/file2 $SUBVOL2/file2
+_verify_reflink $SUBVOL2/file3 $TESTDIR1/file3
+_verify_reflink $SUBVOL2/file3 $SCRATCH_MNT/file3
+echo "Verify the file contents:"
+_checksum_files
+
+echo -e "---\nOverwrite some files with new content"
+$XFS_IO_PROG -c 'pwrite -S 0x64 0 20' $TESTDIR1/file1 >> $seqres.full
+$XFS_IO_PROG -c 'pwrite -S 0x66 0 21000' $SUBVOL2/file2 >> $seqres.full
+$XFS_IO_PROG -c 'pwrite -S 0x65 5000 5000' $SCRATCH_MNT/file3 \
+    >> $seqres.full
+
+echo -n "Verify that non-overwritten reflinks "
+echo "still have the same data blocks"
+_verify_reflink $TESTDIR1/file2 $SCRATCH_MNT/file2
+_verify_reflink $TESTDIR1/file3 $SUBVOL2/file3
+echo "Verify the file contents:"
+_checksum_files
+
+echo -e "---\nShuffle files between directories"
+mv $TESTDIR1/file* $TESTDIR2
+mv $SCRATCH_MNT/file* $TESTDIR1/
+mv $SUBVOL2/file* $SCRATCH_MNT/
+mv $TESTDIR2/file* $SUBVOL2/
+
+# No _verify_reflink here as data is copied when moving files
+# between subvols
+echo "Verify the file contents:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/030.out b/tests/btrfs/030.out
new file mode 100644
index 0000000..050ae0b
--- /dev/null
+++ b/tests/btrfs/030.out
@@ -0,0 +1,48 @@
+QA output created by 030
+Create initial files
+Create reflinks to the initial files on other subvolumes
+Verify the reflinks
+Verify the file contents:
+file1:
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+file3:
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
+---
+Overwrite some files with new content
+Verify that non-overwritten reflinks still have the same data blocks
+Verify the file contents:
+file1:
+00d620f69f30327f0f8946b95c12de44
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+917619ae44b38bb9968af261c3c45440
+file3:
+5a95800e4c04b11117aa4e4de057721f
+b9f275cd638cb784c9e61def94c622a8
+5a95800e4c04b11117aa4e4de057721f
+---
+Shuffle files between directories
+Verify the file contents:
+file1:
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+00d620f69f30327f0f8946b95c12de44
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+917619ae44b38bb9968af261c3c45440
+d7402b46310fbbfbc5e466b1dccb043b
+file3:
+b9f275cd638cb784c9e61def94c622a8
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 8eb8c4f..3f61799 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -32,3 +32,4 @@
 027 auto quick
 028 auto quick
 029 auto quick
+030 auto quick
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: Koen De Wit <koen.de.wit@oracle.com>
To: xfs@oss.sgi.com
Cc: Koen De Wit <koen.de.wit@oracle.com>, linux-btrfs@vger.kernel.org
Subject: [PATCH RESEND] xfstests: btrfs: cross-subvolume sparse copy
Date: Tue, 21 Jan 2014 12:40:48 +0100	[thread overview]
Message-ID: <1390304448-25752-1-git-send-email-koen.de.wit@oracle.com> (raw)

This testscript creates reflinks to files on different subvolumes,
overwrites the original files and reflinks, and moves reflinked files
between subvolumes.

Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
---

Originally submitted as test 302, btrfs/316

diff --git a/tests/btrfs/030 b/tests/btrfs/030
new file mode 100644
index 0000000..5ebc555
--- /dev/null
+++ b/tests/btrfs/030
@@ -0,0 +1,137 @@
+#! /bin/bash
+# FS QA Test No. 030
+#
+# Testing cross-subvolume sparse copy on btrfs
+#    - Create two subvolumes, mount one of them
+#    - Create a file on each (sub/root)volume,
+#      reflink them on the other volumes
+#    - Change one original and two reflinked files
+#    - Move reflinked files between subvolumes
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014, 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
+#-----------------------------------------------------------------------
+
+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()
+{
+    umount $SCRATCH_MNT
+    rm -rf $TESTDIR1
+    rm -rf $TESTDIR2
+    btrfs subvolume delete $SUBVOL1 >> $seqres.full
+    btrfs subvolume delete $SUBVOL2 >> $seqres.full
+    cd /
+    rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+
+_require_scratch
+_require_cp_reflink
+
+_checksum_files() {
+    for F in file1 file2 file3
+    do
+        echo "$F:"
+        for D in $TESTDIR1 $SCRATCH_MNT $SUBVOL2
+        do
+            _md5_checksum $D/$F
+        done
+    done
+}
+
+TESTDIR1=$TEST_DIR/test-$seq-1
+TESTDIR2=$TEST_DIR/test-$seq-2
+SUBVOL1=$TEST_DIR/subvol-$seq-1
+SUBVOL2=$TEST_DIR/subvol-$seq-2
+
+_scratch_unmount 2>/dev/null
+rm -rf $seqres.full
+rm -rf $TESTDIR1 $TESTDIR2
+btrfs subvol delete $SUBVOL1 >/dev/null 2>&1
+btrfs subvol delete $SUBVOL2 >/dev/null 2>&1
+
+mkdir $TESTDIR1
+mkdir $TESTDIR2
+btrfs subvolume create $SUBVOL1 >> $seqres.full
+btrfs subvolume create $SUBVOL2 >> $seqres.full
+_mount -t btrfs -o subvol=subvol-$seq-1 $TEST_DEV $SCRATCH_MNT
+
+echo "Create initial files"
+# TESTDIR1/file1 is very small and will be inlined
+$XFS_IO_PROG -f -c 'pwrite -S 0x61 0 10' $TESTDIR1/file1 \
+    >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x62 0 13000' $SCRATCH_MNT/file2 \
+    >> $seqres.full
+$XFS_IO_PROG -f -c 'pwrite -S 0x63 0 17000' $SUBVOL2/file3 \
+    >> $seqres.full
+
+echo "Create reflinks to the initial files on other subvolumes"
+cp --reflink $TESTDIR1/file1 $SUBVOL1
+cp --reflink $TESTDIR1/file1 $SUBVOL2
+cp --reflink $SUBVOL1/file2 $TESTDIR1/
+cp --reflink $SUBVOL1/file2 $SUBVOL2
+cp --reflink $SUBVOL2/file3 $TESTDIR1/
+cp --reflink $SUBVOL2/file3 $SUBVOL1
+
+echo "Verify the reflinks"
+_verify_reflink $SCRATCH_MNT/file2 $TESTDIR1/file2
+_verify_reflink $SCRATCH_MNT/file2 $SUBVOL2/file2
+_verify_reflink $SUBVOL2/file3 $TESTDIR1/file3
+_verify_reflink $SUBVOL2/file3 $SCRATCH_MNT/file3
+echo "Verify the file contents:"
+_checksum_files
+
+echo -e "---\nOverwrite some files with new content"
+$XFS_IO_PROG -c 'pwrite -S 0x64 0 20' $TESTDIR1/file1 >> $seqres.full
+$XFS_IO_PROG -c 'pwrite -S 0x66 0 21000' $SUBVOL2/file2 >> $seqres.full
+$XFS_IO_PROG -c 'pwrite -S 0x65 5000 5000' $SCRATCH_MNT/file3 \
+    >> $seqres.full
+
+echo -n "Verify that non-overwritten reflinks "
+echo "still have the same data blocks"
+_verify_reflink $TESTDIR1/file2 $SCRATCH_MNT/file2
+_verify_reflink $TESTDIR1/file3 $SUBVOL2/file3
+echo "Verify the file contents:"
+_checksum_files
+
+echo -e "---\nShuffle files between directories"
+mv $TESTDIR1/file* $TESTDIR2
+mv $SCRATCH_MNT/file* $TESTDIR1/
+mv $SUBVOL2/file* $SCRATCH_MNT/
+mv $TESTDIR2/file* $SUBVOL2/
+
+# No _verify_reflink here as data is copied when moving files
+# between subvols
+echo "Verify the file contents:"
+_checksum_files
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/030.out b/tests/btrfs/030.out
new file mode 100644
index 0000000..050ae0b
--- /dev/null
+++ b/tests/btrfs/030.out
@@ -0,0 +1,48 @@
+QA output created by 030
+Create initial files
+Create reflinks to the initial files on other subvolumes
+Verify the reflinks
+Verify the file contents:
+file1:
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+file3:
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
+---
+Overwrite some files with new content
+Verify that non-overwritten reflinks still have the same data blocks
+Verify the file contents:
+file1:
+00d620f69f30327f0f8946b95c12de44
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+d7402b46310fbbfbc5e466b1dccb043b
+917619ae44b38bb9968af261c3c45440
+file3:
+5a95800e4c04b11117aa4e4de057721f
+b9f275cd638cb784c9e61def94c622a8
+5a95800e4c04b11117aa4e4de057721f
+---
+Shuffle files between directories
+Verify the file contents:
+file1:
+e09c80c42fda55f9d992e59ca6b3307d
+e09c80c42fda55f9d992e59ca6b3307d
+00d620f69f30327f0f8946b95c12de44
+file2:
+d7402b46310fbbfbc5e466b1dccb043b
+917619ae44b38bb9968af261c3c45440
+d7402b46310fbbfbc5e466b1dccb043b
+file3:
+b9f275cd638cb784c9e61def94c622a8
+5a95800e4c04b11117aa4e4de057721f
+5a95800e4c04b11117aa4e4de057721f
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 8eb8c4f..3f61799 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -32,3 +32,4 @@
 027 auto quick
 028 auto quick
 029 auto quick
+030 auto quick
-- 
1.7.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2014-01-21 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 11:40 Koen De Wit [this message]
2014-01-21 11:40 ` [PATCH RESEND] xfstests: btrfs: cross-subvolume sparse copy Koen De Wit
2014-01-22 13:27 ` David Sterba
2014-01-22 13:27   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1390304448-25752-1-git-send-email-koen.de.wit@oracle.com \
    --to=koen.de.wit@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.