From 7148b84e0634d8360fc3606e21a509a99fa7c6f8 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Thu, 3 Aug 2017 16:37:57 +0800 Subject: [PATCH] mds: properly do null snapflush part2 previous commit 4b95fbe327 "mds: properly do null snapflush part2" isn't complete. It doesn't properly handle case that snap get deleted before receiving corresponding snapflush. Signed-off-by: "Yan, Zheng" --- src/mds/Locker.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index ab8e943acd2ae..6460972fe993b 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2710,6 +2710,7 @@ void Locker::handle_client_caps(MClientCaps *m) return; } + bool need_unpin = false; int op = m->get_op(); // flushsnap? @@ -2723,6 +2724,13 @@ void Locker::handle_client_caps(MClientCaps *m) snapid_t snap = realm->get_snap_following(follows); dout(10) << " flushsnap follows " << follows << " -> snap " << snap << dendl; + auto p = head_in->client_need_snapflush.begin(); + if (p != head_in->client_need_snapflush.end() && p->first < snap) { + head_in->auth_pin(this); // prevent subtree frozen + need_unpin = true; + _do_null_snapflush(head_in, client, snap); + } + CInode *in = head_in; if (snap != CEPH_NOSNAP) { in = mdcache->pick_inode_snap(head_in, snap - 1); @@ -2750,8 +2758,6 @@ void Locker::handle_client_caps(MClientCaps *m) // this cap now follows a later snap (i.e. the one initiating this flush, or later) if (in == head_in) cap->client_follows = snap < CEPH_NOSNAP ? snap : realm->get_newest_seq(); - else if (head_in->client_need_snapflush.begin()->first < snap) - _do_null_snapflush(head_in, client, snap); _do_snap_update(in, snap, m->get_dirty(), follows, client, m, ack); @@ -2807,6 +2813,8 @@ void Locker::handle_client_caps(MClientCaps *m) // update/release). if (!head_in->client_need_snapflush.empty()) { if ((cap->issued() & CEPH_CAP_ANY_FILE_WR) == 0) { + head_in->auth_pin(this); // prevent subtree frozen + need_unpin = true; _do_null_snapflush(head_in, client); } else { dout(10) << " revocation in progress, not making any conclusions about null snapflushes" << dendl; @@ -2862,6 +2870,8 @@ void Locker::handle_client_caps(MClientCaps *m) } out: + if (need_unpin) + head_in->auth_unpin(this); m->put(); } -- 2.39.5