From: Igor Fedotov Date: Fri, 23 Nov 2018 11:39:20 +0000 (+0300) Subject: os/ceph-bluestore-tool: more strict control if bluefs device is expandable X-Git-Tag: v12.2.11~23^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2912a7aad56b6dd27089d8816ff1cb5e75a266e5;p=ceph.git os/ceph-bluestore-tool: more strict control if bluefs device is expandable Fixes: https://tracker.ceph.com/issues/37495 This commit is specific for pre-Nautilius releases (mimic & luminous) as we don't backport main device expansion feature. Which makes this mimic/luminous commit completely different from nautilus one. Signed-off-by: Igor Fedotov (cherry picked from commit 69a730d56b50985252a1a8ebf8ec44c5f43bf560) Conflicts: src/os/bluestore/bluestore_tool.cc Needed to downgrade ceph_assert call to assert one --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index cf9e1d60392..cf3063aa88b 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -299,6 +299,30 @@ int BlueFS::get_block_extents(unsigned id, interval_set *extents) return 0; } +// returns true if specified device is attached +bool BlueFS::is_device(unsigned id) +{ + return !(id >= MAX_BDEV || bdev[id] == nullptr); +} + +// returns true if specified device is under full bluefs control +// and hence can be expanded +bool BlueFS::is_device_expandable(unsigned id) +{ + if (id >= MAX_BDEV || bdev[id] == nullptr) { + return false; + } + switch(id) { + case BDEV_WAL: + return true; + + case BDEV_DB: + // true if DB volume is non-shared + return bdev[BDEV_SLOW] != nullptr; + } + return false; +} + int BlueFS::mkfs(uuid_d osd_uuid) { std::unique_lock l(lock); diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index ade3c0498e0..033a4930c99 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -347,6 +347,13 @@ public: /// get current extents that we own for given block device int get_block_extents(unsigned id, interval_set *extents); + // returns true if specified device is attached + bool is_device(unsigned id); + + // returns true if specified device is under full bluefs control + // and hence can be expanded + bool is_device_expandable(unsigned id); + int open_for_write( const string& dir, const string& file, diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index c307a6cd6f6..9e520cb3ed0 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -480,8 +480,18 @@ int main(int argc, char **argv) cout << "start:" << std::endl; fs->dump_block_extents(cout); for (int devid : { BlueFS::BDEV_WAL, BlueFS::BDEV_DB }) { + if (!fs->is_device(devid)) { + continue; + } + if (!fs->is_device_expandable(devid)) { + cout << devid + << " : can't be expanded." + << std::endl; + continue; + } interval_set before; fs->get_block_extents(devid, &before); + assert(!before.empty()); uint64_t end = before.range_end(); uint64_t size = fs->get_block_device_size(devid); if (end < size) {