From: Jeff Layton Date: Wed, 9 Nov 2016 14:36:07 +0000 (-0500) Subject: client: wire up the CHECK_CAPS_SYNCHRONOUS flag X-Git-Tag: v11.1.0~333^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=826b30aa28478650755ffe613a7bfc1074778599;p=ceph.git client: wire up the CHECK_CAPS_SYNCHRONOUS flag Ensure that the client will request an immediate journal flush from the MDS when we'll end up waiting on the flush response. This patch should fix the fsync codepath, but we may need something similar for syncfs. Signed-off-by: Jeff Layton --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 97de9faafaba..31522b934b26 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3417,7 +3417,7 @@ void Client::check_caps(Inode *in, unsigned flags) if (in->cap_snaps.size()) flush_snaps(in, true); if (in->flushing_caps) - flush_caps(in, session); + flush_caps(in, session, flags & CHECK_CAPS_SYNCHRONOUS); } int flushing; @@ -3429,8 +3429,8 @@ void Client::check_caps(Inode *in, unsigned flags) flush_tid = 0; } - send_cap(in, session, cap, false, cap_used, wanted, retain, flushing, - flush_tid); + send_cap(in, session, cap, flags & CHECK_CAPS_SYNCHRONOUS, cap_used, wanted, + retain, flushing, flush_tid); } } @@ -4133,7 +4133,7 @@ void Client::flush_caps() } } -void Client::flush_caps(Inode *in, MetaSession *session) +void Client::flush_caps(Inode *in, MetaSession *session, bool sync) { ldout(cct, 10) << "flush_caps " << in << " mds." << session->mds_num << dendl; Cap *cap = in->auth_cap; @@ -4142,7 +4142,14 @@ void Client::flush_caps(Inode *in, MetaSession *session) for (map::iterator p = in->flushing_cap_tids.begin(); p != in->flushing_cap_tids.end(); ++p) { - send_cap(in, session, cap, false, (get_caps_used(in) | in->caps_dirty()), + bool req_sync = false; + + /* If this is a synchronous request, then flush the journal on last one */ + if (sync && (p->first == in->flushing_cap_tids.rbegin()->first)) + req_sync = true; + + send_cap(in, session, cap, req_sync, + (get_caps_used(in) | in->caps_dirty()), in->caps_wanted(), (cap->issued | cap->implemented), p->second, p->first); } @@ -9047,7 +9054,7 @@ int Client::_fsync(Inode *in, bool syncdataonly) } if (!syncdataonly && in->dirty_caps) { - check_caps(in, CHECK_CAPS_NODELAY); + check_caps(in, CHECK_CAPS_NODELAY|CHECK_CAPS_SYNCHRONOUS); if (in->flushing_caps) flush_tid = last_flush_tid; } else ldout(cct, 10) << "no metadata needs to commit" << dendl; diff --git a/src/client/Client.h b/src/client/Client.h index f9fceb9853b4..155385d192f2 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -628,7 +628,7 @@ protected: int mark_caps_flushing(Inode *in, ceph_tid_t *ptid); void adjust_session_flushing_caps(Inode *in, MetaSession *old_s, MetaSession *new_s); void flush_caps(); - void flush_caps(Inode *in, MetaSession *session); + void flush_caps(Inode *in, MetaSession *session, bool sync=false); void kick_flushing_caps(MetaSession *session); void early_kick_flushing_caps(MetaSession *session); void kick_maxsize_requests(MetaSession *session); @@ -654,6 +654,7 @@ protected: /* Flags for check_caps() */ #define CHECK_CAPS_NODELAY (0x1) +#define CHECK_CAPS_SYNCHRONOUS (0x2) void check_caps(Inode *in, unsigned flags); void get_cap_ref(Inode *in, int cap);