From 2a3eb6e2bc687630f9e0e8d5e7b12a50d75d4c47 Mon Sep 17 00:00:00 2001 From: Abutalib Aghayev Date: Wed, 4 Nov 2020 13:57:05 -0500 Subject: [PATCH] os/bluestore: Cleanup. Move ZBD related functions into one place and add zoned prefix to all of them. Signed-off-by: Abutalib Aghayev --- src/os/bluestore/BlueStore.cc | 10 +++++----- src/os/bluestore/BlueStore.h | 12 +++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index b75ee5972c5a..21f0325eeb48 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -11152,7 +11152,7 @@ void BlueStore::BSPerfTracker::update_from_perfcounters( // 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) { +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); @@ -11160,15 +11160,15 @@ void BlueStore::zoned_update_cleaning_metadata(TransContext *txc) { if (offset > 0) { bufferlist offset_bl; encode(offset, offset_bl); - txc->t->set(zoned_get_prefix(offset), key, offset_bl); + txc->t->set(_zoned_get_prefix(offset), key, offset_bl); } else { - txc->t->rmkey(zoned_get_prefix(-offset), key); + txc->t->rmkey(_zoned_get_prefix(-offset), key); } } } } -std::string BlueStore::zoned_get_prefix(uint64_t offset) { +std::string BlueStore::_zoned_get_prefix(uint64_t offset) { uint64_t zone_num = offset / bdev->get_zone_size(); std::string zone_key; _key_encode_u64(zone_num, &zone_key); @@ -11262,7 +11262,7 @@ void BlueStore::_txc_finalize_kv(TransContext *txc, KeyValueDB::Transaction t) } if (bdev->is_smr()) { - zoned_update_cleaning_metadata(txc); + _zoned_update_cleaning_metadata(txc); } _txc_update_store_statfs(txc); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index fdde77dabb7f..4d8a669e0e98 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1153,7 +1153,7 @@ public: // are laid out contiguously on disk, which is not the case in general. // Also, it should always be called after calling extent_map.fault_range(), // so that the extent map is loaded. - int64_t get_ondisk_starting_offset() const { + int64_t zoned_get_ondisk_starting_offset() const { return extent_map.extent_map.begin()->blob-> get_blob().calc_offset(0, nullptr); } @@ -1672,12 +1672,12 @@ public: void zoned_note_new_object(OnodeRef &o) { auto [_, ok] = zoned_onode_to_offset_map.emplace( - std::pair>(o, {o->get_ondisk_starting_offset()})); + std::pair>(o, {o->zoned_get_ondisk_starting_offset()})); ceph_assert(ok); } void zoned_note_updated_object(OnodeRef &o, int64_t prev_offset) { - int64_t new_offset = o->get_ondisk_starting_offset(); + int64_t new_offset = o->zoned_get_ondisk_starting_offset(); auto [it, ok] = zoned_onode_to_offset_map.emplace( std::pair>(o, {-prev_offset, new_offset})); if (!ok) { @@ -2393,6 +2393,8 @@ private: // Functions related to zoned storage. 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); public: utime_t get_deferred_last_submitted() { @@ -3432,10 +3434,6 @@ private: void _fsck_check_objects(FSCKDepth depth, FSCK_ObjectCtx& ctx); - - // Zoned storage related stuff - void zoned_update_cleaning_metadata(TransContext *txc); - std::string zoned_get_prefix(uint64_t offset); }; inline std::ostream& operator<<(std::ostream& out, const BlueStore::volatile_statfs& s) { -- 2.47.3