From 2222bf5eb2e77aca6baa736638b719d0bda8b2bb Mon Sep 17 00:00:00 2001 From: dongdong Date: Wed, 7 Jun 2017 13:41:27 +0800 Subject: [PATCH] Client: signal MDS to flush log when doing a syncfs Fixes: http://tracker.ceph.com/issues/20129 Signed-off-by: dongdong tao --- src/client/Client.cc | 19 +++++++++++++++++++ src/client/Client.h | 6 +++++- src/include/ceph_fs.h | 3 ++- src/mds/Server.cc | 4 ++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 0a55e73977e3b..93d348c026b37 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5788,6 +5788,24 @@ void Client::_close_sessions() } } +void Client::flush_mdlog_sync() +{ + + for (map::iterator p = mds_sessions.begin(); + p != mds_sessions.end(); + ++p) { + MetaSession *s = p->second; + flush_mdlog(s); + } +} + +void Client::flush_mdlog(MetaSession *session) +{ + MClientSession *m = new MClientSession(CEPH_SESSION_REQUEST_FLUSH_MDLOG); + session->con->send_message(m); +} + + void Client::unmount() { Mutex::Locker lock(client_lock); @@ -5799,6 +5817,7 @@ void Client::unmount() while (!mds_requests.empty()) { ldout(cct, 10) << "waiting on " << mds_requests.size() << " requests" << dendl; + flush_mdlog_sync(); mount_cond.Wait(client_lock); } diff --git a/src/client/Client.h b/src/client/Client.h index da06729e8176d..b6369a29363e1 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -724,7 +724,11 @@ protected: bool use_faked_inos() { return _use_faked_inos; } vinodeno_t map_faked_ino(ino_t ino); - + + //notify the mds to flush the mdlog + void flush_mdlog_sync(); + void flush_mdlog(MetaSession *session); + // ---------------------- // fs ops. private: diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 726ee69d62f21..4188bff8b03fd 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -305,7 +305,8 @@ enum { CEPH_SESSION_FORCE_RO, // A response to REQUEST_OPEN indicating that the client should // permanently desist from contacting the MDS - CEPH_SESSION_REJECT + CEPH_SESSION_REJECT, + CEPH_SESSION_REQUEST_FLUSH_MDLOG }; extern const char *ceph_session_op_name(int op); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 43ea584be1b1d..7dab254119281 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -455,6 +455,10 @@ void Server::handle_client_session(MClientSession *m) finish_flush_session(session, m->get_seq()); break; + case CEPH_SESSION_REQUEST_FLUSH_MDLOG: + mdlog->flush(); + break; + default: ceph_abort(); } -- 2.39.5