]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: use SNAP_DESTROY_ASYNC ioctl if available
authorSage Weil <sage@newdream.net>
Thu, 8 Apr 2010 17:34:50 +0000 (10:34 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Fri, 22 Oct 2010 17:16:20 +0000 (10:16 -0700)
src/os/FileStore.cc
src/os/FileStore.h
src/os/btrfs_ioctl.h

index 8ece0697d56e82e359188205aa8382d1a90f7526..901d2a298e631da650ccde406e1ab166c287a84a 100644 (file)
@@ -558,9 +558,17 @@ int FileStore::_detect_fs()
       
        // clean up
        volargs.fd = 0;
-       r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &volargs);
-       if (r != 0) {
-         dout(0) << "mount btrfs SNAP_DESTROY failed: " << strerror_r(-r, buf, sizeof(buf)) << dendl;
+       r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY_ASYNC, &volargs);
+       if (r == 0) {
+         dout(0) << "mount btrfs SNAP_DESTROY_ASYNC is supported" << dendl;
+         btrfs_snap_destroy_async = true;
+       } else {
+         dout(0) << "mount btrfs SNAP_DESTROY_ASYNC is NOT supported: "
+                 << strerror_r(-r, buf, sizeof(buf)) << dendl;
+         r = ::ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &volargs);
+         if (r != 0) {
+           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: "
@@ -690,7 +698,9 @@ int FileStore::mount()
       // drop current
       snapargs.fd = 0;
       strcpy(snapargs.name, "current");
-      int r = ::ioctl(basedir_fd, BTRFS_IOC_SNAP_DESTROY, &snapargs);
+      int r = ::ioctl(basedir_fd,
+                     btrfs_snap_destroy_async ? BTRFS_IOC_SNAP_DESTROY_ASYNC:BTRFS_IOC_SNAP_DESTROY,
+                     &snapargs);
       if (r) {
        char buf[80];
        dout(0) << "error removing old current subvol: " << strerror_r(errno, buf, sizeof(buf)) << dendl;
index dc26e15a34ba33db49d8422547b41ff8f0f38cf3..a8ddcbf78182cbd377bc2377f47257f45d8582f4 100644 (file)
@@ -49,6 +49,7 @@ class FileStore : public JournalingObjectStore {
   bool btrfs_snap_create;
   bool btrfs_snap_destroy;
   bool btrfs_snap_create_async;
+  bool btrfs_snap_destroy_async;
   bool btrfs_wait_sync;
   int fsid_fd, op_fd;
 
@@ -178,6 +179,7 @@ class FileStore : public JournalingObjectStore {
     btrfs_snap_create(false),
     btrfs_snap_destroy(false),
     btrfs_snap_create_async(false),
+    btrfs_snap_destroy_async(false),
     btrfs_wait_sync(false),
     fsid_fd(-1), op_fd(-1),
     attrs(this), fake_attrs(false), 
index 21ff3c1d3537751b9561f61125e8da1ae5b75230..0c33ab730d65b658755bd0d1e0ab960aeaa5ec3e 100644 (file)
@@ -184,4 +184,6 @@ struct btrfs_ioctl_space_args {
 #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_vol_args)
+#define BTRFS_IOC_SNAP_DESTROY_ASYNC _IOW(BTRFS_IOCTL_MAGIC, 24, \
+                                  struct btrfs_ioctl_vol_args)
 #endif