From: Pan Liu Date: Tue, 8 Aug 2017 15:53:41 +0000 (+0800) Subject: os/bluestore: move size and block_size to the base class BlockDevice. X-Git-Tag: v13.0.0~167^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F16886%2Fhead;p=ceph.git os/bluestore: move size and block_size to the base class BlockDevice. Signed-off-by: Pan Liu --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 5d511ddbb570..45e4df8c5301 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -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 *pm) const = 0; diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 3ae5be1ea1e0..b1e9126326af 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -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), diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index f04b7f972af3..9999ea282a29 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -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 *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl, diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 2eb278aa0d08..56eef58ac540 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -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), diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 40378eaec16b..4ce6b7ec5778 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -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; diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 262eeb1c3bb0..b86ddc080b21 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -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) { diff --git a/src/os/bluestore/PMEMDevice.h b/src/os/bluestore/PMEMDevice.h index c08e3cc5f2f1..ab3507192c88 100644 --- a/src/os/bluestore/PMEMDevice.h +++ b/src/os/bluestore/PMEMDevice.h @@ -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 *pm) const override; int read(uint64_t off, uint64_t len, bufferlist *pbl,