From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: hch@infradead.org, david@fromorbit.com, darrick.wong@oracle.com
Cc: fstests@vger.kernel.org, xfs@oss.sgi.com,
tao.peng@primarydata.com, linux-ext4@vger.kernel.org,
Anna.Schumaker@netapp.com, linux-btrfs@vger.kernel.org
Subject: [PATCH 02/11] generic/80[0-2]: support xfs in addition to btrfs
Date: Wed, 11 Nov 2015 11:26:42 -0800 [thread overview]
Message-ID: <20151111192642.15056.75362.stgit@birch.djwong.org> (raw)
In-Reply-To: <20151111192628.15056.6451.stgit@birch.djwong.org>
Modify the reflink tests to support xfs.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
common/rc | 42 ++++++------
common/reflink | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/029 | 1
tests/btrfs/031 | 1
tests/btrfs/108 | 1
tests/btrfs/109 | 1
tests/generic/800 | 3 +
tests/generic/801 | 3 +
tests/generic/802 | 3 +
9 files changed, 210 insertions(+), 24 deletions(-)
create mode 100644 common/reflink
diff --git a/common/rc b/common/rc
index adf1edf..c016673 100644
--- a/common/rc
+++ b/common/rc
@@ -82,6 +82,27 @@ _md5_checksum()
md5sum $1 | cut -d ' ' -f1
}
+# Write a byte into a range of a file
+_pwrite_byte() {
+ pattern="$1"
+ offset="$2"
+ len="$3"
+ file="$4"
+ xfs_io_args="$5"
+
+ "$XFS_IO_PROG" $xfs_io_args -f -c "pwrite -S $pattern $offset $len" "$file"
+}
+
+# mmap-write a byte into a range of a file
+_mwrite_byte() {
+ pattern="$1"
+ offset="$2"
+ len="$3"
+ mmap_len="$4"
+ file="$5"
+
+ "$XFS_IO_PROG" -f -c "mmap -rw 0 $mmap_len" -c "pwrite -S $pattern $offset $len" "$file"
+}
# ls -l w/ selinux sometimes puts a dot at the end:
# -rwxrw-r--. id1 id2 file1
@@ -2569,12 +2590,6 @@ _require_ugid_map()
fi
}
-_require_cp_reflink()
-{
- cp --help | grep -q reflink || \
- _notrun "This test requires a cp with --reflink support."
-}
-
_require_fssum()
{
FSSUM_PROG=$here/src/fssum
@@ -2588,21 +2603,6 @@ _require_cloner()
_notrun "cloner binary not present at $CLONER_PROG"
}
-# 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"
-}
-
_require_atime()
{
if [ "$FSTYP" == "nfs" ]; then
diff --git a/common/reflink b/common/reflink
new file mode 100644
index 0000000..d65816b
--- /dev/null
+++ b/common/reflink
@@ -0,0 +1,179 @@
+##/bin/bash
+# Routines for reflinking, deduping, and comparing parts of files.
+#-----------------------------------------------------------------------
+# Copyright (c) 2015 Oracle. 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; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will 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 to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# Contact information: Oracle Corporation, 500 Oracle Parkway,
+# Redwood Shores, CA 94065, USA, or: http://www.oracle.com/
+#-----------------------------------------------------------------------
+
+# Check that cp has a reflink argument
+_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"
+}
+
+# New reflink/dedupe helpers
+
+# this test requires the test fs support reflink...
+_require_test_reflink()
+{
+ _require_test
+ _require_xfs_io_command "reflink"
+
+ rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2"
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null
+ "$XFS_IO_PROG" -f -c "reflink $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" > /dev/null
+ if [ ! -s "$TEST_DIR/file2" ]; then
+ rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2"
+ _notrun "Reflink not supported by test filesystem type: $FSTYP"
+ fi
+ rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2"
+}
+
+# this test requires the scratch fs support reflink...
+_require_scratch_reflink()
+{
+ _require_scratch
+ _require_xfs_io_command "reflink"
+
+ _scratch_mkfs > /dev/null
+ _scratch_mount
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
+ "$XFS_IO_PROG" -f -c "reflink $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" > /dev/null
+ if [ ! -s "$SCRATCH_MNT/file2" ]; then
+ _scratch_unmount
+ _notrun "Reflink not supported by scratch filesystem type: $FSTYP"
+ fi
+ _scratch_unmount
+}
+
+# this test requires the test fs support dedupe...
+_require_test_dedupe()
+{
+ _require_test
+ _require_xfs_io_command "dedupe"
+
+ rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2"
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file2" > /dev/null
+ testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "Dedupe not supported by test filesystem type: $FSTYP"
+ rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2"
+}
+
+# this test requires the scratch fs support dedupe...
+_require_scratch_dedupe()
+{
+ _require_scratch
+ _require_xfs_io_command "dedupe"
+
+ _scratch_mkfs > /dev/null
+ _scratch_mount
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null
+ "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null
+ testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)"
+ echo $testio | grep -q "Operation not supported" && \
+ _notrun "Dedupe not supported by test filesystem type: $FSTYP"
+ _scratch_unmount
+}
+
+# Prints a range of a file as a hex dump
+_read_range() {
+ file="$1"
+ offset="$2"
+ len="$3"
+ xfs_io_args="$4"
+
+ $XFS_IO_PROG $xfs_io_args -f -c "pread -q -v $offset $len" "$file" | cut -d ' ' -f '3-18'
+}
+
+# Compare ranges of two files
+_compare_range() {
+ file1="$1"
+ offset1="$2"
+ file2="$3"
+ offset2="$4"
+ len="$5"
+
+ cmp -s <(_read_range "$file1" "$offset1" "$len") \
+ <(_read_range "$file2" "$offset2" "$len")
+}
+
+# Prints the md5 checksum of a hexdump of a part of a given file
+_md5_range_checksum() {
+ file="$1"
+ offset="$2"
+ len="$3"
+
+ md5sum <(_read_range "$file" "$offset" "$len") | cut -d ' ' -f 1
+}
+
+# Reflink some file1 into file2 via cp
+_cp_reflink() {
+ file1="$1"
+ file2="$2"
+
+ cp --reflink=always "$file1" "$file2"
+}
+
+# Reflink some file1 into file2
+_reflink() {
+ file1="$1"
+ file2="$2"
+
+ "$XFS_IO_PROG" -f -c "reflink $file1" "$file2"
+}
+
+# Reflink some part of file1 into another part of file2
+_reflink_range() {
+ file1="$1"
+ offset1="$2"
+ file2="$3"
+ offset2="$4"
+ len="$5"
+
+ "$XFS_IO_PROG" -f -c "reflink $file1 $offset1 $offset2 $len" "$file2"
+}
+
+# Dedupe some part of file1 into another part of file2
+_dedupe_range() {
+ file1="$1"
+ offset1="$2"
+ file2="$3"
+ offset2="$4"
+ len="$5"
+
+ "$XFS_IO_PROG" -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2"
+}
diff --git a/tests/btrfs/029 b/tests/btrfs/029
index 0b77b33..175317a 100755
--- a/tests/btrfs/029
+++ b/tests/btrfs/029
@@ -47,6 +47,7 @@ _cleanup()
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/reflink
# real QA test starts here
_supported_fs btrfs
diff --git a/tests/btrfs/031 b/tests/btrfs/031
index bcd332c..c5763da 100755
--- a/tests/btrfs/031
+++ b/tests/btrfs/031
@@ -48,6 +48,7 @@ _cleanup()
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/reflink
# real QA test starts here
_supported_fs btrfs
diff --git a/tests/btrfs/108 b/tests/btrfs/108
index 5e3a403..18e5b99 100755
--- a/tests/btrfs/108
+++ b/tests/btrfs/108
@@ -41,6 +41,7 @@ _cleanup()
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/reflink
# real QA test starts here
_supported_fs btrfs
diff --git a/tests/btrfs/109 b/tests/btrfs/109
index e2aeb73..b86336c 100755
--- a/tests/btrfs/109
+++ b/tests/btrfs/109
@@ -41,6 +41,7 @@ _cleanup()
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/reflink
# real QA test starts here
_supported_fs btrfs
diff --git a/tests/generic/800 b/tests/generic/800
index a71f11a..1e73c33 100755
--- a/tests/generic/800
+++ b/tests/generic/800
@@ -43,9 +43,10 @@ _cleanup()
# get standard environment, filters and checks
. common/rc
. common/filter
+. common/reflink
# real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
_supported_os Linux
_require_xfs_io_command "fiemap"
diff --git a/tests/generic/801 b/tests/generic/801
index b21c44b..2facea9 100755
--- a/tests/generic/801
+++ b/tests/generic/801
@@ -43,9 +43,10 @@ _cleanup()
# get standard environment, filters and checks
. common/rc
. common/filter
+. common/reflink
# real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
_supported_os Linux
_require_xfs_io_command "fiemap"
diff --git a/tests/generic/802 b/tests/generic/802
index afd8513..aaca2b4 100755
--- a/tests/generic/802
+++ b/tests/generic/802
@@ -41,9 +41,10 @@ _cleanup()
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/reflink
# real QA test starts here
-_supported_fs btrfs
+_require_test_reflink
_supported_os Linux
_require_xfs_io_command "fiemap"
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-11-11 19:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 19:26 [RFCv3.1 00/11] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls Darrick J. Wong
2015-11-11 19:26 ` [PATCH 01/11] btrfs: move btrfs reflink tests to generic Darrick J. Wong
2015-11-11 19:26 ` Darrick J. Wong [this message]
2015-11-11 19:26 ` [PATCH 03/11] reflink: basic tests of the reflink and dedupe ioctls Darrick J. Wong
2015-11-11 19:26 ` [PATCH 04/11] reflink: test CoW behaviors of reflinked files Darrick J. Wong
2015-11-11 19:27 ` [PATCH 05/11] reflink: test the various fallocate modes Darrick J. Wong
2015-11-11 19:27 ` [PATCH 06/11] reflink: concurrent operations tests Darrick J. Wong
2015-11-11 19:27 ` [PATCH 07/11] reflink: test accuracy of free block counts Darrick J. Wong
2015-11-11 19:27 ` [PATCH 08/11] reflink: test error conditions due to bad inputs Darrick J. Wong
2015-11-11 19:27 ` [PATCH 09/11] xfs: test xfs-specific reflink pieces Darrick J. Wong
2015-11-11 19:27 ` [PATCH 10/11] reflink: test what happens when we hit resource limits Darrick J. Wong
2015-11-11 19:27 ` [PATCH 11/11] reflink: test that CoW writes fail when we're out of space Darrick J. Wong
2015-11-12 9:07 ` [RFCv3.1 00/11] xfstests: test the nfs/cifs/btrfs/xfs reflink/dedupe ioctls Christoph Hellwig
2015-11-12 12:51 ` Christoph Hellwig
2015-11-12 17:34 ` Darrick J. Wong
2015-11-12 17:36 ` Christoph Hellwig
2015-11-13 9:08 ` Darrick J. Wong
2015-11-13 14:12 ` Christoph Hellwig
2015-11-13 18:32 ` Darrick J. Wong
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=20151111192642.15056.75362.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=Anna.Schumaker@netapp.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=tao.peng@primarydata.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).