]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
filestore: detect new btrfs ioctls
authorSage Weil <sage@newdream.net>
Thu, 9 Oct 2008 23:02:50 +0000 (16:02 -0700)
committerSage Weil <sage@newdream.net>
Mon, 13 Oct 2008 19:02:27 +0000 (12:02 -0700)
Don't use them yet, though.

src/os/FileStore.cc
src/os/FileStore.h

index c639186deadc54547753e6acc6b20475ed3cbb00..3ab0cbd23d3b40421fdabcc967e741dd1c4fc54f 100644 (file)
 # 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_WAIT_FOR_SYNC _IO(BTRFS_IOCTL_MAGIC, 5)
+struct btrfs_ioctl_clone_range_args {
+  __s64 src_fd;
+  __u64 src_offset, src_length;
+  __u64 dest_offset;
+};
+
+#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
+                                 struct btrfs_ioctl_clone_range_args)
 
 // alternate usertrans interface...
 #define BTRFS_IOC_USERTRANS_OPEN   1
@@ -413,17 +422,26 @@ int FileStore::mount()
 
   // is this btrfs?
   Transaction empty;
-  btrfs = true;
+  btrfs = 1;
   btrfs_trans_start_end = true;  // trans start/end interface
   r = apply_transaction(empty, 0);
   if (r == 0) {
     dout(0) << "mount detected btrfs" << dendl;
+
+    // do we have WAIT_FOR_SYNC and CLONE_RANGE?
+    r = ::ioctl(fd, BTRFS_IOC_CLONE_RANGE, 0);  // pass in a BAD POINTER ...
+    assert(r < 0);
+    if (errno == -EFAULT) {
+      dout(0) << "mount detected shiny new btrfs" << dendl;      
+      btrfs = 2;
+    } else {
+      dout(0) << "mount detected dingey old btrfs" << dendl;
+    }
   } else {
     dout(0) << "mount did NOT detect btrfs: " << strerror(-r) << dendl;
-    btrfs = false;
+    btrfs = 0;
   }
 
-
   // all okay.
   return 0;
 }
index 5295a2e9fd8836f5ebc1de7337a41a8fbfc805ca..603de94a4587e541fd7ef8dcb7602550f0c6bca1 100644 (file)
@@ -39,7 +39,7 @@ class FileStore : public JournalingObjectStore {
   string basedir;
   __u64 fsid;
   
-  bool btrfs;
+  int btrfs;
   bool btrfs_trans_start_end;
   int lock_fd;