From 9f6ccafb8656865c87c3052b12422322e1d1d276 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Mon, 29 Apr 2024 12:11:51 +0800 Subject: [PATCH] crimson/osd/pg: reset the snap mapper's backend when pg interval changes Fixes: https://tracker.ceph.com/issues/65679 Signed-off-by: Xuehan Xu --- src/common/map_cacher.hpp | 4 ++++ src/common/sharedptr_registry.hpp | 6 ++++++ src/crimson/osd/pg.cc | 1 + src/osd/SnapMapper.h | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/src/common/map_cacher.hpp b/src/common/map_cacher.hpp index a83f924b622c0..4d843be75dc64 100644 --- a/src/common/map_cacher.hpp +++ b/src/common/map_cacher.hpp @@ -85,6 +85,10 @@ private: public: MapCacher(StoreDriver *driver) : driver(driver) {} + void reset() { + in_progress.reset(); + } + /// Fetch first key/value std::pair after specified key int get_next( K key, ///< [in] key after which to get next diff --git a/src/common/sharedptr_registry.hpp b/src/common/sharedptr_registry.hpp index 3b3cf01bb28a0..8c0db6c24a702 100644 --- a/src/common/sharedptr_registry.hpp +++ b/src/common/sharedptr_registry.hpp @@ -18,6 +18,7 @@ #include #include #include "common/ceph_mutex.h" +#include "include/ceph_assert.h" /** * Provides a registry of shared_ptr indexed by K while @@ -61,6 +62,11 @@ public: waiting(0) {} + void reset() { + ceph_assert(!waiting); + contents.clear(); + } + bool empty() { std::lock_guard l(lock); return contents.empty(); diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index 5b2c5cedabbd9..6cb3b6f053649 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -1626,6 +1626,7 @@ void PG::on_change(ceph::os::Transaction &t) { // is save and in time. peering_state.state_clear(PG_STATE_SNAPTRIM); peering_state.state_clear(PG_STATE_SNAPTRIM_ERROR); + snap_mapper.reset_backend(); } void PG::context_registry_on_change() { diff --git a/src/osd/SnapMapper.h b/src/osd/SnapMapper.h index a90faa8e84fc3..f9a371932f622 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -356,6 +356,11 @@ private: return prefix_itr; } + /// reset the MapCacher backend, this should be called on pg interval change + void reset_backend() { + backend.reset(); + } + /// Update snaps for oid, empty new_snaps removes the mapping int update_snaps( const hobject_t &oid, ///< [in] oid to update -- 2.39.5