From: Samuel Just Date: Mon, 11 Mar 2013 22:15:03 +0000 (-0700) Subject: FileJournal::wrap_read_bl: convert arguments to explicit in/out arguments X-Git-Tag: v0.60~64^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=cf0093002176ac9e51bd456c5ce50543b13ad2ae;p=ceph.git FileJournal::wrap_read_bl: convert arguments to explicit in/out arguments Signed-off-by: Samuel Just --- diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index ad84b0dbf80d..47b95007fba5 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -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; diff --git a/src/os/FileJournal.h b/src/os/FileJournal.h index ed6ca10dc311..cb66819066b6 100644 --- a/src/os/FileJournal.h +++ b/src/os/FileJournal.h @@ -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;