]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc: Clean up journalstream readable check
authorJohn Spray <john.spray@inktank.com>
Thu, 1 May 2014 11:54:14 +0000 (12:54 +0100)
committerJohn Spray <john.spray@inktank.com>
Tue, 20 May 2014 13:07:50 +0000 (14:07 +0100)
Fix redundant (and subtly incorrect) calculation of
the number of bytes needed.  It worked because waiting
for a few more bytes before reading the entry size
of an old-format entry was harmless.

Signed-off-by: John Spray <john.spray@inktank.com>
src/osdc/Journaler.cc

index 28b10977244a85ad835820df62e0cbd30aae81df..848fb5703c6e6ca6a60c5d8d57c030891d39ee35 100644 (file)
@@ -1056,19 +1056,18 @@ void Journaler::handle_write_error(int r)
  */
 bool JournalStream::readable(bufferlist &read_buf, uint64_t &need)
 {
-  // have enough for entry size?
   uint32_t entry_size = 0;
   uint64_t start_ptr = 0;
   uint64_t entry_sentinel = 0;
   bufferlist::iterator p = read_buf.begin();
 
-  // Do we have enough data to decode an entry header?
+  // Do we have enough data to decode an entry prefix?
   if (format >= JOURNAL_FORMAT_RESILIENT) {
     need = sizeof(entry_size) + sizeof(entry_sentinel);
   } else {
     need = sizeof(entry_size);
   }
-  if (read_buf.length() >= sizeof(entry_size) + sizeof(entry_sentinel) + sizeof(start_ptr)) {
+  if (read_buf.length() >= need) {
     if (format >= JOURNAL_FORMAT_RESILIENT) {
       ::decode(entry_sentinel, p);
     }
@@ -1083,7 +1082,7 @@ bool JournalStream::readable(bufferlist &read_buf, uint64_t &need)
     return false;
   }
 
-  // Do we have enough data to decode an entry header and payload?
+  // Do we have enough data to decode an entry prefix, payload and suffix?
   if (format >= JOURNAL_FORMAT_RESILIENT) {
     need = sizeof(entry_size) + sizeof(entry_sentinel) + entry_size + sizeof(start_ptr);
   } else {