From 17d6a993fc17d533460c5f40f3908c708e057c18 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 23 May 2024 18:45:17 +0200 Subject: Merging upstream version 18.2.3. Signed-off-by: Daniel Baumann --- src/osd/PG.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/osd/PG.h') diff --git a/src/osd/PG.h b/src/osd/PG.h index 88c893b35..2f8b59061 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1019,6 +1019,19 @@ public: return num_bytes; } + uint64_t get_average_object_size() { + ceph_assert(ceph_mutex_is_locked_by_me(_lock)); + auto num_bytes = static_cast( + std::max( + 0, // ensure bytes is non-negative + info.stats.stats.sum.num_bytes)); + auto num_objects = static_cast( + std::max( + 1, // ensure objects is non-negative and non-zero + info.stats.stats.sum.num_objects)); + return std::max(num_bytes / num_objects, 1); + } + protected: /* -- cgit v1.2.3