]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/NVMEDevice: remove not used BufferedExtents.
authorPan Liu <wanjun.lp@alibaba-inc.com>
Sun, 27 Aug 2017 15:03:15 +0000 (23:03 +0800)
committerPan Liu <wanjun.lp@alibaba-inc.com>
Sun, 27 Aug 2017 15:03:15 +0000 (23:03 +0800)
Signed-off-by: Pan Liu <wanjun.lp@alibaba-inc.com>
Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
src/os/bluestore/NVMEDevice.cc
src/os/bluestore/NVMEDevice.h

index 9b37390d043e82f59a10d56ec01f445f1f5147d4..c49b940903852142ca7fc53549d6973511010af2 100644 (file)
@@ -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)
 {
 }
 
index a573e199305ebcfd6b6f86c29bbaecfc124ca5bf..1a33dcf5ea5931fdb03f3166876970f9ec05476d 100644 (file)
@@ -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<Offset, Extent> buffered_extents;
-    uint64_t left_edge = std::numeric_limits<uint64_t>::max();
-    uint64_t right_edge = 0;
-
-    void verify() {
-      interval_set<uint64_t> 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<Offset, Extent>::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<uint64_t>::max();
-      right_edge = 0;
-    }
-  };
-  Mutex buffer_lock;
-  BufferedExtents buffered_extents;
-  Task *buffered_task_head = nullptr;
-
   static void init();
  public:
   SharedDriverData *get_driver() { return driver; }