From b567f85c56f681f77586fe2b5a12440b4d58dbfc Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Mon, 17 Feb 2025 22:04:18 +0300 Subject: [PATCH] os/bluestore: use proper device when updating DB/WAL label while expanding. Fixes: https://tracker.ceph.com/issues/69999 Signed-off-by: Igor Fedotov (cherry picked from commit ba3e4d2c9daf6b3af8340607e722f31b83e69db8) --- src/os/bluestore/BlueStore.cc | 36 +++++++++++++++++------------------ src/os/bluestore/BlueStore.h | 2 +- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index ac8f38e897d7c..f0e37b4f7d70c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8894,19 +8894,25 @@ string BlueStore::get_device_path(unsigned id) return res; } -int BlueStore::_set_bdev_label_size(const string& path, uint64_t size) +int BlueStore::_set_bdev_label_size(unsigned id, uint64_t size) { - bluestore_bdev_label_t label; - int r = _read_bdev_label(cct, bdev, path, &label); - if (r < 0) { - derr << "unable to read label for " << path << ": " - << cpp_strerror(r) << dendl; - } else { - label.size = size; - r = _write_bdev_label(cct, bdev, path, label); + ceph_assert(bluefs); + BlockDevice* my_bdev = bluefs->get_block_device(id); + int r = -1; + if (my_bdev != nullptr) { + string my_path = get_device_path(id); + bluestore_bdev_label_t label; + r = _read_bdev_label(cct, my_bdev, my_path, &label); if (r < 0) { - derr << "unable to write label for " << path << ": " + derr << "unable to read label for " << my_path << ": " << cpp_strerror(r) << dendl; + } else { + label.size = size; + r = _write_bdev_label(cct, my_bdev, my_path, label); + if (r < 0) { + derr << "unable to write label for " << my_path << ": " + << cpp_strerror(r) << dendl; + } } } return r; @@ -8931,18 +8937,10 @@ int BlueStore::expand_devices(ostream& out) // no bdev continue; } - out << devid <<" : expanding " << " to 0x" << size << std::dec << std::endl; - string p = get_device_path(devid); - const char* path = p.c_str(); - if (path == nullptr) { - derr << devid - <<": can't find device path " << dendl; - continue; - } if (bluefs->bdev_support_label(devid)) { - if (_set_bdev_label_size(p, size) >= 0) { + if (_set_bdev_label_size(devid, size) >= 0) { out << devid << " : size label updated to " << size << std::endl; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 368c842d4cdad..ed768cddb0268 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2804,7 +2804,7 @@ private: std::vector* out_valid_positions = nullptr, bool* out_is_multi = nullptr, int64_t* out_epoch = nullptr); - int _set_bdev_label_size(const std::string& path, uint64_t size); + int _set_bdev_label_size(unsigned id, uint64_t size); void _main_bdev_label_try_reserve(); void _main_bdev_label_remove(Allocator* alloc); -- 2.39.5