diff options
author | Qiaowei Ren <qiaowei.ren@intel.com> | 2018-01-04 13:43:33 +0800 |
---|---|---|
committer | Qiaowei Ren <qiaowei.ren@intel.com> | 2018-01-05 11:59:39 +0800 |
commit | 812ff6ca9fcd3e629e49d4328905f33eee8ca3f5 (patch) | |
tree | 04ece7b4da00d9d2f98093774594f4057ae561d4 /src/ceph/qa/btrfs | |
parent | 15280273faafb77777eab341909a3f495cf248d9 (diff) |
initial code repo
This patch creates initial code repo.
For ceph, luminous stable release will be used for base code,
and next changes and optimization for ceph will be added to it.
For opensds, currently any changes can be upstreamed into original
opensds repo (https://github.com/opensds/opensds), and so stor4nfv
will directly clone opensds code to deploy stor4nfv environment.
And the scripts for deployment based on ceph and opensds will be
put into 'ci' directory.
Change-Id: I46a32218884c75dda2936337604ff03c554648e4
Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
Diffstat (limited to 'src/ceph/qa/btrfs')
-rw-r--r-- | src/ceph/qa/btrfs/.gitignore | 3 | ||||
-rw-r--r-- | src/ceph/qa/btrfs/Makefile | 11 | ||||
-rw-r--r-- | src/ceph/qa/btrfs/clone_range.c | 35 | ||||
-rw-r--r-- | src/ceph/qa/btrfs/create_async_snap.c | 34 | ||||
-rw-r--r-- | src/ceph/qa/btrfs/test_async_snap.c | 83 | ||||
-rwxr-xr-x | src/ceph/qa/btrfs/test_rmdir_async_snap | bin | 0 -> 8559 bytes | |||
-rw-r--r-- | src/ceph/qa/btrfs/test_rmdir_async_snap.c | 62 |
7 files changed, 228 insertions, 0 deletions
diff --git a/src/ceph/qa/btrfs/.gitignore b/src/ceph/qa/btrfs/.gitignore new file mode 100644 index 0000000..530c1b5 --- /dev/null +++ b/src/ceph/qa/btrfs/.gitignore @@ -0,0 +1,3 @@ +/clone_range +/test_async_snap +/create_async_snap diff --git a/src/ceph/qa/btrfs/Makefile b/src/ceph/qa/btrfs/Makefile new file mode 100644 index 0000000..be95ecf --- /dev/null +++ b/src/ceph/qa/btrfs/Makefile @@ -0,0 +1,11 @@ +CFLAGS = -Wall -Wextra -D_GNU_SOURCE + +TARGETS = clone_range test_async_snap create_async_snap + +.c: + $(CC) $(CFLAGS) $@.c -o $@ + +all: $(TARGETS) + +clean: + rm $(TARGETS) diff --git a/src/ceph/qa/btrfs/clone_range.c b/src/ceph/qa/btrfs/clone_range.c new file mode 100644 index 0000000..0a88e16 --- /dev/null +++ b/src/ceph/qa/btrfs/clone_range.c @@ -0,0 +1,35 @@ +#include <fcntl.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <string.h> + +#include <linux/types.h> +#include "../../src/os/btrfs_ioctl.h" +#include <stdio.h> +#include <errno.h> + +int main(int argc, char **argv) +{ + struct btrfs_ioctl_clone_range_args ca; + int dfd; + int r; + + if (argc < 6) { + printf("usage: %s <srcfn> <srcoffset> <srclen> <destfn> <destoffset>\n", argv[0]); + exit(1); + } + + ca.src_fd = open(argv[1], O_RDONLY); + ca.src_offset = atoi(argv[2]); + ca.src_length = atoi(argv[3]); + dfd = open(argv[4], O_WRONLY|O_CREAT); + ca.dest_offset = atoi(argv[5]); + + r = ioctl(dfd, BTRFS_IOC_CLONE_RANGE, &ca); + printf("clone_range %s %lld %lld~%lld to %s %d %lld = %d %s\n", + argv[1], ca.src_fd, + ca.src_offset, ca.src_length, + argv[4], dfd, + ca.dest_offset, r, strerror(errno)); + return r; +} diff --git a/src/ceph/qa/btrfs/create_async_snap.c b/src/ceph/qa/btrfs/create_async_snap.c new file mode 100644 index 0000000..2ef22af --- /dev/null +++ b/src/ceph/qa/btrfs/create_async_snap.c @@ -0,0 +1,34 @@ +#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; + +int main(int argc, char **argv) +{ + int fd; + int r; + + if (argc != 3) { + printf("usage: %s <source subvol> <name>\n", argv[0]); + return 1; + } + printf("creating snap ./%s from %s\n", argv[2], argv[1]); + fd = open(".", O_RDONLY); + va.fd = open(argv[1], O_RDONLY); + va.flags = BTRFS_SUBVOL_CREATE_ASYNC; + strcpy(va.name, argv[2]); + r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, (unsigned long long)&va); + printf("result %d\n", r ? -errno:0); + return r; +} diff --git a/src/ceph/qa/btrfs/test_async_snap.c b/src/ceph/qa/btrfs/test_async_snap.c new file mode 100644 index 0000000..211be95 --- /dev/null +++ b/src/ceph/qa/btrfs/test_async_snap.c @@ -0,0 +1,83 @@ +#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 max = 4; + +void check_return(int r) +{ + if (r < 0) { + printf("********* failed with %d %s ********\n", errno, strerror(errno)); + exit(1); + } +} + +int main(int argc, char **argv) +{ + int num = 1000; + + if (argc > 1) + num = atoi(argv[1]); + printf("will do %d iterations\n", num); + + int cwd = open(".", O_RDONLY); + printf("cwd = %d\n", cwd); + while (num-- > 0) { + if (rand() % 10 == 0) { + __u64 transid; + int r; + printf("sync starting\n"); + r = ioctl(cwd, BTRFS_IOC_START_SYNC, &transid); + check_return(r); + printf("sync started, transid %lld, waiting\n", transid); + r = ioctl(cwd, BTRFS_IOC_WAIT_SYNC, &transid); + check_return(r); + printf("sync finished\n"); + } + + int i = rand() % max; + struct stat st; + va.fd = cwd; + sprintf(va.name, "test.%d", i); + va.transid = 0; + int r = stat(va.name, &st); + if (r < 0) { + if (rand() % 3 == 0) { + printf("snap create (sync) %s\n", va.name); + va.flags = 0; + r = ioctl(cwd, BTRFS_IOC_SNAP_CREATE_V2, &va); + check_return(r); + } else { + printf("snap create (async) %s\n", va.name); + va.flags = BTRFS_SUBVOL_CREATE_ASYNC; + r = ioctl(cwd, BTRFS_IOC_SNAP_CREATE_V2, &va); + check_return(r); + printf("snap created, transid %lld\n", va.transid); + if (rand() % 2 == 0) { + printf("waiting for async snap create\n"); + r = ioctl(cwd, BTRFS_IOC_WAIT_SYNC, &va.transid); + check_return(r); + } + } + } else { + printf("snap remove %s\n", va.name); + vold.fd = va.fd; + strcpy(vold.name, va.name); + r = ioctl(cwd, BTRFS_IOC_SNAP_DESTROY, &vold); + check_return(r); + } + } + return 0; +} diff --git a/src/ceph/qa/btrfs/test_rmdir_async_snap b/src/ceph/qa/btrfs/test_rmdir_async_snap Binary files differnew file mode 100755 index 0000000..f128a6b --- /dev/null +++ b/src/ceph/qa/btrfs/test_rmdir_async_snap diff --git a/src/ceph/qa/btrfs/test_rmdir_async_snap.c b/src/ceph/qa/btrfs/test_rmdir_async_snap.c new file mode 100644 index 0000000..5dafaac --- /dev/null +++ b/src/ceph/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; +} |