]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: detect final version of async ioctl SNAP_CREATE_V2
authorSage Weil <sage@newdream.net>
Sat, 11 Dec 2010 00:26:06 +0000 (16:26 -0800)
committerSage Weil <sage@newdream.net>
Wed, 15 Dec 2010 21:39:57 +0000 (13:39 -0800)
Li's revised interface for the async snap ioctl is more flexible.  Update
the ioctl call sites and detection code accordingly.

Signed-off-by: Sage Weil <sage@newdream.net>
src/os/FileStore.cc
src/os/FileStore.h
src/os/btrfs_ioctl.h

index b078692e10a7b9db83d6bf4a8229c5f7995ace5f..8cf22e97233f8d29d5d45c434e3dc64f2b1c4eb2 100644 (file)
@@ -847,8 +847,9 @@ int FileStore::_detect_fs()
       vol_args.fd = 0;
       strcpy(vol_args.name, "async_snap_test");
 
-      struct btrfs_ioctl_async_vol_args async_args;
+      struct btrfs_ioctl_vol_args_v2 async_args;
       async_args.fd = fd;
+      async_args.flags = BTRFS_SUBVOL_CREATE_ASYNC;
       strcpy(async_args.name, "async_snap_test");
 
       // remove old one, first
@@ -860,15 +861,11 @@ int FileStore::_detect_fs()
          dout(0) << "mount  failed to remove old async_snap_test: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
       }
 
-      /*
-       
-       do not autodetect this yet until the btrfs ioctl interface is finalized!
-
-      r = ::ioctl(fd, BTRFS_IOC_SNAP_CREATE_ASYNC, &async_args);
-      dout(0) << "mount btrfs SNAP_CREATE_ASYNC got " << r << " " << strerror_r(-r, buf, sizeof(buf)) << dendl;
+      r = ::ioctl(fd, BTRFS_IOC_SNAP_CREATE_V2, &async_args);
+      dout(0) << "mount btrfs SNAP_CREATE_V2 got " << r << " " << strerror_r(-r, buf, sizeof(buf)) << dendl;
       if (r == 0 || errno == EEXIST) {
-       dout(0) << "mount btrfs SNAP_CREATE_ASYNC is supported" << dendl;
-       btrfs_snap_create_async = true;
+       dout(0) << "mount btrfs SNAP_CREATE_V2 is supported" << dendl;
+       btrfs_snap_create_v2 = true;
       
        // clean up
        r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &vol_args);
@@ -876,17 +873,16 @@ int FileStore::_detect_fs()
          dout(0) << "mount btrfs SNAP_DESTROY failed: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
        }
       } else {
-       dout(0) << "mount btrfs SNAP_CREATE_ASYNC is NOT supported: "
+       dout(0) << "mount btrfs SNAP_CREATE_V2 is NOT supported: "
                << strerror_r(-r, buf, sizeof(buf)) << dendl;
       }
-      */
     }
 
