From 97b974ef8fadbcf0793c38ece90cf5216e8d4e61 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Tue, 24 May 2016 19:50:17 +0800 Subject: [PATCH] os/bluestore/BlockDevice: add parameter 'bool rotational' Using this parameter indicate whether device is rotational or not. Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlockDevice.h | 4 ++-- src/os/bluestore/KernelDevice.cc | 5 +++++ src/os/bluestore/NVMEDevice.cc | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 5815d4000fa11..14608ebcca805 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 e488b5ef61a04..f58901298926a 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 d83b7721678e0..871d624b6df77 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; -- 2.39.5