From de3f3d88b3e1557baa9e6701cfb2718e7d9d8f75 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 5 Jan 2018 09:51:19 +0800 Subject: [PATCH] mds: properly setup need_snapflush for snapped inode MDCache::cow_inode() checks "cap->issued() & CEPH_CAP_ANY_WR" to decide if it needs to setup need_snapflush for the new snapped inode. Locker::handle_client_caps() should call Locker::_do_cap_update() first, then update issued caps. Otherwise MDCache::cow_inode() will fail to setup need_snapflush if cap messages flushes dirty caps and releases the same caps. Signed-off-by: "Yan, Zheng" --- src/mds/Locker.cc | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index df65779239fc9..edea4cb065024 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2868,19 +2868,32 @@ void Locker::handle_client_caps(MClientCaps *m) caps &= cap->issued(); } - cap->confirm_receipt(m->get_seq(), caps); dout(10) << " follows " << follows << " retains " << ccap_string(m->get_caps()) << " dirty " << ccap_string(m->get_dirty()) << " on " << *in << dendl; + if (m->get_dirty() && in->is_auth()) { + dout(7) << " flush client." << client << " dirty " << ccap_string(m->get_dirty()) + << " seq " << m->get_seq() << " on " << *in << dendl; + ack = new MClientCaps(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(), + m->get_caps(), 0, m->get_dirty(), 0, mds->get_osd_epoch_barrier()); + ack->set_client_tid(m->get_client_tid()); + ack->set_oldest_flush_tid(m->get_oldest_flush_tid()); + } + + bool need_flush = m->flags & MClientCaps::FLAG_SYNC; + bool updated = in->is_auth() && + _do_cap_update(in, cap, m->get_dirty(), follows, m, ack, &need_flush); + + cap->confirm_receipt(m->get_seq(), caps); // missing/skipped snapflush? - // The client MAY send a snapflush if it is issued WR/EXCL caps, but - // presently only does so when it has actual dirty metadata. But, we - // set up the need_snapflush stuff based on the issued caps. - // We can infer that the client WONT send a FLUSHSNAP once they have - // released all WR/EXCL caps (the FLUSHSNAP always comes before the cap + // The client MAY send a snapflush if it is issued WR/EXCL caps, + // but only does so when it has actual dirty metadata. We set up + // the need_snapflush stuff based on the issued caps. We can infer + // that the client WONT send a FLUSHSNAP once they have released + // all WR/EXCL caps (the FLUSHSNAP always comes before the cap // update/release). if (!head_in->client_need_snapflush.empty()) { if (!(cap->issued() & CEPH_CAP_ANY_FILE_WR) && @@ -2894,18 +2907,8 @@ void Locker::handle_client_caps(MClientCaps *m) } if (cap->need_snapflush() && !(m->flags & MClientCaps::FLAG_PENDING_CAPSNAP)) cap->clear_needsnapflush(); - - if (m->get_dirty() && in->is_auth()) { - dout(7) << " flush client." << client << " dirty " << ccap_string(m->get_dirty()) - << " seq " << m->get_seq() << " on " << *in << dendl; - ack = new MClientCaps(CEPH_CAP_OP_FLUSH_ACK, in->ino(), 0, cap->get_cap_id(), m->get_seq(), - m->get_caps(), 0, m->get_dirty(), 0, mds->get_osd_epoch_barrier()); - ack->set_client_tid(m->get_client_tid()); - ack->set_oldest_flush_tid(m->get_oldest_flush_tid()); - } // filter wanted based on what we could ever give out (given auth/replica status) - bool need_flush = m->flags & MClientCaps::FLAG_SYNC; int new_wanted = m->get_wanted() & head_in->get_caps_allowed_ever(); if (new_wanted != cap->wanted()) { if (!need_flush && (new_wanted & ~cap->pending())) { @@ -2916,8 +2919,7 @@ void Locker::handle_client_caps(MClientCaps *m) adjust_cap_wanted(cap, new_wanted, m->get_issue_seq()); } - if (in->is_auth() && - _do_cap_update(in, cap, m->get_dirty(), follows, m, ack, &need_flush)) { + if (updated) { // updated eval(in, CEPH_CAP_LOCKS); -- 2.39.5