]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: write journal header by force when journal write close
authorXinze Chi <xmdxcxz@gmail.com>
Tue, 3 Mar 2015 11:24:50 +0000 (11:24 +0000)
committerDavid Zafman <dzafman@redhat.com>
Sat, 20 Feb 2016 00:56:00 +0000 (16:56 -0800)
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 <xmdxcxz@gmail.com>
(cherry picked from commit 8f80ae3fbaba7b0e64b6e4df6c2dddd10ac50e5a)

src/os/FileJournal.cc
src/os/FileJournal.h

index c6bb6f2c0755d870f01c276783906ec3b5d77114..1b04d8e27f671a0038a02c96294b6c3bfba953ea 100644 (file)
@@ -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)
 {
index 574c902a68bb973235be70c20e7a822d44286e14..8aa04a9d93ac45909bb90a6410261408986caf5c 100644 (file)
@@ -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