From dafa7d2788ac58e9bef278e59fa709bee45f2c4d Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 3 Jun 2015 17:40:16 +0800 Subject: [PATCH] client: don't change flush TID when re-send cap flush Client::wait_sync_caps requires stable TIDs for flushing caps. Signed-off-by: Yan, Zheng --- src/client/Client.cc | 35 ++++++++++++++++++++++------------- src/client/Client.h | 5 +++-- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 1fad25149c2a5..0ba948128c30d 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2876,7 +2876,8 @@ void Client::cap_delay_requeue(Inode *in) } void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, - int used, int want, int retain, int flush) + int used, int want, int retain, int flush, + ceph_tid_t flush_tid) { int held = cap->issued | cap->implemented; int revoking = cap->implemented & ~cap->issued; @@ -2919,14 +2920,10 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap, cap->implemented &= cap->issued | used; } - uint64_t flush_tid = 0; snapid_t follows = 0; - if (flush) { - flush_tid = ++last_flush_tid; - in->flushing_cap_tids[flush_tid] = flush; + if (flush) follows = in->snaprealm->get_snap_context().seq; - } MClientCaps *m = new MClientCaps(op, in->ino, @@ -3081,12 +3078,15 @@ void Client::check_caps(Inode *in, bool is_delayed) ack: int flushing; - if (in->auth_cap == cap && in->dirty_caps) - flushing = mark_caps_flushing(in); - else + ceph_tid_t flush_tid; + if (in->auth_cap == cap && in->dirty_caps) { + flushing = mark_caps_flushing(in, &flush_tid); + } else { flushing = 0; + flush_tid = 0; + } - send_cap(in, session, cap, cap_used, wanted, retain, flushing); + send_cap(in, session, cap, cap_used, wanted, retain, flushing, flush_tid); } } @@ -3708,13 +3708,16 @@ void Client::mark_caps_dirty(Inode *in, int caps) in->dirty_caps |= caps; } -int Client::mark_caps_flushing(Inode *in) +int Client::mark_caps_flushing(Inode *in, ceph_tid_t* ptid) { MetaSession *session = in->auth_cap->session; int flushing = in->dirty_caps; assert(flushing); + ceph_tid_t flush_tid = ++last_flush_tid; + in->flushing_cap_tids[flush_tid] = flushing; + if (!in->flushing_caps) { ldout(cct, 10) << "mark_caps_flushing " << ccap_string(flushing) << " " << *in << dendl; in->flushing_cap_seq = ++last_flush_seq; @@ -3729,6 +3732,7 @@ int Client::mark_caps_flushing(Inode *in) session->flushing_caps.push_back(&in->flushing_cap_item); + *ptid = flush_tid; return flushing; } @@ -3758,8 +3762,13 @@ void Client::flush_caps(Inode *in, MetaSession *session) Cap *cap = in->auth_cap; assert(cap->session == session); - send_cap(in, session, cap, get_caps_used(in), in->caps_wanted(), - (cap->issued | cap->implemented), in->flushing_caps); + for (map::iterator p = in->flushing_cap_tids.begin(); + p != in->flushing_cap_tids.end(); + ++p) { + send_cap(in, session, cap, (get_caps_used(in) | in->caps_dirty()), + in->caps_wanted(), (cap->issued | cap->implemented), + p->second, p->first); + } } void Client::wait_sync_caps(Inode *in, ceph_tid_t want) diff --git a/src/client/Client.h b/src/client/Client.h index 6fa4c235b74e0..b6ea21ba7eb60 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -535,7 +535,7 @@ protected: void remove_all_caps(Inode *in); void remove_session_caps(MetaSession *session); void mark_caps_dirty(Inode *in, int caps); - int mark_caps_flushing(Inode *in); + int mark_caps_flushing(Inode *in, ceph_tid_t *ptid); void flush_caps(); void flush_caps(Inode *in, MetaSession *session); void kick_flushing_caps(MetaSession *session); @@ -557,7 +557,8 @@ protected: void handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, class MClientCaps *m); void cap_delay_requeue(Inode *in); void send_cap(Inode *in, MetaSession *session, Cap *cap, - int used, int want, int retain, int flush); + int used, int want, int retain, int flush, + ceph_tid_t flush_tid); void check_caps(Inode *in, bool is_delayed); void get_cap_ref(Inode *in, int cap); void put_cap_ref(Inode *in, int cap); -- 2.47.3