]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: faster versions of SnapMapper::get_legacy_prefix() & make_purged_snap_key()
authorRonen Friedman <rfriedma@redhat.com>
Thu, 4 Aug 2022 16:24:53 +0000 (16:24 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Thu, 4 Aug 2022 16:25:38 +0000 (16:25 +0000)
Using fmtlib, and treating the size of uint64_t as a known
quantity.

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/osd/SnapMapper.cc

index 26ace62a7382e469e8459979845b50b11f7216b3..9936808c10d2da661249fe1351c8031599c10bae 100644 (file)
@@ -419,10 +419,10 @@ int SnapMapper::get_snaps(
 
 string SnapMapper::make_purged_snap_key(int64_t pool, snapid_t last)
 {
-  char k[80];
-  snprintf(k, sizeof(k), "%s_%llu_%016llx", PURGED_SNAP_PREFIX,
-          (unsigned long long)pool, (unsigned long long)last);
-  return k;
+  return fmt::sprintf("%s_%lld_%016llx",
+                     PURGED_SNAP_PREFIX,
+                     pool,
+                     last);
 }
 
 void SnapMapper::make_purged_snap_key_value(
@@ -639,12 +639,9 @@ void SnapMapper::Scrubber::run()
 
 string SnapMapper::get_legacy_prefix(snapid_t snap)
 {
-  char buf[100];
-  int len = snprintf(
-    buf, sizeof(buf),
-    "%.*X_",
-    (int)(sizeof(snap)*2), static_cast<unsigned>(snap));
-  return LEGACY_MAPPING_PREFIX + string(buf, len);
+  return fmt::sprintf("%s%.16X_",
+                     LEGACY_MAPPING_PREFIX,
+                     snap);
 }
 
 string SnapMapper::to_legacy_raw_key(