From: Xinze Chi Date: Tue, 3 Mar 2015 11:24:50 +0000 (+0000) Subject: osd: write journal header by force when journal write close X-Git-Tag: v0.94.7~28^2~12^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4fb688d15c40a9b9d5a54700b3c7695a97ffd03b;p=ceph.git osd: write journal header by force when journal write close osd update the journal header when ceph call FileStore::sync_entry( ApplyManager::commit_finish -> FileJournal::committed_thru). But, it doesnot write the journal head until the next transaction (calling do_write or do_aio_write). So write jouranl header when journal write close, so that committed_up_to in journal header is new enough. ceph may not replay some transaction which has been writen to filestore. Signed-off-by: Xinze Chi (cherry picked from commit 8f80ae3fbaba7b0e64b6e4df6c2dddd10ac50e5a) --- diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index c6bb6f2c0755..1b04d8e27f67 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -648,6 +648,10 @@ void FileJournal::stop_writer() commit_cond.Signal(); } write_thread.join(); + + // write jouranl header right now, so that + // committed_up_to in journal header is newer enough. + write_header(); #ifdef HAVE_LIBAIO // stop aio completeion thread *after* writer thread has stopped @@ -733,7 +737,14 @@ bufferptr FileJournal::prepare_header() return bp; } - +void FileJournal::write_header() +{ + Mutex::Locker locker(write_lock); + must_write_header = true; + bufferlist bl; + do_write(bl); + dout(20) << __func__ << " finish" << dendl; +} int FileJournal::check_for_full(uint64_t seq, off64_t pos, off64_t size) { diff --git a/src/os/FileJournal.h b/src/os/FileJournal.h index 574c902a68bb..8aa04a9d93ac 100644 --- a/src/os/FileJournal.h +++ b/src/os/FileJournal.h @@ -414,6 +414,8 @@ private: return full_state != FULL_NOTFULL && !write_stop; } + void write_header(); + void set_wait_on_full(bool b) { wait_on_full = b; } // reads