* [PATCH] xfstests: btrfs 308: regression test for btrfs send
@ 2013-05-20 17:20 ` Josef Bacik
0 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2013-05-20 17:20 UTC (permalink / raw)
To: xfs, linux-btrfs
I'm not sure how the numbering is supposed to work now that we've split
everything out so I'm just going with the next number in the directory. This is
a regression test for btrfs send, we had a problem where we'd try to send a file
that had been deleted in the source snapshot. This is just to make sure we
don't have the same problem in the future. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
src/Makefile | 2 +-
src/hold-open.c | 29 ++++++++++++++++++++
tests/btrfs/308 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/308.out | 2 +
tests/btrfs/group | 1 +
5 files changed, 107 insertions(+), 1 deletions(-)
create mode 100644 src/hold-open.c
create mode 100644 tests/btrfs/308
create mode 100644 tests/btrfs/308.out
diff --git a/src/Makefile b/src/Makefile
index c18ffc9..3ab9a21 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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
+ seek_copy_test t_readdir_1 t_readdir_2 fsync-tester hold-open
SUBDIRS =
diff --git a/src/hold-open.c b/src/hold-open.c
new file mode 100644
index 0000000..f44c1dd
--- /dev/null
+++ b/src/hold-open.c
@@ -0,0 +1,29 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ int fd;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: hold-open <filename>\n");
+ return -1;
+ }
+
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening file: %d\n", errno);
+ return -1;
+ }
+
+ while (1) {
+ sleep(60);
+ }
+
+ close(fd);
+ return 0;
+}
diff --git a/tests/btrfs/308 b/tests/btrfs/308
new file mode 100644
index 0000000..144be99
--- /dev/null
+++ b/tests/btrfs/308
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test No. btrfs/308
+#
+# btrfs send ESTALE regression test, kernel.org bugzilla 57491
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Fusion IO. 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
+
+dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=10 > /dev/null 2>&1
+sync
+$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap > /dev/null 2>&1
+dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=10 oflag=append > /dev/null 2>&1
+sync
+
+# We need to hold the file open, tail -f makes the output file look weird so
+# here is this awful hack to get around that
+$here/src/hold-open $SCRATCH_MNT/foo &
+
+# need this so that tail doesn't error out racing with the rm
+sleep 1
+rm -f $SCRATCH_MNT/foo
+$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap1 > /dev/null 2>&1
+$BTRFS_UTIL_PROG send -f /dev/null -p $SCRATCH_MNT/snap $SCRATCH_MNT/snap1 >/dev/null 2>&1
+if [ $? -ne 0 ]
+then
+ echo "send failed"
+fi
+kill $!
+
+echo "Silence is golden"
+status=0 ; exit
diff --git a/tests/btrfs/308.out b/tests/btrfs/308.out
new file mode 100644
index 0000000..a731eaa
--- /dev/null
+++ b/tests/btrfs/308.out
@@ -0,0 +1,2 @@
+QA output created by 308
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index bc6c256..666054b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -9,3 +9,4 @@
276 auto rw metadata
284 auto
307 auto quick
+308 auto quick
--
1.7.7.6
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] xfstests: btrfs 308: regression test for btrfs send
@ 2013-05-20 17:20 ` Josef Bacik
0 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2013-05-20 17:20 UTC (permalink / raw)
To: xfs, linux-btrfs
I'm not sure how the numbering is supposed to work now that we've split
everything out so I'm just going with the next number in the directory. This is
a regression test for btrfs send, we had a problem where we'd try to send a file
that had been deleted in the source snapshot. This is just to make sure we
don't have the same problem in the future. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
src/Makefile | 2 +-
src/hold-open.c | 29 ++++++++++++++++++++
tests/btrfs/308 | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/308.out | 2 +
tests/btrfs/group | 1 +
5 files changed, 107 insertions(+), 1 deletions(-)
create mode 100644 src/hold-open.c
create mode 100644 tests/btrfs/308
create mode 100644 tests/btrfs/308.out
diff --git a/src/Makefile b/src/Makefile
index c18ffc9..3ab9a21 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -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
+ seek_copy_test t_readdir_1 t_readdir_2 fsync-tester hold-open
SUBDIRS =
diff --git a/src/hold-open.c b/src/hold-open.c
new file mode 100644
index 0000000..f44c1dd
--- /dev/null
+++ b/src/hold-open.c
@@ -0,0 +1,29 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+
+int main(int argc, char **argv)
+{
+ int fd;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: hold-open <filename>\n");
+ return -1;
+ }
+
+ fd = open(argv[1], O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening file: %d\n", errno);
+ return -1;
+ }
+
+ while (1) {
+ sleep(60);
+ }
+
+ close(fd);
+ return 0;
+}
diff --git a/tests/btrfs/308 b/tests/btrfs/308
new file mode 100644
index 0000000..144be99
--- /dev/null
+++ b/tests/btrfs/308
@@ -0,0 +1,74 @@
+#! /bin/bash
+# FS QA Test No. btrfs/308
+#
+# btrfs send ESTALE regression test, kernel.org bugzilla 57491
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Fusion IO. 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
+
+dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=10 > /dev/null 2>&1
+sync
+$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap > /dev/null 2>&1
+dd if=/dev/zero of=$SCRATCH_MNT/foo bs=1M count=10 oflag=append > /dev/null 2>&1
+sync
+
+# We need to hold the file open, tail -f makes the output file look weird so
+# here is this awful hack to get around that
+$here/src/hold-open $SCRATCH_MNT/foo &
+
+# need this so that tail doesn't error out racing with the rm
+sleep 1
+rm -f $SCRATCH_MNT/foo
+$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap1 > /dev/null 2>&1
+$BTRFS_UTIL_PROG send -f /dev/null -p $SCRATCH_MNT/snap $SCRATCH_MNT/snap1 >/dev/null 2>&1
+if [ $? -ne 0 ]
+then
+ echo "send failed"
+fi
+kill $!
+
+echo "Silence is golden"
+status=0 ; exit
diff --git a/tests/btrfs/308.out b/tests/btrfs/308.out
new file mode 100644
index 0000000..a731eaa
--- /dev/null
+++ b/tests/btrfs/308.out
@@ -0,0 +1,2 @@
+QA output created by 308
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index bc6c256..666054b 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -9,3 +9,4 @@
276 auto rw metadata
284 auto
307 auto quick
+308 auto quick
--
1.7.7.6
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] xfstests: btrfs 308: regression test for btrfs send
2013-05-20 17:20 ` Josef Bacik
@ 2013-05-21 0:33 ` Dave Chinner
-1 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2013-05-21 0:33 UTC (permalink / raw)
To: Josef Bacik; +Cc: xfs, linux-btrfs
On Mon, May 20, 2013 at 01:20:34PM -0400, Josef Bacik wrote:
> I'm not sure how the numbering is supposed to work now that we've split
> everything out so I'm just going with the next number in the directory. This is
> a regression test for btrfs send, we had a problem where we'd try to send a file
> that had been deleted in the source snapshot. This is just to make sure we
> don't have the same problem in the future. Thanks,
You are holding open an unlinked file? You want to use
src/multi_open_unlink, then.
/*
* multi_open_unlink path_prefix num_files sleep_time
* e.g.
* $ multi_open_unlink file 100 60
* Creates 100 files: file.1, file.2, ..., file.100
* unlinks them all but doesn't close them all until after 60 seconds.
*/
If you need to hold open existing files, add support for that into
multi_open_unlink.c (i.e. allow it to ignore EEXIST when trying to
create files).
> +# need this so that tail doesn't error out racing with the rm
> +sleep 1
> +rm -f $SCRATCH_MNT/foo
> +$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap1 > /dev/null 2>&1
> +$BTRFS_UTIL_PROG send -f /dev/null -p $SCRATCH_MNT/snap $SCRATCH_MNT/snap1 >/dev/null 2>&1
I'd send this output to $seqres.full, so if the test fails there's
debug output to look at...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfstests: btrfs 308: regression test for btrfs send
@ 2013-05-21 0:33 ` Dave Chinner
0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2013-05-21 0:33 UTC (permalink / raw)
To: Josef Bacik; +Cc: linux-btrfs, xfs
On Mon, May 20, 2013 at 01:20:34PM -0400, Josef Bacik wrote:
> I'm not sure how the numbering is supposed to work now that we've split
> everything out so I'm just going with the next number in the directory. This is
> a regression test for btrfs send, we had a problem where we'd try to send a file
> that had been deleted in the source snapshot. This is just to make sure we
> don't have the same problem in the future. Thanks,
You are holding open an unlinked file? You want to use
src/multi_open_unlink, then.
/*
* multi_open_unlink path_prefix num_files sleep_time
* e.g.
* $ multi_open_unlink file 100 60
* Creates 100 files: file.1, file.2, ..., file.100
* unlinks them all but doesn't close them all until after 60 seconds.
*/
If you need to hold open existing files, add support for that into
multi_open_unlink.c (i.e. allow it to ignore EEXIST when trying to
create files).
> +# need this so that tail doesn't error out racing with the rm
> +sleep 1
> +rm -f $SCRATCH_MNT/foo
> +$BTRFS_UTIL_PROG subvol snap -r $SCRATCH_MNT $SCRATCH_MNT/snap1 > /dev/null 2>&1
> +$BTRFS_UTIL_PROG send -f /dev/null -p $SCRATCH_MNT/snap $SCRATCH_MNT/snap1 >/dev/null 2>&1
I'd send this output to $seqres.full, so if the test fails there's
debug output to look at...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-21 0:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-20 17:20 [PATCH] xfstests: btrfs 308: regression test for btrfs send Josef Bacik
2013-05-20 17:20 ` Josef Bacik
2013-05-21 0:33 ` Dave Chinner
2013-05-21 0:33 ` Dave Chinner
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.