From d90d1866dc18fab893c29f8fde0478d2d70fc140 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 9 Jan 2009 14:15:44 -0800 Subject: [PATCH] mds: wait for journal safe when doing ino allocations Stop-gap, I suppose.. we really want to wait for things to fully journal, period. Hmm. --- src/mds/MDCache.h | 5 ++++- src/mds/MDLog.cc | 6 ++++-- src/mds/MDLog.h | 2 +- src/mds/Server.cc | 11 +++++++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 3600a6a578064..314b6430abc4b 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -345,7 +345,10 @@ struct MDRequest : public Mutation { } bool slave_did_prepare() { return more()->slave_commit; } - + + bool did_ino_allocation() { + return alloc_ino || used_prealloc_ino || prealloc_inos.size(); + } void print(ostream &out) { out << "request(" << reqid; diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index 7b919592caafa..02078b6775603 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -147,7 +147,7 @@ void MDLog::append() // ------------------------------------------------- -void MDLog::submit_entry( LogEvent *le, Context *c ) +void MDLog::submit_entry( LogEvent *le, Context *c, bool wait_safe ) { if (!g_conf.mds_log) { // hack: log is disabled. @@ -191,7 +191,9 @@ void MDLog::submit_entry( LogEvent *le, Context *c ) if (c) { unflushed = 0; - journaler->flush(c); + journaler->flush(wait_safe ? 0:c); + if (wait_safe) + journaler->wait_for_flush(0, c); } else unflushed++; diff --git a/src/mds/MDLog.h b/src/mds/MDLog.h index 6388219c890f3..83de89ed4dd78 100644 --- a/src/mds/MDLog.h +++ b/src/mds/MDLog.h @@ -161,7 +161,7 @@ public: bool is_capped() { return capped; } void cap(); - void submit_entry( LogEvent *e, Context *c = 0 ); + void submit_entry( LogEvent *e, Context *c = 0, bool wait_for_safe=false ); void wait_for_sync( Context *c ); void wait_for_safe( Context *c ); void flush(); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 50d62e4d6d5ec..443eac8d2d14d 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -2352,7 +2352,8 @@ void Server::handle_client_mknod(MDRequest *mdr) // log + wait mdr->committing = true; - mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows)); + mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows), + mdr->did_ino_allocation()); } @@ -2407,7 +2408,8 @@ void Server::handle_client_mkdir(MDRequest *mdr) // log + wait mdr->committing = true; - mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows)); + mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows), + mdr->did_ino_allocation()); } @@ -2454,7 +2456,8 @@ void Server::handle_client_symlink(MDRequest *mdr) // log + wait mdr->committing = true; - mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows)); + mdlog->submit_entry(le, new C_MDS_mknod_finish(mds, mdr, dn, newi, follows), + mdr->did_ino_allocation()); } @@ -5109,7 +5112,7 @@ void Server::handle_client_openc(MDRequest *mdr) // log + wait C_MDS_openc_finish *fin = new C_MDS_openc_finish(mds, mdr, dn, in, follows); - mdlog->submit_entry(le, fin); + mdlog->submit_entry(le, fin, mdr->did_ino_allocation()); } -- 2.39.5