From: Jianpeng Ma Date: Tue, 24 May 2016 11:50:17 +0000 (+0800) Subject: os/bluestore/BlockDevice: add parameter 'bool rotational' X-Git-Tag: v11.0.0~376^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97b974ef8fadbcf0793c38ece90cf5216e8d4e61;p=ceph.git os/bluestore/BlockDevice: add parameter 'bool rotational' Using this parameter indicate whether device is rotational or not. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 5815d4000fa..14608ebcca8 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -72,8 +72,8 @@ class BlockDevice { std::mutex ioc_reap_lock; vector 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; diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index e488b5ef61a..f5890129892 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -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; diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index d83b7721678..871d624b6df 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -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;