]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: release completed aios
authorSage Weil <sage@redhat.com>
Thu, 29 Sep 2016 21:05:53 +0000 (17:05 -0400)
committerSage Weil <sage@redhat.com>
Thu, 29 Sep 2016 21:05:53 +0000 (17:05 -0400)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 15c23e9996eeaca58d182ed4226e3b56d6bcb639..4f8a8a44960f505690d5d646c356f0ffc70be44e 100644 (file)
@@ -1344,8 +1344,11 @@ int BlueFS::_flush_and_sync_log(std::unique_lock<std::mutex>& l,
   }
 
   // drop lock while we wait for io
+  list<FS::aio_t> completed_ios;
+  _claim_completed_aios(log_writer, &completed_ios);
   l.unlock();
   wait_for_aio(log_writer);
+  completed_ios.clear();
   flush_bdev();
   l.lock();
 
@@ -1541,8 +1544,9 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
   for (unsigned i = 0; i < MAX_BDEV; ++i) {
     if (bdev[i]) {
       assert(h->iocv[i]);
-      if (h->iocv[i]->has_aios())
+      if (h->iocv[i]->has_aios()) {
         bdev[i]->aio_submit(h->iocv[i]);
+      }
     }
   }
   dout(20) << __func__ << " h " << h << " pos now 0x"
@@ -1550,6 +1554,18 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
   return 0;
 }
 
+// we need to retire old completed aios so they don't stick around in
+// memory indefinitely (along with their bufferlist refs).
+void BlueFS::_claim_completed_aios(FileWriter *h, list<FS::aio_t> *ls)
+{
+  for (auto p : h->iocv) {
+    if (p) {
+      ls->splice(ls->end(), p->running_aios);
+    }
+  }
+  dout(10) << __func__ << " got " << ls->size() << " aios" << dendl;
+}
+
 void BlueFS::wait_for_aio(FileWriter *h)
 {
   // NOTE: this is safe to call without a lock, as long as our reference is
@@ -1635,8 +1651,11 @@ int BlueFS::_fsync(FileWriter *h, std::unique_lock<std::mutex>& l)
   if (r < 0)
      return r;
   uint64_t old_dirty_seq = h->file->dirty_seq;
+  list<FS::aio_t> completed_ios;
+  _claim_completed_aios(h, &completed_ios);
   lock.unlock();
   wait_for_aio(h);
+  completed_ios.clear();
   lock.lock();
   if (old_dirty_seq) {
     uint64_t s = log_seq;
index e3862a584fc26607154ae08af99a49d16ac3ae79..92260c50596172ed88028b16fbf84261102bd8ef 100644 (file)
@@ -248,9 +248,11 @@ private:
   int _allocate(uint8_t bdev, uint64_t len, vector<bluefs_extent_t> *ev);
   int _flush_range(FileWriter *h, uint64_t offset, uint64_t length);
   int _flush(FileWriter *h, bool force);
-  void wait_for_aio(FileWriter *h);  // safe to call without a lock
   int _fsync(FileWriter *h, std::unique_lock<std::mutex>& l);
 
+  void _claim_completed_aios(FileWriter *h, list<FS::aio_t> *ls);
+  void wait_for_aio(FileWriter *h);  // safe to call without a lock
+
   int _flush_and_sync_log(std::unique_lock<std::mutex>& l,
                          uint64_t want_seq = 0,
                          uint64_t jump_to = 0);