__btrfs_drop_extents() BUG_ON reproducer
v2 cover __btrfs_drop_extents() BUG_ON reproducer
This patch-set provides a reproducer for hitting the 3.14.0-rc1 BUG_ON() at:
692 int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
...
839 /*
840 * | ---- range to drop ----- | 841 * | -------- extent -------- | 842 */
843 if (start <= key.offset && end < extent_end) {
844 BUG_ON(extent_type == BTRFS_FILE_EXTENT_INLINE);
845
846 memcpy(&new_key, &key, sizeof(new_key));
The first patch adds a small cloner binary which is used by btrfs/035 to dispatch BTRFS_IOC_CLONE_RANGE requests.
This workload resembles that of Samba's vfs_btrfs module, when a Windows client restores a file from a shadow-copy (snapshot) using server-side copy requests.
Changes since V1:
- Use strtoull instead of atoi
- Print error conditions in cloner
- Check for cloner binary before running test
- Continue test on failure
- Add cloner to .gitignore
Feedback appreciated.
Cheers, David
.gitignore | 1 + configure.ac | 1 + src/Makefile | 2 +- src/cloner.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/035 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/035.out | 3 +++ tests/btrfs/group | 1 + 7 files changed, 276 insertions(+), 1 deletion(-) create mode 100644 src/cloner.c create mode 100755 tests/btrfs/035 create mode 100644 tests/btrfs/035.out
PATCH v2 1/3 btrfs: add small program for clone testing
The cloner program is capable of cloning files using the BTRFS_IOC_CLONE and BTRFS_IOC_CLONE_RANGE ioctls.
--- .gitignore | 1 + src/Makefile | 2 +- src/cloner.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 src/cloner.c
.gitignore +1 -0
@@ -104,6 +104,7 @@ /src/aio-dio-regress/aio-free-ring-with-bogus-nr-pages /src/aio-dio-regress/aio-io-setup-with-nonwritable-context-pointer /src/aio-dio-regress/aiodio_sparse2 +/src/cloner # dmapi/ binaries /dmapi/src/common/cmd/read_invis
src/Makefile +1 -1
@@ -18,7 +18,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \ locktest unwritten_mmap bulkstat_unlink_test t_stripealign \ bulkstat_unlink_test_modified t_dir_offset t_futimens t_immutable \ stale_handle pwrite_mmap_blocked t_dir_offset2 seek_sanity_test \ - seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec + seek_copy_test t_readdir_1 t_readdir_2 fsync-tester nsexec cloner SUBDIRS =
src/cloner.c new file +188 -0
188 lines not on this page · raw message
Signature · 1 line
1.8.4.5
PATCH v2 2/3 src/cloner: use btrfs/ioctl.h header if present
In reply to David DisseldorpCheck for the btrfsprogs-devel ioctl.h header at configure time. Use it in src/cloner if present, otherwise fall back to using the copied clone ioctl definitions.
--- configure.ac | 1 + src/cloner.c | 4 ++++ 2 files changed, 5 insertions(+)
configure.ac +1 -0
@@ -30,6 +30,7 @@ AC_HEADER_STDC AC_CHECK_HEADERS([ sys/fs/xfs_fsops.h \ sys/fs/xfs_itable.h \ xfs/platform_defs.h \ + btrfs/ioctl.h \ ]) AC_PACKAGE_NEED_UUIDCOMPARE
src/cloner.c +4 -0
@@ -30,6 +30,9 @@#include <stdio.h> #include <string.h> #include <errno.h> +#ifdef HAVE_BTRFS_IOCTL_H +#include <btrfs/ioctl.h> +#else struct btrfs_ioctl_clone_range_args { int64_t src_fd;
@@ -42,6 +45,7 @@ struct btrfs_ioctl_clone_range_args {#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \ struct btrfs_ioctl_clone_range_args) +#endif static void usage (char *name,const char *msg)
Signature · 1 line
1.8.4.5
PATCH v2 3/3 btrfs/035: add new clone overwrite regression test
In reply to David DisseldorpThis test uses the newly added cloner binary to dispatch full file and range specific clone (reflink) requests.
--- tests/btrfs/035 | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/035.out | 3 +++ tests/btrfs/group | 1 + 3 files changed, 81 insertions(+) create mode 100755 tests/btrfs/035 create mode 100644 tests/btrfs/035.out
tests/btrfs/035 new file +77 -0
@@ -0,0 +1,77 @@ +#!/bin/bash +# FS QA Test No. btrfs/035 +# +# Regression test for overwriting clones +# +#----------------------------------------------------------------------- +# Copyright (C) 2014 SUSE Linux Products GmbH. 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` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! + +_cleanup() +{ + rm -f $tmp.* +} + +trap "_cleanup ; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux +_require_scratch + +_scratch_mkfs > /dev/null 2>&1 +_scratch_mount + +CLONER_PROG=$here/src/cloner +[ -x $CLONER_PROG ] || _notrun "cloner binary not present at $CLONER_PROG" + +src_str="aaaaaaaaaa" + +echo -n "$src_str" > $SCRATCH_MNT/src || echo "failed to create src" + +$CLONER_PROG $SCRATCH_MNT/src $SCRATCH_MNT/src.clone1 + +src_str="bbbbbbbbbbcccccccccc" + +echo -n "$src_str" > $SCRATCH_MNT/src || echo "failed to create src" + +$CLONER_PROG $SCRATCH_MNT/src $SCRATCH_MNT/src.clone2 + +snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone1 | awk '{print $5}'` +echo "attempting ioctl (src.clone1 src)" +$CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \ + $SCRATCH_MNT/src.clone1 $SCRATCH_MNT/src + +snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone2 | awk '{print $5}'` +echo "attempting ioctl (src.clone2 src)" +$CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \ + $SCRATCH_MNT/src.clone2 $SCRATCH_MNT/src + +status=0 ; exit
tests/btrfs/035.out new file +3 -0
@@ -0,0 +1,3 @@ +QA output created by 035 +attempting ioctl (src.clone1 src) +attempting ioctl (src.clone2 src)
tests/btrfs/group +1 -0
@@ -37,3 +37,4 @@ 032 auto quick 033 auto quick 034 auto quick +035 auto quick
Signature · 1 line
1.8.4.5
Re: [PATCH v2 3/3] btrfs/035: add new clone overwrite regression test
Quoted 2 lines · David Disseldorp
This test uses the newly added cloner binary to dispatch full file and range specific clone (reflink) requests.
....
Review
Quoted 2 lines
(quoted diff) +2
-0+ +echo -n "$src_str" > $SCRATCH_MNT/src || echo "failed to create src"
Not exactly what I intended.
If echo fails, it will output some kind of error message, and that will cause the golden image mismatch.
Otherwise the test looks good.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH v2 3/3] btrfs/035: add new clone overwrite regression test
Quoted 4 lines · Dave Chinner
Not exactly what I intended.
If echo fails, it will output some kind of error message, and that will cause the golden image mismatch.
Fair enough. I'll resend with the two ' || echo "failed to create src"' checks removed. Thanks again for the review Dave.
Cheers, David