From 7b80ec4ba4db49e23ae1dedd0adf7acab340b041 Mon Sep 17 00:00:00 2001 From: Abutalib Aghayev Date: Mon, 14 Jun 2021 14:11:52 -0400 Subject: [PATCH] os/bluestore: Revise the naming scheme for per-zone cleaning information. Use a single letter (G) for the namespace, and use zone_num+oid as the key. Signed-off-by: Abutalib Aghayev --- src/os/bluestore/BlueStore.cc | 32 +++++++++++++++++++------------- src/os/bluestore/BlueStore.h | 6 +++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 63cacb061a6..e93c87fc26e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -11521,34 +11521,40 @@ void BlueStore::BSPerfTracker::update_from_perfcounters( } #ifdef HAVE_LIBZBD -// For every object we maintain 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 by -// enumerating all the keys starting with prefix. +// For every object we maintain 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 +// by enumerating all the keys starting with 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 diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 3e4a245e1c3..a1249607a4d 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -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> 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: -- 2.39.5