]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: Revise the naming scheme for per-zone cleaning information. 41845/head
authorAbutalib Aghayev <agayev@psu.edu>
Mon, 14 Jun 2021 18:11:52 +0000 (14:11 -0400)
committerAbutalib Aghayev <agayev@psu.edu>
Thu, 17 Jun 2021 18:21:52 +0000 (14:21 -0400)
Use a single letter (G) for the namespace, and use zone_num+oid as the key.

Signed-off-by: Abutalib Aghayev <agayev@psu.edu>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 63cacb061a64a58d72805fd1d404e9023405d7f3..e93c87fc26e4273b6b015bef0b7dc791bc94c650 100644 (file)
@@ -11521,34 +11521,40 @@ void BlueStore::BSPerfTracker::update_from_perfcounters(
 }
 
 #ifdef HAVE_LIBZBD
-// For every object we maintain <zone_num+oid, offset> tuple in the key-value
-// store.  When a new object written to a zone, we insert the corresponding
-// tuple to the database.  When an object is truncated, we remove the
-// corresponding tuple.  When an object is overwritten, we remove the old tuple
-// and insert a new tuple corresponding to the new location of the object.  The
-// cleaner can now identify live objects within the zone <zone_num> by
-// enumerating all the keys starting with <zone_num> prefix.
+// For every object we maintain <zone_num+oid, offset> tuple in the
+// PREFIX_ZONED_CL_INFO namespace.  When a new object written to a zone, we
+// insert the corresponding tuple to the database.  When an object is truncated,
+// we remove the corresponding tuple.  When an object is overwritten, we remove
+// the old tuple and insert a new tuple corresponding to the new location of the
+// object.  The cleaner can now identify live objects within the zone <zone_num>
+// by enumerating all the keys starting with <zone_num> prefix.
 void BlueStore::_zoned_update_cleaning_metadata(TransContext *txc) {
   for (const auto &[o, offsets] : txc->zoned_onode_to_offset_map) {
-    std::string key;
-    get_object_key(cct, o->oid, &key);
     for (auto offset : offsets) {
       if (offset > 0) {
        bufferlist offset_bl;
        encode(offset, offset_bl);
-        txc->t->set(_zoned_get_prefix(offset), key, offset_bl);
+        txc->t->set(PREFIX_ZONED_CL_INFO, _zoned_key(offset, &o->oid), offset_bl);
       } else {
-        txc->t->rmkey(_zoned_get_prefix(-offset), key);
+        txc->t->rmkey(PREFIX_ZONED_CL_INFO, _zoned_key(-offset, &o->oid));
       }
     }
   }
 }
 
-std::string BlueStore::_zoned_get_prefix(uint64_t offset) {
+// Given an offset and possibly an oid, returns a key of the form zone_num+oid.
+std::string BlueStore::_zoned_key(uint64_t offset, const ghobject_t *oid) {
   uint64_t zone_num = offset / bdev->get_zone_size();
   std::string zone_key;
   _key_encode_u64(zone_num, &zone_key);
-  return PREFIX_ZONED_CL_INFO + zone_key;
+
+  if (!oid)
+    return zone_key;
+
+  std::string object_key;
+  get_object_key(cct, *oid, &object_key);
+
+  return zone_key + object_key;
 }
 
 // For now, to avoid interface changes we piggyback zone_size (in MiB) and the
index 3e4a245e1c379cacc521bf4ebbcab5d2b7cf1b1b..a1249607a4d2ad5b000f4dfa0e455ff405e15896 100644 (file)
@@ -1590,8 +1590,8 @@ public:
     // negative of the previous ondisk offset.  We need to maintain a vector of
     // offsets because *within the same transaction* an object may be truncated
     // and then written again, or an object may be overwritten multiple times to
-    // different zones.  See update_cleaning_metadata function for how this map
-    // is used.
+    // different zones.  See _zoned_update_cleaning_metadata function for how
+    // this map is used.
     std::map<OnodeRef, std::vector<int64_t>> zoned_onode_to_offset_map;
 #endif
     
@@ -2400,7 +2400,7 @@ private:
   uint64_t _zoned_piggyback_device_parameters_onto(uint64_t min_alloc_size);
   int _zoned_check_config_settings();
   void _zoned_update_cleaning_metadata(TransContext *txc);
-  std::string _zoned_get_prefix(uint64_t offset);
+  std::string _zoned_key(uint64_t offset, const ghobject_t *oid);
 #endif
 
 public: