]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
blk/BlockDevice: Remove reap_ioc logic 40032/head
authorAdam Kupczyk <akupczyk@redhat.com>
Thu, 11 Mar 2021 13:03:00 +0000 (14:03 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Thu, 11 Mar 2021 13:03:00 +0000 (14:03 +0100)
queue_reap_ioc and reap_ioc logic was necessary for BlueFS's _close_writer() method.
At one point it did not perform aio_wait(), and there was race condition in access/deletion to IOContext object.
Now we can simply delete it after successfull aio_wait().

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/blk/BlockDevice.cc
src/blk/BlockDevice.h
src/blk/kernel/KernelDevice.cc
src/blk/spdk/NVMEDevice.cc
src/blk/spdk/NVMEDevice.h
src/blk/zoned/HMSMRDevice.cc
src/os/bluestore/BlueFS.cc

index 6804ee50cbcaa0f08af053d272c568a0edcabf88..d5d3169e9131e0f58b00d5a30c8a39b51d9a09e3 100644 (file)
@@ -176,27 +176,6 @@ BlockDevice *BlockDevice::create(
   return create_with_type(device_type, cct, path, cb, cbpriv, d_cb, d_cbpriv);
 }
 
-void BlockDevice::queue_reap_ioc(IOContext *ioc)
-{
-  std::lock_guard l(ioc_reap_lock);
-  if (ioc_reap_count.load() == 0)
-    ++ioc_reap_count;
-  ioc_reap_queue.push_back(ioc);
-}
-
-void BlockDevice::reap_ioc()
-{
-  if (ioc_reap_count.load()) {
-    std::lock_guard l(ioc_reap_lock);
-    for (auto p : ioc_reap_queue) {
-      dout(20) << __func__ << " reap ioc " << p << dendl;
-      delete p;
-    }
-    ioc_reap_queue.clear();
-    --ioc_reap_count;
-  }
-}
-
 bool BlockDevice::is_valid_io(uint64_t off, uint64_t len) const {
   bool ret = (off % block_size == 0 &&
     len % block_size == 0 &&
index 191eb8ec908af8ebd0c32a5dbf8d96c0e8545add..44ed3de4d8c610ab8219d300b063d86bf4acc054 100644 (file)
@@ -263,9 +263,6 @@ public:
   virtual int queue_discard(interval_set<uint64_t> &to_release) { return -1; }
   virtual void discard_drain() { return; }
 
-  void queue_reap_ioc(IOContext *ioc);
-  void reap_ioc();
-
   // for managing buffered readers/writers
   virtual int invalidate_cache(uint64_t off, uint64_t len) = 0;
   virtual int open(const std::string& path) = 0;
index d41cda05b63d470b0eac9e7dc28a8486aa8d91b4..09a4b687ef062b11d12347e865f17f7f88b23cd2 100644 (file)
@@ -648,7 +648,6 @@ void KernelDevice::_aio_thread()
        }
       }
     }
-    reap_ioc();
     if (cct->_conf->bdev_inject_crash) {
       ++inject_crash_count;
       if (inject_crash_count * cct->_conf->bdev_aio_poll_ms / 1000 >
@@ -660,7 +659,6 @@ void KernelDevice::_aio_thread()
       }
     }
   }
-  reap_ioc();
   dout(10) << __func__ << " end" << dendl;
 }
 
index 935d3bbd11c165ddc9bc266082783af706012f1e..78fcb035101a219f8b7bfcfa12820b89cb2edece 100644 (file)
@@ -126,7 +126,6 @@ class SharedDriverQueueData {
   uint32_t block_size;
   uint32_t max_queue_depth;
   struct spdk_nvme_qpair *qpair;
-  bool reap_io = false;
   int alloc_buf_from_pool(Task *t, bool write);
 
   public:
@@ -159,16 +158,11 @@ class SharedDriverQueueData {
       }
       data_buf_list.push_front(*reinterpret_cast<data_cache_buf *>(b));
     }
-
-    bdev->queue_number++;
-    if (bdev->queue_number.load() == 1)
-      reap_io = true;
   }
 
   ~SharedDriverQueueData() {
     if (qpair) {
       spdk_nvme_ctrlr_free_io_qpair(qpair);
-      bdev->queue_number--;
     }
 
     data_buf_list.clear_and_dispose(spdk_dma_free);
@@ -419,8 +413,6 @@ void SharedDriverQueueData::_aio_handle(Task *t, IOContext *ioc)
     }
   }
 
-  if (reap_io)
-    bdev->reap_ioc();
   dout(20) << __func__ << " end" << dendl;
 }
 
index 352856093d802600a48440e10b03e9c36b42051e..cbd094d655d1cd5b82b2c9b29d72e4488b0ea3bd 100644 (file)
@@ -48,7 +48,6 @@ class NVMEDevice : public BlockDevice {
   string name;
 
  public:
-  std::atomic_int queue_number = {0};
   SharedDriverData *get_driver() { return driver; }
 
   NVMEDevice(CephContext* cct, aio_callback_t cb, void *cbpriv);
index 8a30be9b0a2421864308db0a12cd12a86a2d1821..dac61c879e735adecd219bae5afacb084225e732 100644 (file)
@@ -656,7 +656,6 @@ void HMSMRDevice::_aio_thread()
        }
       }
     }
-    reap_ioc();
     if (cct->_conf->bdev_inject_crash) {
       ++inject_crash_count;
       if (inject_crash_count * cct->_conf->bdev_aio_poll_ms / 1000 >
@@ -668,7 +667,6 @@ void HMSMRDevice::_aio_thread()
       }
     }
   }
-  reap_ioc();
   dout(10) << __func__ << " end" << dendl;
 }
 
index b87bc4fd50b299e166e99c56bc4d79c8ff6a95fc..b26f1b3bafc6518952130bbba17685c7916f39a3 100644 (file)
@@ -3285,7 +3285,7 @@ void BlueFS::_close_writer(FileWriter *h)
     if (bdev[i]) {
       if (h->iocv[i]) {
        h->iocv[i]->aio_wait();
-       bdev[i]->queue_reap_ioc(h->iocv[i]);
+       delete h->iocv[i];
       }
     }
   }