From 71c3b58da4e7ced3422bce2b1da0e3fa9331530b Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Thu, 24 May 2018 19:05:48 +0300 Subject: [PATCH] tools/ceph-bluestore-tool: update size label on bluefs expand Signed-off-by: Igor Fedotov --- src/os/bluestore/bluestore_tool.cc | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index fc21750542eca..50834d369cf43 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -66,6 +66,28 @@ void validate_path(CephContext *cct, const string& path, bool bluefs) } } +const char* find_device_path( + int id, + CephContext *cct, + const vector& devs) +{ + for (auto& i : devs) { + bluestore_bdev_label_t label; + int r = BlueStore::_read_bdev_label(cct, i, &label); + if (r < 0) { + cerr << "unable to read label for " << i << ": " + << cpp_strerror(r) << std::endl; + exit(EXIT_FAILURE); + } + if ((id == BlueFS::BDEV_SLOW && label.description == "main") || + (id == BlueFS::BDEV_DB && label.description == "bluefs db") || + (id == BlueFS::BDEV_WAL && label.description == "bluefs wal")) { + return i.c_str(); + } + } + return nullptr; +} + void add_devices( BlueFS *fs, CephContext *cct, @@ -483,6 +505,27 @@ int main(int argc, char **argv) cout << "expanding dev " << devid << " from 0x" << std::hex << end << " to 0x" << size << std::dec << std::endl; fs->add_block_extent(devid, end, size-end); + const char* path = find_device_path(devid, cct.get(), devs); + if (path == nullptr) { + cerr << "Can't find device path for dev " << devid << std::endl; + continue; + } + bluestore_bdev_label_t label; + int r = BlueStore::_read_bdev_label(cct.get(), path, &label); + if (r < 0) { + cerr << "unable to read label for " << path << ": " + << cpp_strerror(r) << std::endl; + continue; + } + label.size = size; + r = BlueStore::_write_bdev_label(cct.get(), path, label); + if (r < 0) { + cerr << "unable to write label for " << path << ": " + << cpp_strerror(r) << std::endl; + continue; + } + cout << "dev " << devid << " size label updated to " + << size << std::endl; } } delete fs; -- 2.39.5