From: Ronen Friedman Date: Sun, 4 Aug 2024 16:36:59 +0000 (-0500) Subject: osd: use an hex-only format for snap_id when creating snapmapper entries X-Git-Tag: testing/wip-vshankar-testing-20240826.122843-debug~21^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=21fe5264f7003c1629015bde63ff2fda98752c50;p=ceph-ci.git osd: use an hex-only format for snap_id when creating snapmapper entries i.e. - without the optional text representation of NOSNAP & SNAPDIR Signed-off-by: Ronen Friedman (cherry picked from commit 547b67fa684b50697b717b3fdcb88d71ae6956df) Signed-off-by: Matan Breizman --- diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc index f60a786f18a..414de479dc7 100644 --- a/src/osd/SnapMapper.cc +++ b/src/osd/SnapMapper.cc @@ -208,10 +208,14 @@ int OSDriver::get_next_or_current( string SnapMapper::get_prefix(int64_t pool, snapid_t snap) { static_assert(sizeof(pool) == 8, "assumed by the formatting code"); + + // note: the snap_id is to be formatted as a 64-bit hex number, + // and not according to the text representation of snapid_t + ceph_assert(snap != CEPH_NOSNAP && snap != CEPH_SNAPDIR); return fmt::sprintf("%s%lld_%.16X_", MAPPING_PREFIX, pool, - snap); + static_cast(snap)); } string SnapMapper::to_raw_key( @@ -729,10 +733,11 @@ int SnapMapper::get_snaps( string SnapMapper::make_purged_snap_key(int64_t pool, snapid_t last) { + ceph_assert(last != CEPH_NOSNAP && last != CEPH_SNAPDIR); return fmt::sprintf("%s_%lld_%016llx", PURGED_SNAP_PREFIX, pool, - last); + static_cast(last)); } void SnapMapper::make_purged_snap_key_value( @@ -950,9 +955,10 @@ void SnapMapper::Scrubber::run() string SnapMapper::get_legacy_prefix(snapid_t snap) { + ceph_assert(snap != CEPH_NOSNAP && snap != CEPH_SNAPDIR); return fmt::sprintf("%s%.16X_", LEGACY_MAPPING_PREFIX, - snap); + static_cast(snap)); } string SnapMapper::to_legacy_raw_key(