xfstests: btrfs 308: regression test for btrfs send
PATCH 1/1 xfstests: btrfs 308: regression test for btrfs send
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,
--- 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
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 + seek_copy_test t_readdir_1 t_readdir_2 fsync-tester hold-open SUBDIRS =
src/hold-open.c new file +29 -0
@@ -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 ; +}
tests/btrfs/308 new file +74 -0
74 lines not on this page · raw message
tests/btrfs/308.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 308 +Silence is golden
tests/btrfs/group +1 -0
@@ -9,3 +9,4 @@ 276 auto rw metadata 284 auto 307 auto quick +308 auto quick
Signature · 1 line
1.7.7.6
Quoted 5 lines · Josef Bacik
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).
tests/btrfs/308 line 66
Quoted 5 lines
tests/btrfs/308 new file +5
-0+# 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.
Signature · 2 lines
Dave Chinner [email protected]