From e1a8fea924fde1958c53223fa9832c0d79ca3c66 Mon Sep 17 00:00:00 2001 From: dparmar18 Date: Mon, 5 Dec 2022 13:49:52 +0530 Subject: [PATCH] mds: remove inode from scrub_stack if being purged it an inode is being purged, scrub should not be ran on it. Fixes: https://tracker.ceph.com/issues/51824 Signed-off-by: Dhairya Parmar (cherry picked from commit ce12cd71ffa703c8e3f05617cd8261d4ff820e7e) --- src/mds/ScrubStack.cc | 12 ++++++++++++ src/mds/ScrubStack.h | 2 ++ src/mds/StrayManager.cc | 6 ++++++ 3 files changed, 20 insertions(+) diff --git a/src/mds/ScrubStack.cc b/src/mds/ScrubStack.cc index 202eebc6b1de1..c6ac668150ce8 100644 --- a/src/mds/ScrubStack.cc +++ b/src/mds/ScrubStack.cc @@ -825,6 +825,18 @@ void ScrubStack::dispatch(const cref_t &m) } } +bool ScrubStack::remove_inode_if_stacked(CInode *in) { + MDSCacheObject *obj = dynamic_cast(in); + if(obj->item_scrub.is_on_list()) { + dout(20) << "removing inode " << *in << " from scrub_stack" << dendl; + obj->put(MDSCacheObject::PIN_SCRUBQUEUE); + obj->item_scrub.remove_myself(); + stack_size--; + return true; + } + return false; +} + void ScrubStack::handle_scrub(const cref_t &m) { diff --git a/src/mds/ScrubStack.h b/src/mds/ScrubStack.h index 62a4a529944d2..756ebd9cb0e95 100644 --- a/src/mds/ScrubStack.h +++ b/src/mds/ScrubStack.h @@ -101,6 +101,8 @@ public: void dispatch(const cref_t &m); + bool remove_inode_if_stacked(CInode *in); + MDCache *mdcache; protected: diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index 9bf1a83d3a6e6..a480ca4ca75c7 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -20,6 +20,7 @@ #include "mds/MDLog.h" #include "mds/CDir.h" #include "mds/CDentry.h" +#include "mds/ScrubStack.h" #include "events/EUpdate.h" #include "messages/MClientRequest.h" @@ -297,6 +298,11 @@ void StrayManager::enqueue(CDentry *dn, bool trunc) CInode *in = dnl->get_inode(); ceph_assert(in); + //remove inode from scrub stack if it is being purged + if(mds->scrubstack->remove_inode_if_stacked(in)) { + dout(20) << "removed " << *in << " from the scrub stack" << dendl; + } + /* We consider a stray to be purging as soon as it is enqueued, to avoid * enqueing it twice */ dn->state_set(CDentry::STATE_PURGING); -- 2.39.5