From 8cfc870ad5b11d5dfa1d16e172a228492d56570d Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Tue, 29 Nov 2022 10:40:54 +0000 Subject: [PATCH] osd/PeeringState: Add logs to can_serve_replica_read() Signed-off-by: Matan Breizman --- src/osd/PeeringState.cc | 19 +++++++++++++++++++ src/osd/PeeringState.h | 9 +-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index f25c862674172..8c7c15ee7e2ec 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -1404,6 +1404,25 @@ bool PeeringState::needs_backfill() const return false; } +/** +* Returns whether a particular object can be safely read on this replica +*/ +bool PeeringState::can_serve_replica_read(const hobject_t &hoid) +{ + ceph_assert(!is_primary()); + eversion_t min_last_complete_ondisk = get_min_last_complete_ondisk(); + if (!pg_log.get_log().has_write_since( + hoid, min_last_complete_ondisk)) { + psdout(20) << __func__ + << " can be safely read on this replica" << dendl; + return true; + } else { + psdout(20) << __func__ + << " can't read object on this replica" << dendl; + return false; + } +} + /* * Returns true unless there is a non-lost OSD in might_have_unfound. */ diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index b466a013e25fa..45a3c0a9cc3fb 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -2337,14 +2337,7 @@ public: bool needs_recovery() const; bool needs_backfill() const; - /** - * Returns whether a particular object can be safely read on this replica - */ - bool can_serve_replica_read(const hobject_t &hoid) { - ceph_assert(!is_primary()); - return !pg_log.get_log().has_write_since( - hoid, get_min_last_complete_ondisk()); - } + bool can_serve_replica_read(const hobject_t &hoid); /** * Returns whether the current acting set is able to go active -- 2.39.5