]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
FileJournal::wrap_read_bl: convert arguments to explicit in/out arguments
authorSamuel Just <sam.just@inktank.com>
Mon, 11 Mar 2013 22:15:03 +0000 (15:15 -0700)
committerSamuel Just <sam.just@inktank.com>
Fri, 15 Mar 2013 18:21:07 +0000 (11:21 -0700)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileJournal.cc
src/os/FileJournal.h

index ad84b0dbf80d5aeb7def709298571df90fb8ec1e..47b95007fba5310d716caf1bb5d489dfcb9c42a7 100644 (file)
@@ -1578,7 +1578,12 @@ void FileJournal::make_writeable()
   start_writer();
 }
 
-void FileJournal::wrap_read_bl(off64_t& pos, int64_t olen, bufferlist& bl)
+void FileJournal::wrap_read_bl(
+  off64_t pos,
+  int64_t olen,
+  bufferlist* bl,
+  off64_t *out_pos
+  )
 {
   while (olen > 0) {
     while (pos >= header.max_size)
@@ -1604,12 +1609,14 @@ void FileJournal::wrap_read_bl(off64_t& pos, int64_t olen, bufferlist& bl)
           << r << dendl;
       ceph_abort();
     }
-    bl.push_back(bp);
+    bl->push_back(bp);
     pos += len;
     olen -= len;
   }
   if (pos >= header.max_size)
     pos = pos + get_top() - header.max_size;
+  if (out_pos)
+    *out_pos = pos;
 }
 
 bool FileJournal::read_entry(bufferlist& bl, uint64_t& seq)
@@ -1624,7 +1631,7 @@ bool FileJournal::read_entry(bufferlist& bl, uint64_t& seq)
   // header
   entry_header_t *h;
   bufferlist hbl;
-  wrap_read_bl(pos, sizeof(*h), hbl);
+  wrap_read_bl(pos, sizeof(*h), &hbl, &pos);
   h = (entry_header_t *)hbl.c_str();
 
   if (!h->check_magic(read_pos, header.get_fsid64())) {
@@ -1644,7 +1651,7 @@ bool FileJournal::read_entry(bufferlist& bl, uint64_t& seq)
     pos += h->pre_pad;
 
   bl.clear();
-  wrap_read_bl(pos, h->len, bl);
+  wrap_read_bl(pos, h->len, &bl, &pos);
 
   if (h->post_pad)
     pos += h->post_pad;
@@ -1652,7 +1659,7 @@ bool FileJournal::read_entry(bufferlist& bl, uint64_t& seq)
   // footer
   entry_header_t *f;
   bufferlist fbl;
-  wrap_read_bl(pos, sizeof(*f), fbl);
+  wrap_read_bl(pos, sizeof(*f), &fbl, &pos);
   f = (entry_header_t *)fbl.c_str();
   if (memcmp(f, h, sizeof(*f))) {
     dout(2) << "read_entry " << read_pos << " : bad footer magic, partial entry, end of journal" << dendl;
index ed6ca10dc3113e4814415c8c0d409e7eb9cf531b..cb66819066b640cdc9643797ec98a64d915e0484 100644 (file)
@@ -292,7 +292,14 @@ private:
 
   void align_bl(off64_t pos, bufferlist& bl);
   int write_bl(off64_t& pos, bufferlist& bl);
-  void wrap_read_bl(off64_t& pos, int64_t len, bufferlist& bl);
+
+  /// read len from journal starting at in_pos and wrapping up to len
+  void wrap_read_bl(
+    off64_t in_pos,   ///< [in] start position
+    int64_t len,      ///< [in] length to read
+    bufferlist* bl,   ///< [out] result
+    off64_t *out_pos  ///< [out] next position to read, will be wrapped
+    );
 
   class Writer : public Thread {
     FileJournal *journal;