From 8df0cd3867200012fdb95d2fd1771b993dfac215 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 10 Nov 2011 11:31:22 -0800 Subject: [PATCH] filestore: make trigger_commit() wake up sync; adjust locking We need to wake up the sync thread (duh). Also, we need to obey the FileJournal::lock -> journal_lock locking order. Also, lockdep is broken. :( Signed-off-by: Sage Weil --- src/os/FileStore.cc | 17 +++++++++++++++++ src/os/FileStore.h | 2 ++ src/os/JournalingObjectStore.cc | 7 ++++--- src/os/JournalingObjectStore.h | 3 ++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 131484888a21f..2787110e58d52 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3161,6 +3161,23 @@ void FileStore::start_sync(Context *onsafe) dout(10) << "start_sync" << dendl; } +void FileStore::trigger_commit(uint64_t seq) +{ + /* + * crib the lock -> journal_lock. we need to start the sync under lock, + * but once we release lock it will block because journal_lock is held. + * _trigger_commit() expects journal_lock to be held by the caller. + */ + lock.Lock(); + dout(10) << "trigger_commit seq" << dendl; + force_sync = true; + sync_cond.Signal(); + journal_lock.Lock(); + lock.Unlock(); + _trigger_commit(seq); + journal_lock.Unlock(); +} + void FileStore::sync() { Mutex l("FileStore::sync"); diff --git a/src/os/FileStore.h b/src/os/FileStore.h index 033dad31faeae..09eea071927f9 100644 --- a/src/os/FileStore.h +++ b/src/os/FileStore.h @@ -103,6 +103,8 @@ class FileStore : public JournalingObjectStore, } } sync_thread; + void trigger_commit(uint64_t); + void sync_fs(); // actuall sync underlying fs // -- op workqueue -- diff --git a/src/os/JournalingObjectStore.cc b/src/os/JournalingObjectStore.cc index 80ee981eaea81..66257bf5d9a21 100644 --- a/src/os/JournalingObjectStore.cc +++ b/src/os/JournalingObjectStore.cc @@ -180,18 +180,19 @@ void JournalingObjectStore::op_submit_finish(uint64_t op) * an open_ops reference. it should block only long enough for the * commit to _start_ waiting for open_ops, but not longer or else we * will deadlock. + * + * caller must hold journal_lock. */ -void JournalingObjectStore::trigger_commit(uint64_t seq) +void JournalingObjectStore::_trigger_commit(uint64_t seq) { + assert(journal_lock.is_locked()); dout(10) << "trigger_commit " << seq << dendl; - journal_lock.Lock(); force_commit = true; while (!blocked && committing_seq < seq) { dout(20) << "trigger_commit not blocked and seq " << seq << " > committing " << committing_seq << dendl; cond.Wait(journal_lock); } dout(10) << "trigger_commit triggered, will commit something >= " << seq << dendl; - journal_lock.Unlock(); } bool JournalingObjectStore::commit_start() diff --git a/src/os/JournalingObjectStore.h b/src/os/JournalingObjectStore.h index 3b4f7cf68ce14..a701a7d12e3a6 100644 --- a/src/os/JournalingObjectStore.h +++ b/src/os/JournalingObjectStore.h @@ -45,7 +45,8 @@ protected: void journal_stop(); int journal_replay(uint64_t fs_op_seq); - void trigger_commit(uint64_t op_seq); + virtual void trigger_commit(uint64_t op_seq) = 0; + void _trigger_commit(uint64_t op_seq); // -- uint64_t op_submit_start(); -- 2.39.5