]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: move size and block_size to the base class BlockDevice. 16886/head
authorPan Liu <wanjun.lp@alibaba-inc.com>
Tue, 8 Aug 2017 15:53:41 +0000 (23:53 +0800)
committerPan Liu <wanjun.lp@alibaba-inc.com>
Tue, 8 Aug 2017 15:53:41 +0000 (23:53 +0800)
Signed-off-by: Pan Liu <wanjun.lp@alibaba-inc.com>
src/os/bluestore/BlockDevice.h
src/os/bluestore/KernelDevice.cc
src/os/bluestore/KernelDevice.h
src/os/bluestore/NVMEDevice.cc
src/os/bluestore/NVMEDevice.h
src/os/bluestore/PMEMDevice.cc
src/os/bluestore/PMEMDevice.h

index 5d511ddbb5708a20132c9b8eae267f0c70cec72a..45e4df8c5301cc8eb293e4ce9b84889953069f63 100644 (file)
@@ -88,10 +88,16 @@ private:
   std::atomic_int ioc_reap_count = {0};
 
 protected:
+  uint64_t size;
+  uint64_t block_size;
   bool rotational = true;
 
 public:
-  BlockDevice(CephContext* cct) : cct(cct) {}
+  BlockDevice(CephContext* cct) 
+  : cct(cct),
+    size(0),
+    block_size(0)
+ {}
   virtual ~BlockDevice() = default;
   typedef void (*aio_callback_t)(void *handle, void *aio);
 
@@ -102,8 +108,8 @@ public:
 
   virtual void aio_submit(IOContext *ioc) = 0;
 
-  virtual uint64_t get_size() const = 0;
-  virtual uint64_t get_block_size() const = 0;
+  uint64_t get_size() const { return size; }
+  uint64_t get_block_size() const { return block_size; }
 
   virtual int collect_metadata(std::string prefix, std::map<std::string,std::string> *pm) const = 0;
 
index 3ae5be1ea1e0847b63a882142ac3bba81e0a7e3e..b1e9126326af54e618fd0675bea1cd460b49d3d6 100644 (file)
@@ -37,7 +37,6 @@ KernelDevice::KernelDevice(CephContext* cct, aio_callback_t cb, void *cbpriv)
   : BlockDevice(cct),
     fd_direct(-1),
     fd_buffered(-1),
-    size(0), block_size(0),
     fs(NULL), aio(false), dio(false),
     debug_lock("KernelDevice::debug_lock"),
     aio_queue(cct->_conf->bdev_aio_max_queue_depth),
index f04b7f972af3a8c46e6e86e569e945c1571d3f94..9999ea282a290e70161b1f5cdc95a426e498065e 100644 (file)
@@ -25,8 +25,6 @@
 
 class KernelDevice : public BlockDevice {
   int fd_direct, fd_buffered;
-  uint64_t size;
-  uint64_t block_size;
   std::string path;
   FS *fs;
   bool aio, dio;
@@ -79,13 +77,6 @@ public:
 
   void aio_submit(IOContext *ioc) override;
 
-  uint64_t get_size() const override {
-    return size;
-  }
-  uint64_t get_block_size() const override {
-    return block_size;
-  }
-
   int collect_metadata(std::string prefix, map<std::string,std::string> *pm) const override;
 
   int read(uint64_t off, uint64_t len, bufferlist *pbl,
index 2eb278aa0d08c2d6b184dcd3dc739e09406bfd3b..56eef58ac540060787a789697f2dbf33f9d62ef6 100644 (file)
@@ -858,8 +858,6 @@ void io_complete(void *t, const struct spdk_nvme_cpl *completion)
 NVMEDevice::NVMEDevice(CephContext* cct, aio_callback_t cb, void *cbpriv)
   :   BlockDevice(cct),
       driver(nullptr),
-      size(0),
-      block_size(0),
       aio_stop(false),
       buffer_lock("NVMEDevice::buffer_lock"),
       aio_callback(cb),
index 40378eaec16b33bf3fc30923184a492e28b12689..4ce6b7ec57787bc84f73f78ad2ec26ab824d3111 100644 (file)
@@ -50,9 +50,6 @@ class NVMEDevice : public BlockDevice {
   SharedDriverData *driver;
   string name;
 
-  uint64_t size;
-  uint64_t block_size;
-
   bool aio_stop;
 
   struct BufferedExtents {
@@ -211,13 +208,6 @@ class NVMEDevice : public BlockDevice {
 
   void aio_submit(IOContext *ioc) override;
 
-  uint64_t get_size() const override {
-    return size;
-  }
-  uint64_t get_block_size() const override {
-    return block_size;
-  }
-
   int read(uint64_t off, uint64_t len, bufferlist *pbl,
            IOContext *ioc,
            bool buffered) override;
index 262eeb1c3bb0e49c958032b881fc515fd306ef58..b86ddc080b21ef7d8a11abc5cce5421bcfddee51 100644 (file)
@@ -36,7 +36,6 @@
 PMEMDevice::PMEMDevice(CephContext *cct, aio_callback_t cb, void *cbpriv)
   : BlockDevice(cct),
     fd(-1), addr(0),
-    size(0), block_size(0),
     debug_lock("PMEMDevice::debug_lock"),
     injecting_crash(0)
 {
index c08e3cc5f2f1ae4c633cbb6bace7d93a2ddc8aa2..ab3507192c88b5a61ec823db3bf15e18c7dc5b79 100644 (file)
@@ -27,8 +27,6 @@
 class PMEMDevice : public BlockDevice {
   int fd;
   char *addr; //the address of mmap
-  uint64_t size;
-  uint64_t block_size;
   std::string path;
 
   Mutex debug_lock;
@@ -43,13 +41,6 @@ public:
 
   void aio_submit(IOContext *ioc) override;
 
-  uint64_t get_size() const override {
-    return size;
-  }
-  uint64_t get_block_size() const override {
-    return block_size;
-  }
-
   int collect_metadata(std::string prefix, map<std::string,std::string> *pm) const override;
 
   int read(uint64_t off, uint64_t len, bufferlist *pbl,