From 3f8b332b8fb090ee6a97ed8dc88a5fd1bc4a4eb1 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Mon, 21 Aug 2017 15:21:07 +0800 Subject: [PATCH] mds: fix snap dentry discover bloom filter does not track snap dentries. pass proper snapid to CDir::add_null_dentry Signed-off-by: "Yan, Zheng" --- src/mds/MDCache.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 2d9fc00560491..20aaae2395c99 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -8044,7 +8044,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, Message *req, MDSInternalContextBa if (curdir->is_complete() || (snapid == CEPH_NOSNAP && curdir->has_bloom() && - !curdir->is_in_bloom(path[depth]))){ + !curdir->is_in_bloom(path[depth]))) { // file not found if (pdnvec) { // instantiate a null dn? @@ -8090,7 +8090,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, Message *req, MDSInternalContextBa mds_authority_t dauth = curdir->authority(); if (forward && - snapid && mdr && mdr->client_request && + mdr && mdr->client_request && (int)depth < mdr->client_request->get_num_fwd()) { dout(7) << "traverse: snap " << snapid << " and depth " << depth << " < fwd " << mdr->client_request->get_num_fwd() @@ -9912,7 +9912,9 @@ void MDCache::handle_discover(MDiscover *dis) // incomplete dir? if (!dn) { if (!curdir->is_complete() && - (!curdir->has_bloom() || curdir->is_in_bloom(dis->get_dentry(i)))) { + !(snapid == CEPH_NOSNAP && + curdir->has_bloom() && + !curdir->is_in_bloom(dis->get_dentry(i)))) { // readdir dout(7) << "incomplete dir contents for " << *curdir << ", fetching" << dendl; if (reply->is_empty()) { @@ -9928,10 +9930,19 @@ void MDCache::handle_discover(MDiscover *dis) } } + if (snapid != CEPH_NOSNAP && !reply->is_empty()) { + dout(7) << "dentry " << dis->get_dentry(i) << " snap " << snapid + << " dne, non-empty reply, stopping" << dendl; + break; + } + // send null dentry dout(7) << "dentry " << dis->get_dentry(i) << " dne, returning null in " << *curdir << dendl; - dn = curdir->add_null_dentry(dis->get_dentry(i)); + if (snapid == CEPH_NOSNAP) + dn = curdir->add_null_dentry(dis->get_dentry(i)); + else + dn = curdir->add_null_dentry(dis->get_dentry(i), snapid, snapid); } assert(dn); -- 2.39.5