]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Fix FileJournal wrap to get header out first 3771/head
authorDavid Zafman <dzafman@redhat.com>
Thu, 19 Feb 2015 00:21:12 +0000 (16:21 -0800)
committerDavid Zafman <dzafman@redhat.com>
Sat, 21 Feb 2015 00:12:43 +0000 (16:12 -0800)
Correct and restore assert that was removed

Cause by f46b1b473fce0322a672b16c7739e569a45054b6
Fixes: #10883
Backport: dumpling, firefly, giant

Signed-off-by: David Zafman <dzafman@redhat.com>
(cherry picked from commit 970bb4901f93575709421b5b25c3eff213de61b8)

src/os/FileJournal.cc

index d6ddc7fa21297c737b15e4d215e1b2e57cc2dd84..6c33f9c505a27217daef4a480112474bab98aebd 100644 (file)
@@ -806,7 +806,8 @@ int FileJournal::prepare_multi_write(bufferlist& bl, uint64_t& orig_ops, uint64_
   }
 
   dout(20) << "prepare_multi_write queue_pos now " << queue_pos << dendl;
-  //assert(write_pos + bl.length() == queue_pos);
+  assert((write_pos + bl.length() == queue_pos) ||
+         (write_pos + bl.length() - header.max_size + get_top() == queue_pos));
   return 0;
 }
 
@@ -1005,22 +1006,32 @@ void FileJournal::do_write(bufferlist& bl)
     dout(10) << "do_write wrapping, first bit at " << pos << " len " << first.length()
             << " second bit len " << second.length() << " (orig len " << bl.length() << ")" << dendl;
 
-    if (write_bl(pos, first)) {
-      derr << "FileJournal::do_write: write_bl(pos=" << pos
-          << ") failed" << dendl;
-      ceph_abort();
-    }
-    assert(pos == get_top());
+    //Save pos to write first piece second
+    off64_t first_pos = pos;
+    off64_t orig_pos;
+    pos = get_top();
+    // header too?
     if (hbp.length()) {
       // be sneaky: include the header in the second fragment
       second.push_front(hbp);
       pos = 0;          // we included the header
     }
+    // Write the second portion first possible with the header, so
+    // do_read_entry() won't even get a valid entry_header_t if there
+    // is a crash between the two writes.
+    orig_pos = pos;
     if (write_bl(pos, second)) {
-      derr << "FileJournal::do_write: write_bl(pos=" << pos
+      derr << "FileJournal::do_write: write_bl(pos=" << orig_pos
+          << ") failed" << dendl;
+      ceph_abort();
+    }
+    orig_pos = first_pos;
+    if (write_bl(first_pos, first)) {
+      derr << "FileJournal::do_write: write_bl(pos=" << orig_pos
           << ") failed" << dendl;
       ceph_abort();
     }
+    assert(first_pos == get_top());
   } else {
     // header too?
     if (hbp.length()) {