]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Journaler: make sure flush() writes enough data 20435/head
authorYan, Zheng <zyan@redhat.com>
Mon, 29 Jan 2018 02:59:00 +0000 (10:59 +0800)
committerPrashant D <pdhange@redhat.com>
Wed, 14 Feb 2018 10:08:10 +0000 (05:08 -0500)
If _do_flush() fails to write all data because of prezere, _do_flush()
should be called again when prezero finishes. Otherwise flush waiters
may sleep forever.

Fixes: http://tracker.ceph.com/issues/22824
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit 94a2076b9de9e8ffb73f3d5c873bdb87a0429e65)

src/osdc/Journaler.cc
src/osdc/Journaler.h

index c57616edca47e83fa4e4a04bfbafb66c5edd96f2..0680fb945e0d9aa211e863465ce1fa11924455c3 100644 (file)
@@ -623,19 +623,16 @@ void Journaler::_do_flush(unsigned amount)
       ldout(cct, 10) << "_do_flush wanted to do " << flush_pos << "~" << len
                     << " already too close to prezero_pos " << prezero_pos
                     << ", zeroing first" << dendl;
-      waiting_for_zero = true;
+      waiting_for_zero_pos = flush_pos + len;
       return;
     }
     if (newlen < len) {
       ldout(cct, 10) << "_do_flush wanted to do " << flush_pos << "~" << len
                     << " but hit prezero_pos " << prezero_pos
                     << ", will do " << flush_pos << "~" << newlen << dendl;
+      waiting_for_zero_pos = flush_pos + len;
       len = newlen;
-    } else {
-      waiting_for_zero = false;
     }
-  } else {
-    waiting_for_zero = false;
   }
   ldout(cct, 10) << "_do_flush flushing " << flush_pos << "~" << len << dendl;
 
@@ -835,8 +832,8 @@ void Journaler::_finish_prezero(int r, uint64_t start, uint64_t len)
       pending_zero.erase(b);
     }
 
-    if (waiting_for_zero) {
-      _do_flush();
+    if (waiting_for_zero_pos > flush_pos) {
+      _do_flush(waiting_for_zero_pos - flush_pos);
     }
   } else {
     pending_zero.insert(start, len);
index 58269462ea516499ebf5ea5804d2e44792e8ecb4..6d78626ec90fec1c980174977379593bb494ecd8 100644 (file)
@@ -315,7 +315,7 @@ private:
   // protect write_buf from bufferlist _len overflow 
   Throttle write_buf_throttle;
 
-  bool waiting_for_zero;
+  uint64_t waiting_for_zero_pos;
   interval_set<uint64_t> pending_zero;  // non-contig bits we've zeroed
   std::set<uint64_t> pending_safe;
   // when safe through given offset
@@ -411,7 +411,7 @@ public:
     state(STATE_UNDEF), error(0),
     prezeroing_pos(0), prezero_pos(0), write_pos(0), flush_pos(0), safe_pos(0),
     write_buf_throttle(cct, "write_buf_throttle", UINT_MAX - (UINT_MAX >> 3)),
-    waiting_for_zero(false),
+    waiting_for_zero_pos(0),
     read_pos(0), requested_pos(0), received_pos(0),
     fetch_len(0), temp_fetch_len(0),
     on_readable(0), on_write_error(NULL), called_write_error(false),
@@ -447,7 +447,7 @@ public:
     expire_pos = 0;
     trimming_pos = 0;
     trimmed_pos = 0;
-    waiting_for_zero = false;
+    waiting_for_zero_pos = 0;
   }
 
   // Asynchronous operations