]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: drop lock while waiting for user io to complete
authorSage Weil <sage@redhat.com>
Thu, 23 Jun 2016 13:39:31 +0000 (09:39 -0400)
committerSage Weil <sage@redhat.com>
Thu, 30 Jun 2016 16:56:56 +0000 (12:56 -0400)
_flush_wait is safe to call without a lock, as long as our reference is
stable.  Rename it wait_for_aio() to be more clear about what it does and
the fact that it doesn't require a lock.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 8237ecfea586d58a16005a9412492b3a9649993e..b81ca696c6f7a76eb2ddc0a83950d6ac88ca529b 100644 (file)
@@ -997,7 +997,7 @@ void BlueFS::_compact_log()
   log_writer->append(bl);
   int r = _flush(log_writer, true);
   assert(r == 0);
-  _flush_wait(log_writer);
+  wait_for_aio(log_writer);
 
   dout(10) << __func__ << " writing super" << dendl;
   super.log_fnode = log_file->fnode;
@@ -1057,7 +1057,7 @@ int BlueFS::_flush_and_sync_log()
   _flush_bdev();
   int r = _flush(log_writer, true);
   assert(r == 0);
-  _flush_wait(log_writer);
+  wait_for_aio(log_writer);
   _flush_bdev();
 
   // clean dirty files
@@ -1220,8 +1220,10 @@ int BlueFS::_flush_range(FileWriter *h, uint64_t offset, uint64_t length)
   return 0;
 }
 
-void BlueFS::_flush_wait(FileWriter *h)
+void BlueFS::wait_for_aio(FileWriter *h)
 {
+  // NOTE: this is safe to call without a lock, as long as our reference is
+  // stable.
   dout(10) << __func__ << " " << h << dendl;
   utime_t start = ceph_clock_now(NULL);
   for (auto p : h->iocv) {
@@ -1293,11 +1295,14 @@ void BlueFS::_fsync(FileWriter *h)
 {
   dout(10) << __func__ << " " << h << " " << h->file->fnode << dendl;
   _flush(h, true);
-  _flush_wait(h);
-  if (h->file->dirty_seq) {
+  uint64_t old_dirty_seq = h->file->dirty_seq;
+  lock.unlock();
+  wait_for_aio(h);
+  lock.lock();
+  if (old_dirty_seq) {
     uint64_t s = log_seq;
-    dout(20) << __func__ << " file metadata is dirty, flushing log on "
-            << h->file->fnode << dendl;
+    dout(20) << __func__ << " file metadata was dirty (" << old_dirty_seq
+            << ") on " << h->file->fnode << ", flushing log" << dendl;
     _flush_and_sync_log();
     assert(h->file->dirty_seq == 0 ||  // cleaned
           h->file->dirty_seq > s);    // or redirtied by someone else
index e01eb371aaee3043b9e9598549912dcdbe7b0010..1757418da110f49db151be29e9d4823d8da4c9ac 100644 (file)
@@ -233,7 +233,7 @@ private:
   int _allocate(unsigned 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 _flush_wait(FileWriter *h);
+  void wait_for_aio(FileWriter *h);  // safe to call without a lock
   void _fsync(FileWriter *h);
 
   int _flush_and_sync_log();