]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: remove unused btrfs_ioctl.h and tests 59838/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 17 Sep 2024 14:00:26 +0000 (10:00 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 17 Sep 2024 14:07:54 +0000 (10:07 -0400)
remove unused header whose GPL license was potentially problematic

Fixes: https://tracker.ceph.com/issues/68083
Signed-off-by: Casey Bodley <cbodley@redhat.com>
COPYING
qa/Makefile
qa/btrfs/.gitignore [deleted file]
qa/btrfs/Makefile [deleted file]
qa/btrfs/clone_range.c [deleted file]
qa/btrfs/create_async_snap.c [deleted file]
qa/btrfs/test_async_snap.c [deleted file]
qa/btrfs/test_rmdir_async_snap.c [deleted file]
src/btrfs_ioc_test.c [deleted file]
src/os/fs/btrfs_ioctl.h [deleted file]

diff --git a/COPYING b/COPYING
index 509306e16995abf198463ff46266147b3dfcfc9e..28b93b219353a303ab60597b8b0c79ff51aa314a 100644 (file)
--- a/COPYING
+++ b/COPYING
@@ -29,10 +29,6 @@ Files: src/mount/canonicalize.c
 Copyright: Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
 License: LGPL-2 or later
 
-Files: src/os/btrfs_ioctl.h
-Copyright: Copyright (C) 2007 Oracle.  All rights reserved.
-License: GPL2 (see COPYING-GPL2)
-
 Files: src/include/ceph_hash.cc
 Copyright: None
 License: Public domain
index ad655b7e743cb4468bfb6e691bfcb7ad875dd565..05dc834adbdb3c234698965491b1c031a5896b7f 100644 (file)
@@ -1,4 +1,4 @@
-DIRS= workunits btrfs
+DIRS= workunits
 
 all:
        for d in $(DIRS) ; do ( cd $$d ; $(MAKE) all ) ; done
diff --git a/qa/btrfs/.gitignore b/qa/btrfs/.gitignore
deleted file mode 100644 (file)
index 530c1b5..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-/clone_range
-/test_async_snap
-/create_async_snap
diff --git a/qa/btrfs/Makefile b/qa/btrfs/Makefile
deleted file mode 100644 (file)
index be95ecf..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-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/qa/btrfs/clone_range.c b/qa/btrfs/clone_range.c
deleted file mode 100644 (file)
index 0a88e16..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#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/qa/btrfs/create_async_snap.c b/qa/btrfs/create_async_snap.c
deleted file mode 100644 (file)
index 2ef22af..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#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/qa/btrfs/test_async_snap.c b/qa/btrfs/test_async_snap.c
deleted file mode 100644 (file)
index 211be95..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#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/qa/btrfs/test_rmdir_async_snap.c b/qa/btrfs/test_rmdir_async_snap.c
deleted file mode 100644 (file)
index 5dafaac..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#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;
-}
diff --git a/src/btrfs_ioc_test.c b/src/btrfs_ioc_test.c
deleted file mode 100644 (file)
index e12bad1..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <asm/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <fcntl.h>
-
-#include "common/safe_io.h"
-#include "os/btrfs_ioctl.h"
-
-void do_open_wr(const char *fname, int *fd)
-{
-       *fd = open(fname, O_WRONLY | O_CREAT, 0644);
-       if (*fd < 0) {
-               perror("open");
-               exit(1);
-       }
-}
-
-void do_open_rd(const char *fname, int *fd)
-{
-       *fd = open(fname, O_RDONLY);
-       if (*fd < 0) {
-               perror("open");
-               exit(1);
-       }
-}
-
-void do_lseek(int fd, int ofs)
-{
-       int rc = lseek(fd, ofs, SEEK_SET);
-       if (rc < 0) {
-               perror("lseek");
-               exit(1);
-       }
-}
-
-void do_write(int fd, int len)
-{
-       char *buf = malloc(len);
-       int rc;
-       if (!buf) {
-               printf("not enough memory\n");
-               exit(1);
-       }
-
-       memset(buf, 0, len);
-       rc = safe_write(fd, buf, len);
-       if (rc) {
-               fprintf(stderr, "safe_write failed with error %d (%s)\n",
-                       rc, strerror(rc));
-               exit(1);
-       }
-
-       if (rc != len) {
-               printf("invalid number of bytes written\n");
-               exit(1);
-       }
-
-       free(buf);
-}
-
-void do_link(const char *old, const char *new)
-{
-       int rc = link(old, new);
-       if (rc < 0) {
-               perror("link");
-               exit(1);
-       }
-}
-
-void do_clone_range(int from, int to, int off, int len)
-{
-       struct btrfs_ioctl_clone_range_args a;
-       int r;
-
-       a.src_fd = from;
-       a.src_offset = off;
-       a.src_length = len;
-       a.dest_offset = off;
-       r = ioctl(to, BTRFS_IOC_CLONE_RANGE, &a);
-       if (r < 0) {
-               perror("ioctl");
-               exit(1);
-       }
-}
-
-void do_snap_async(int fd, const char *name, unsigned long long *transid)
-{
-       struct btrfs_ioctl_async_vol_args async_args;
-       struct btrfs_ioctl_vol_args volargs;
-       int r;
-
-       strcpy(volargs.name, name);
-       volargs.fd = fd;
-
-       async_args.args = &volargs;
-       async_args.transid = transid;
-
-       r = ioctl(fd, BTRFS_IOC_SNAP_CREATE_ASYNC, &async_args);
-
-       if (r < 0) {
-               perror("ioctl");
-               exit(1);
-       }
-}
-
-void do_snap_destroy(int fd, const char *name)
-{
-       struct btrfs_ioctl_vol_args volargs;
-       int r;
-
-       strcpy(volargs.name, name);
-       volargs.fd = 0;
-
-       r = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &volargs);
-
-       if (r < 0) {
-               perror("snap_destroy: ioctl");
-               exit(1);
-       }
-}
-
-void do_snap_wait(int fd, unsigned long long transid)
-{
-       int r = ioctl(fd, BTRFS_IOC_WAIT_SYNC, &transid);
-       if (r < 0) {
-               perror("do_snap_wait: ioctl");
-               exit(1);
-       }
-}
-
-void usage_exit(char *arg)
-{
-       printf("usage: %s <btrfs_base> <snap_name>\n", arg);
-       exit(1);
-}
-
-#define TEMP_FILENAME "temp"
-#define DEST_FILENAME "dest"
-#define SRC_FILENAME "src"
-
-int main(int argc, char *argv[])
-{
-       const char *base_dir;
-       const char *snap_name;
-
-       int fd;
-       int i;
-       unsigned long long transid;
-
-       if (argc < 3)
-               usage_exit(argv[0]);
-
-       base_dir = argv[1];
-       snap_name = argv[2];
-
-       for (i=0; i<10; i++) {
-               printf("%d\n", i);
-               do_open_rd(base_dir, &fd);
-               do_snap_async(fd, snap_name, &transid);
-               sleep(2);
-               //do_snap_wait(fd, transid);
-               do_snap_destroy(fd, snap_name);
-               close(fd);
-       }
-       
-       return 0;
-}
diff --git a/src/os/fs/btrfs_ioctl.h b/src/os/fs/btrfs_ioctl.h
deleted file mode 100644 (file)
index 277498c..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2007 Oracle.  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 v2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will 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 to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- */
-
-#ifndef __IOCTL_
-#define __IOCTL_
-
-#if defined(__linux__)
-#include <linux/ioctl.h>
-#elif defined(__FreeBSD__)
-#include <sys/ioctl.h>
-#endif
-
-#define BTRFS_IOCTL_MAGIC 0x94
-#define BTRFS_VOL_NAME_MAX 255
-
-/* this should be 4k */
-#define BTRFS_PATH_NAME_MAX 4087
-struct btrfs_ioctl_vol_args {
-       __s64 fd;
-       char name[BTRFS_PATH_NAME_MAX + 1];
-};
-
-#define BTRFS_SUBVOL_CREATE_ASYNC      (1ULL << 0)
-
-#define BTRFS_SUBVOL_NAME_MAX 4039
-struct btrfs_ioctl_vol_args_v2 {
-       __s64 fd;
-       __u64 transid;
-       __u64 flags;
-       __u64 unused[4];
-       char name[BTRFS_SUBVOL_NAME_MAX + 1];
-};
-
-#define BTRFS_INO_LOOKUP_PATH_MAX 4080
-struct btrfs_ioctl_ino_lookup_args {
-       __u64 treeid;
-       __u64 objectid;
-       char name[BTRFS_INO_LOOKUP_PATH_MAX];
-};
-
-struct btrfs_ioctl_search_key {
-       /* which root are we searching.  0 is the tree of tree roots */
-       __u64 tree_id;
-
-       /* keys returned will be >= min and <= max */
-       __u64 min_objectid;
-       __u64 max_objectid;
-
-       /* keys returned will be >= min and <= max */
-       __u64 min_offset;
-       __u64 max_offset;
-
-       /* max and min transids to search for */
-       __u64 min_transid;
-       __u64 max_transid;
-
-       /* keys returned will be >= min and <= max */
-       __u32 min_type;
-       __u32 max_type;
-
-       /*
-        * how many items did userland ask for, and how many are we
-        * returning
-        */
-       __u32 nr_items;
-
-       /* align to 64 bits */
-       __u32 unused;
-
-       /* some extra for later */
-       __u64 unused1;
-       __u64 unused2;
-       __u64 unused3;
-       __u64 unused4;
-};
-
-struct btrfs_ioctl_search_header {
-       __u64 transid;
-       __u64 objectid;
-       __u64 offset;
-       __u32 type;
-       __u32 len;
-};
-
-#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
-/*
- * the buf is an array of search headers where
- * each header is followed by the actual item
- * the type field is expanded to 32 bits for alignment
- */
-struct btrfs_ioctl_search_args {
-       struct btrfs_ioctl_search_key key;
-       char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
-};
-
-struct btrfs_ioctl_clone_range_args {
-  __s64 src_fd;
-  __u64 src_offset, src_length;
-  __u64 dest_offset;
-};
-
-/* flags for the defrag range ioctl */
-#define BTRFS_DEFRAG_RANGE_COMPRESS 1
-#define BTRFS_DEFRAG_RANGE_START_IO 2
-
-struct btrfs_ioctl_defrag_range_args {
-       /* start of the defrag operation */
-       __u64 start;
-
-       /* number of bytes to defrag, use (u64)-1 to say all */
-       __u64 len;
-
-       /*
-        * flags for the operation, which can include turning
-        * on compression for this one defrag
-        */
-       __u64 flags;
-
-       /*
-        * any extent bigger than this will be considered
-        * already defragged.  Use 0 to take the kernel default
-        * Use 1 to say every single extent must be rewritten
-        */
-       __u32 extent_thresh;
-
-       /* spare for later */
-       __u32 unused[5];
-};
-
-struct btrfs_ioctl_space_info {
-       __u64 flags;
-       __u64 total_bytes;
-       __u64 used_bytes;
-};
-
-struct btrfs_ioctl_space_args {
-       __u64 space_slots;
-       __u64 total_spaces;
-       struct btrfs_ioctl_space_info spaces[0];
-};
-
-#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
-                                  struct btrfs_ioctl_vol_args)
-/* trans start and trans end are dangerous, and only for
- * use by applications that know how to avoid the
- * resulting deadlocks
- */
-#define BTRFS_IOC_TRANS_START  _IO(BTRFS_IOCTL_MAGIC, 6)
-#define BTRFS_IOC_TRANS_END    _IO(BTRFS_IOCTL_MAGIC, 7)
-#define BTRFS_IOC_SYNC         _IO(BTRFS_IOCTL_MAGIC, 8)
-
-#define BTRFS_IOC_CLONE        _IOW(BTRFS_IOCTL_MAGIC, 9, int)
-#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
-                                  struct btrfs_ioctl_vol_args)
-
-#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
-                                 struct btrfs_ioctl_clone_range_args)
-
-#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
-                                  struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
-                               struct btrfs_ioctl_vol_args)
-#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
-                               struct btrfs_ioctl_defrag_range_args)
-#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
-                                  struct btrfs_ioctl_search_args)
-#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
-                                  struct btrfs_ioctl_ino_lookup_args)
-#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, u64)
-#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
-                                   struct btrfs_ioctl_space_args)
-#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
-#define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
-#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
-                                  struct btrfs_ioctl_vol_args_v2)
-#endif