From 45c18be188a7caf573d4fe5b1dbb685202eac239 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 7 Mar 2024 14:30:35 -0500 Subject: [PATCH] mds: dispatch quiesce_inode ops after dir traversal Mostly to avoid the possibility of the CDir::items changing during iteration when calling sub-ops. Signed-off-by: Patrick Donnelly (cherry picked from commit c90cc2d04bb2d6d4e558fe268bcd241ea7723880) --- src/mds/MDCache.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e21d2d4d0ec..83fffabd509 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -13645,6 +13645,7 @@ void MDCache::dispatch_quiesce_inode(const MDRequestRef& mdr) } } MDSGatherBuilder gather(g_ceph_context, new C_MDS_RetryRequest(this, mdr)); + std::vector todispatch; for (auto& dir : in->get_dirfrags()) { for (auto& [dnk, dn] : *dir) { auto* in = dn->get_projected_inode(); @@ -13669,13 +13670,16 @@ void MDCache::dispatch_quiesce_inode(const MDRequestRef& mdr) cache->dispatch_request(qimdr); })); } else { - dispatch_request(qimdr); - } - if (!(qs.inc_heartbeat_count() % mds->heartbeat_reset_grace())) { - mds->heartbeat_reset(); + todispatch.push_back(qimdr); } } } + for (auto& qimdr : todispatch) { + dispatch_request(qimdr); + if (!(qs.inc_heartbeat_count() % mds->heartbeat_reset_grace())) { + mds->heartbeat_reset(); + } + } if (gather.has_subs()) { dout(20) << __func__ << ": waiting for sub-ops to gather" << dendl; gather.activate(); -- 2.39.5