From: Igor Fedotov Date: Wed, 22 Apr 2020 12:27:42 +0000 (+0300) Subject: os/bluestore: update bdev label's size if supported only X-Git-Tag: v16.1.0~2497^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F34683%2Fhead;p=ceph.git os/bluestore: update bdev label's size if supported only Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BitmapFreelistManager.cc b/src/os/bluestore/BitmapFreelistManager.cc index f48e3943d6dc..4a9ad01d91ca 100644 --- a/src/os/bluestore/BitmapFreelistManager.cc +++ b/src/os/bluestore/BitmapFreelistManager.cc @@ -82,7 +82,7 @@ int BitmapFreelistManager::create(uint64_t new_size, uint64_t granularity, // set past-eof blocks as allocated _xor(size, blocks * bytes_per_block - size, txn); } - dout(0) << __func__ + dout(1) << __func__ << " size 0x" << std::hex << size << " bytes_per_block 0x" << bytes_per_block << " blocks 0x" << blocks @@ -220,7 +220,7 @@ int BitmapFreelistManager::init(KeyValueDB *kvdb, bool db_in_read_only, std::function cfg_reader) { dout(1) << __func__ << dendl; - int r = _init_from_external_cfg(cfg_reader); + int r = _read_cfg(cfg_reader); if (r != 0) { dout(1) << __func__ << " fall back to legacy meta repo" << dendl; _load_from_db(kvdb); @@ -237,7 +237,7 @@ int BitmapFreelistManager::init(KeyValueDB *kvdb, bool db_in_read_only, return 0; } -int BitmapFreelistManager::_init_from_external_cfg( +int BitmapFreelistManager::_read_cfg( std::function cfg_reader) { dout(1) << __func__ << dendl; @@ -265,7 +265,7 @@ int BitmapFreelistManager::_init_from_external_cfg( derr << __func__ << " Failed to parse - " << keys[i] << ":" << val << ", error: " << err << dendl; - return r; + return -EINVAL; } } else { // this is expected for legacy deployed OSDs diff --git a/src/os/bluestore/BitmapFreelistManager.h b/src/os/bluestore/BitmapFreelistManager.h index 8c08daa94e17..9689e87b37f8 100644 --- a/src/os/bluestore/BitmapFreelistManager.h +++ b/src/os/bluestore/BitmapFreelistManager.h @@ -46,7 +46,7 @@ class BitmapFreelistManager : public FreelistManager { uint64_t offset, uint64_t length, KeyValueDB::Transaction txn); - int _init_from_external_cfg( + int _read_cfg( std::function cfg_reader); int _expand(uint64_t new_size, KeyValueDB* db); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 4d3f7807dd64..937b09180ef9 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6840,6 +6840,24 @@ string BlueStore::get_device_path(unsigned id) return res; } +int BlueStore::_set_bdev_label_size(const string& path, uint64_t size) +{ + bluestore_bdev_label_t label; + int r = _read_bdev_label(cct, 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, path, label); + if (r < 0) { + derr << "unable to write label for " << path << ": " + << cpp_strerror(r) << dendl; + } + } + return r; +} + int BlueStore::expand_devices(ostream& out) { int r = cold_open(); @@ -6872,23 +6890,13 @@ int BlueStore::expand_devices(ostream& out) <<": can't find device path " << dendl; continue; } - bluestore_bdev_label_t label; - int r = _read_bdev_label(cct, path, &label); - if (r < 0) { - derr << "unable to read label for " << path << ": " - << cpp_strerror(r) << dendl; - continue; - } - label.size = size; - r = _write_bdev_label(cct, path, label); - if (r < 0) { - derr << "unable to write label for " << path << ": " - << cpp_strerror(r) << dendl; - continue; + if (bluefs->bdev_support_label(devid)) { + if (_set_bdev_label_size(p, size) >= 0) { + out << devid + << " : size label updated to " << size + << std::endl; + } } - out << devid - <<" : size label updated to " << size - << std::endl; } } uint64_t size0 = fm->get_size(); @@ -6898,6 +6906,13 @@ int BlueStore::expand_devices(ostream& out) << " : expanding " << " from 0x" << std::hex << size0 << " to 0x" << size << std::dec << std::endl; _write_out_fm_meta(size); + if (bdev->supported_bdev_label()) { + if (_set_bdev_label_size(path, size) >= 0) { + out << bluefs_layout.shared_bdev + << " : size label updated to " << size + << std::endl; + } + } cold_close(); // mount in read/write to sync expansion changes diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 82fbd72b56af..d251053ea2e2 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2317,6 +2317,7 @@ public: private: int _check_or_set_bdev_label(std::string path, uint64_t size, std::string desc, bool create); + int _set_bdev_label_size(const string& path, uint64_t size); int _open_super_meta();