summaryrefslogtreecommitdiffstats
path: root/qa/btrfs
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2012-02-20 19:31:55 +0100
committerSage Weil <sage@newdream.net>2012-02-20 19:56:42 +0100
commitebd29b65b9f70d4f485f89f8ae9df11427960c2c (patch)
tree07381424daa6011b850a74c4907aa108cb2b8bbe /qa/btrfs
parentceph-dencoder: add OSDMap::Incremental (diff)
downloadceph-ebd29b65b9f70d4f485f89f8ae9df11427960c2c.tar.xz
ceph-ebd29b65b9f70d4f485f89f8ae9df11427960c2c.zip
qa/btrfs/test_rmdir_async_snap
Attempt to reproduce btrfs bug when rmdirs race with an async snap. Unsuccessful. Best guess is that we need multiple threads to trigger. Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'qa/btrfs')
-rwxr-xr-xqa/btrfs/test_rmdir_async_snapbin0 -> 8559 bytes
-rw-r--r--qa/btrfs/test_rmdir_async_snap.c62
2 files changed, 62 insertions, 0 deletions
diff --git a/qa/btrfs/test_rmdir_async_snap b/qa/btrfs/test_rmdir_async_snap
new file mode 100755
index 00000000000..f128a6bb8ca
--- /dev/null
+++ b/qa/btrfs/test_rmdir_async_snap
Binary files differ
diff --git a/qa/btrfs/test_rmdir_async_snap.c b/qa/btrfs/test_rmdir_async_snap.c
new file mode 100644
index 00000000000..5dafaacaaeb
--- /dev/null
+++ b/qa/btrfs/test_rmdir_async_snap.c
@@ -0,0 +1,62 @@
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
+#include <string.h>
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+#include "../../src/os/btrfs_ioctl.h"
+
+struct btrfs_ioctl_vol_args_v2 va;
+struct btrfs_ioctl_vol_args vold;
+
+int main(int argc, char **argv)
+{
+ int num = 1000;
+ int i, r, fd;
+ char buf[30];
+
+ if (argc > 1)
+ num = atoi(argv[1]);
+ printf("will do %d iterations\n", num);
+
+ fd = open(".", O_RDONLY);
+ vold.fd = 0;
+ strcpy(vold.name, "current");
+ r = ioctl(fd, BTRFS_IOC_SUBVOL_CREATE, (unsigned long int)&vold);
+ printf("create current ioctl got %d\n", r ? errno:0);
+ if (r)
+ return 1;
+
+ for (i=0; i<num; i++) {
+ sprintf(buf, "current/dir.%d", i);
+ r = mkdir(buf, 0755);
+ printf("mkdir got %d\n", r ? errno:0);
+ if (r)
+ return 1;
+ }
+
+ va.fd = open("current", O_RDONLY);
+ va.flags = BTRFS_SUBVOL_CREATE_ASYNC;
+ for (i=0; i<num; i++) {
+ system("/bin/cp /boot/vmlinuz-3.2.0-ceph-00142-g9e98323 current/foo");
+ sprintf(buf, "current/dir.%d", i);
+ r = rmdir(buf);
+ printf("rmdir got %d\n", r ? errno:0);
+ if (r)
+ return 1;
+
+ if (i % 10) continue;
+ sprintf(va.name, "snap.%d", i);
+ r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, (unsigned long long)&va);
+ printf("ioctl got %d\n", r ? errno:0);
+ if (r)
+ return 1;
+ }
+ return 0;
+}