From 91f777ad2707cfe32fcf61c4b0b0b59d7bb0bd54 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 (cherry picked from commit 9f6ccafb8656865c87c3052b12422322e1d1d276) --- 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 ad777c49d6011..fd7e09a898462 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -1592,6 +1592,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 70d1b6c39add7..688a7b8f1fffe 100644 --- a/src/osd/SnapMapper.h +++ b/src/osd/SnapMapper.h @@ -357,6 +357,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