From 455e7435f70a0791271c86a5742b90de2c5a01f6 Mon Sep 17 00:00:00 2001 From: Pan Liu Date: Sun, 27 Aug 2017 23:03:15 +0800 Subject: [PATCH] os/bluestore/NVMEDevice: remove not used BufferedExtents. Signed-off-by: Pan Liu Signed-off-by: Ziye Yang --- src/os/bluestore/NVMEDevice.cc | 4 +- src/os/bluestore/NVMEDevice.h | 145 --------------------------------- 2 files changed, 2 insertions(+), 147 deletions(-) diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 9b37390d043..c49b9409038 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -91,6 +91,7 @@ struct IORequest { void **extra_segs = nullptr; }; +struct Task; class SharedDriverQueueData { SharedDriverData *driver; spdk_nvme_ctrlr *ctrlr; @@ -872,8 +873,7 @@ void io_complete(void *t, const struct spdk_nvme_cpl *completion) NVMEDevice::NVMEDevice(CephContext* cct, aio_callback_t cb, void *cbpriv) : BlockDevice(cct, cb, cbpriv), driver(nullptr), - aio_stop(false), - buffer_lock("NVMEDevice::buffer_lock") + aio_stop(false) { } diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index a573e199305..1a33dcf5ea5 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -37,8 +37,6 @@ enum class IOCommand { FLUSH_COMMAND }; -class Task; -class PerfCounters; class SharedDriverData; class NVMEDevice : public BlockDevice { @@ -49,151 +47,8 @@ class NVMEDevice : public BlockDevice { */ SharedDriverData *driver; string name; - bool aio_stop; - struct BufferedExtents { - struct Extent { - uint64_t x_len; - uint64_t x_off; - const char *data; - uint64_t data_len; - }; - using Offset = uint64_t; - map buffered_extents; - uint64_t left_edge = std::numeric_limits::max(); - uint64_t right_edge = 0; - - void verify() { - interval_set m; - for (auto && it : buffered_extents) { - assert(!m.intersects(it.first, it.second.x_len)); - m.insert(it.first, it.second.x_len); - } - } - - void insert(uint64_t off, uint64_t len, const char *data) { - auto it = buffered_extents.lower_bound(off); - if (it != buffered_extents.begin()) { - --it; - if (it->first + it->second.x_len <= off) - ++it; - } - uint64_t end = off + len; - if (off < left_edge) - left_edge = off; - if (end > right_edge) - right_edge = end; - while (it != buffered_extents.end()) { - if (it->first >= end) - break; - uint64_t extent_it_end = it->first + it->second.x_len; - assert(extent_it_end >= off); - if (it->first <= off) { - if (extent_it_end > end) { - // <- data -> - // <- it -> - it->second.x_len -= (extent_it_end - off); - buffered_extents[end] = Extent{ - extent_it_end - end, it->second.x_off + it->second.x_len + len, it->second.data, it->second.data_len}; - } else { - // <- data -> - // <- it -> - assert(extent_it_end <= end); - it->second.x_len -= (extent_it_end - off); - } - ++it; - } else { - assert(it->first > off); - if (extent_it_end > end) { - // <- data -> - // <- it -> - uint64_t overlap = end - it->first; - buffered_extents[end] = Extent{ - it->second.x_len - overlap, it->second.x_off + overlap, it->second.data, it->second.data_len}; - } else { - // <- data -> - // <- it -> - } - buffered_extents.erase(it++); - } - } - buffered_extents[off] = Extent{ - len, 0, data, len}; - - if (0) - verify(); - } - - void memcpy_check(char *dst, uint64_t dst_raw_len, uint64_t dst_off, - map::iterator &it, uint64_t src_off, uint64_t copylen) { - if (0) { - assert(dst_off + copylen <= dst_raw_len); - assert(it->second.x_off + src_off + copylen <= it->second.data_len); - } - memcpy(dst + dst_off, it->second.data + it->second.x_off + src_off, copylen); - } - - uint64_t read_overlap(uint64_t off, uint64_t len, char *buf) { - uint64_t end = off + len; - if (end <= left_edge || off >= right_edge) - return 0; - - uint64_t copied = 0; - auto it = buffered_extents.lower_bound(off); - if (it != buffered_extents.begin()) { - --it; - if (it->first + it->second.x_len <= off) - ++it; - } - uint64_t copy_len; - while (it != buffered_extents.end()) { - if (it->first >= end) - break; - uint64_t extent_it_end = it->first + it->second.x_len; - assert(extent_it_end >= off); - if (it->first >= off) { - if (extent_it_end > end) { - // <- data -> - // <- it -> - copy_len = len - (it->first - off); - memcpy_check(buf, len, it->first - off, it, 0, copy_len); - } else { - // <- data -> - // <- it -> - copy_len = it->second.x_len; - memcpy_check(buf, len, it->first - off, it, 0, copy_len); - } - } else { - if (extent_it_end > end) { - // <- data -> - // <- it -> - copy_len = len; - memcpy_check(buf, len, 0, it, off - it->first, copy_len); - } else { - // <- data -> - // <- it -> - assert(extent_it_end <= end); - copy_len = it->first + it->second.x_len - off; - memcpy_check(buf, len, 0, it, off - it->first, copy_len); - } - } - copied += copy_len; - ++it; - } - return copied; - } - - void clear() { - buffered_extents.clear(); - left_edge = std::numeric_limits::max(); - right_edge = 0; - } - }; - Mutex buffer_lock; - BufferedExtents buffered_extents; - Task *buffered_task_head = nullptr; - static void init(); public: SharedDriverData *get_driver() { return driver; } -- 2.39.5