]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlockDevice: add parameter 'bool rotational' 9137/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 24 May 2016 11:50:17 +0000 (19:50 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 24 May 2016 12:04:12 +0000 (20:04 +0800)
Using this parameter indicate whether device is rotational or not.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/bluestore/BlockDevice.h
src/os/bluestore/KernelDevice.cc
src/os/bluestore/NVMEDevice.cc

index 5815d4000fa11a96a7d7dee0100e4776a3d9a0fe..14608ebcca805ce08763f895547cf76945274458 100644 (file)
@@ -72,8 +72,8 @@ class BlockDevice {
   std::mutex ioc_reap_lock;
   vector<IOContext*> ioc_reap_queue;
   std::atomic_int ioc_reap_count = {0};
-
 public:
+  bool rotational;
   BlockDevice() = default;
   virtual ~BlockDevice() = default;
   typedef void (*aio_callback_t)(void *handle, void *aio);
@@ -81,7 +81,7 @@ public:
   static BlockDevice *create(
       const string& path, aio_callback_t cb, void *cbpriv);
   virtual bool supported_bdev_label() { return true; }
-
+  virtual bool is_rotational() { return rotational; }
   virtual void aio_submit(IOContext *ioc) = 0;
 
   virtual uint64_t get_size() const = 0;
index e488b5ef61a04dc31e7ded4874fbcb548f07e46a..f58901298926a7b9d7d766a8ee5264df83d69f7e 100644 (file)
@@ -115,9 +115,13 @@ int KernelDevice::open(string p)
     if (r < 0) {
       goto out_fail;
     }
+
+    rotational = block_device_is_rotational(path.c_str());
     size = s;
   } else {
     size = st.st_size;
+    //regular file is rotational device
+    rotational = true;
   }
 
   // Operate as though the block size is 4 KB.  The backing file
@@ -142,6 +146,7 @@ int KernelDevice::open(string p)
          << " (" << pretty_si_t(size) << "B)"
          << " block_size " << block_size
          << " (" << pretty_si_t(block_size) << "B)"
+         << " " << (rotational ? "rotational" : "non-rotational")
          << dendl;
   return 0;
 
index d83b7721678e090312d4d4da9728960ce8fb2104..871d624b6df77f71cebb5751733f3b6c2872893f 100644 (file)
@@ -834,6 +834,9 @@ int NVMEDevice::open(string p)
     zeros.zero();
   }
 
+  //nvme is non-rotational device.
+  rotational = false;
+
   dout(1) << __func__ << " size " << size << " (" << pretty_si_t(size) << "B)"
           << " block_size " << block_size << " (" << pretty_si_t(block_size)
           << "B)" << dendl;