-    if (g_conf.filestore_btrfs_snap && !btrfs_snap_create_async) {
-      dout(0) << "mount WARNING: btrfs snaps enabled, but no SNAP_CREATE_ASYNC ioctl (from kernel 2.6.37+)" << dendl;
+    if (g_conf.filestore_btrfs_snap && !btrfs_snap_create_v2) {
+      dout(0) << "mount WARNING: btrfs snaps enabled, but no SNAP_CREATE_V2 ioctl (from kernel 2.6.37+)" << dendl;
       cerr << TEXT_YELLOW
           << " ** WARNING: 'filestore btrfs snap' is enabled (for safe transactions,\n"         
-          << "             rollback), but btrfs does not support the SNAP_CREATE_ASYNC ioctl\n"
+          << "             rollback), but btrfs does not support the SNAP_CREATE_V2 ioctl\n"
           << "             (added in Linux 2.6.37).  Expect slow btrfs sync/commit\n"
           << "             performance.\n"
           << TEXT_NORMAL;
@@ -1147,12 +1143,12 @@ int FileStore::mount()
       } else if (!g_conf.filestore_btrfs_snap) {
        g_conf.filestore_journal_writeahead = true;
        dout(0) << "mount: enabling WRITEAHEAD journal mode: 'filestore btrfs snap' mode is not enabled" << dendl;
-      } else if (!btrfs_snap_create_async) {
+      } else if (!btrfs_snap_create_v2) {
        g_conf.filestore_journal_writeahead = true;
-       dout(0) << "mount: enabling WRITEAHEAD journal mode: btrfs SNAP_CREATE_ASYNC ioctl not detected (v2.6.37+)" << dendl;
+       dout(0) << "mount: enabling WRITEAHEAD journal mode: btrfs SNAP_CREATE_V2 ioctl not detected (v2.6.37+)" << dendl;
       } else {
        g_conf.filestore_journal_parallel = true;
-       dout(0) << "mount: enabling PARALLEL journal mode: btrfs, SNAP_CREATE_ASYNC detected and 'filestore btrfs snap' mode is enabled" << dendl;
+       dout(0) << "mount: enabling PARALLEL journal mode: btrfs, SNAP_CREATE_V2 detected and 'filestore btrfs snap' mode is enabled" << dendl;
       }
     } else {
       if (g_conf.filestore_journal_writeahead)
@@ -2299,15 +2295,16 @@ void FileStore::sync_entry()
 
       if (do_snap) {
 
-       if (btrfs_snap_create_async) {
+       if (btrfs_snap_create_v2) {
          // be smart!
-         struct btrfs_ioctl_async_vol_args async_args;
+         struct btrfs_ioctl_vol_args_v2 async_args;
          async_args.fd = current_fd;
+         async_args.flags = BTRFS_SUBVOL_CREATE_ASYNC;
          snprintf(async_args.name, sizeof(async_args.name), COMMIT_SNAP_ITEM,
                   (long long unsigned)cp);
 
          dout(10) << "taking async snap '" << async_args.name << "'" << dendl;
-         int r = ::ioctl(basedir_fd, BTRFS_IOC_SNAP_CREATE_ASYNC, &async_args);
+         int r = ::ioctl(basedir_fd, BTRFS_IOC_SNAP_CREATE_V2, &async_args);
          char buf[100];
          dout(20) << "async snap create '" << async_args.name
                   << "' transid " << async_args.transid
index 3c4e2a26d67b7f6a8d623f828703e60f14efcc99..79d43e908c0e3e0682da56bc56b3d707f7d147bb 100644 (file)
@@ -46,7 +46,7 @@ class FileStore : public JournalingObjectStore {
   bool btrfs_clone_range;
   bool btrfs_snap_create;
   bool btrfs_snap_destroy;
-  bool btrfs_snap_create_async;
+  bool btrfs_snap_create_v2;
   bool btrfs_wait_sync;
   bool ioctl_fiemap;
   int fsid_fd, op_fd;
@@ -176,7 +176,7 @@ class FileStore : public JournalingObjectStore {
     btrfs(false), btrfs_trans_start_end(false), btrfs_clone_range(false),
     btrfs_snap_create(false),
     btrfs_snap_destroy(false),
-    btrfs_snap_create_async(false),
+    btrfs_snap_create_v2(false),
     btrfs_wait_sync(false),
     ioctl_fiemap(false),
     fsid_fd(-1), op_fd(-1),
index 17c99ebdf96049a8ad028cd6e138355df86f0c9e..c344d12c646bf7d1cbb953f8c4aba6257b6db8b9 100644 (file)
@@ -30,11 +30,15 @@ struct btrfs_ioctl_vol_args {
        char name[BTRFS_PATH_NAME_MAX + 1];
 };
 
-#define BTRFS_SNAPSHOT_NAME_MAX 4079
-struct btrfs_ioctl_async_vol_args {
+#define BTRFS_SUBVOL_CREATE_ASYNC      (1ULL << 0)
+
+#define BTRFS_SUBVOL_NAME_MAX 4039
+struct btrfs_ioctl_vol_args_v2 {
        __s64 fd;
        __u64 transid;
-       char name[BTRFS_SNAPSHOT_NAME_MAX + 1];
+       __u64 flags;
+       __u64 unused[4];
+       char name[BTRFS_SUBVOL_NAME_MAX + 1];
 };
 
 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
@@ -187,6 +191,6 @@ struct btrfs_ioctl_space_args {
                                    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_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 23, \
-                                  struct btrfs_ioctl_async_vol_args)
+#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
+                                  struct btrfs_ioctl_vol_args_v2)
 #endif