]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journaler: fix flush bug
authorSage Weil <sage@newdream.net>
Wed, 22 Apr 2009 22:55:49 +0000 (15:55 -0700)
committerSage Weil <sage@newdream.net>
Wed, 22 Apr 2009 22:55:49 +0000 (15:55 -0700)
Fixes problem with aec1203d8502ad9b8583b53e55491f3a43309b97

Also uses decode for entry sizes (endian-safe!).

src/osdc/Journaler.cc

index 73a71457bfc0bb3e614f09b2a91e7add7f6d6568..0c619e82ca2de1acc388243dd12f20972e99012d 100644 (file)
@@ -381,13 +381,14 @@ void Journaler::_do_flush(unsigned amount)
   } else {
     write_buf.splice(0, len, &write_bl);
   }
-  flush_pos += len;
-  assert(write_buf.length() == write_pos - flush_pos);
 
   filer.write(ino, &layout, snapc,
              flush_pos, len, write_bl, g_clock.now(),
              CEPH_OSD_FLAG_INCLOCK_FAIL,
              onack, onsafe);
+
+  flush_pos += len;
+  assert(write_buf.length() == write_pos - flush_pos);
     
   dout(10) << "_do_flush write pointers now at " << write_pos << "/" << flush_pos << "/" << ack_pos << "/" << safe_pos << dendl;
 }
@@ -644,8 +645,9 @@ bool Journaler::is_readable()
 
   // have enough for entry size?
   uint32_t s = 0;
-  if (read_buf.length() >= sizeof(s)) 
-    read_buf.copy(0, sizeof(s), (char*)&s);
+  bufferlist::iterator p = read_buf.begin();
+  if (read_buf.length() >= sizeof(s))
+    ::decode(s, p);
 
   // entry and payload?
   if (read_buf.length() >= sizeof(s) &&
@@ -689,8 +691,10 @@ bool Journaler::try_read_entry(bufferlist& bl)
   }
   
   uint32_t s;
-  assert(read_buf.length() >= sizeof(s));
-  read_buf.copy(0, sizeof(s), (char*)&s);
+  {
+    bufferlist::iterator p = read_buf.begin();
+    ::decode(s, p);
+  }
   assert(read_buf.length() >= sizeof(s) + s);
   
   dout(10) << "try_read_entry at " << read_pos << " reading "