diff options
author | Igor Fedotov <ifedotov@suse.com> | 2021-02-19 14:23:00 +0300 |
---|---|---|
committer | Igor Fedotov <ifed@suse.com> | 2021-07-16 15:53:54 +0300 |
commit | c2f82daea5d2b686ceebbcce8812fc9bc4538b16 (patch) | |
tree | 6fb6f19bd563e37073f105f27f987366da36b52d | |
parent | 7d518f6b629e6292006e88108f6ca78edde2db67 (diff) | |
download | ceph-c2f82daea5d2b686ceebbcce8812fc9bc4538b16.tar.gz |
tools/ceph-bluestore-tool: be more legible before requesting additional params
Request DB/WAL size specification when relevant devices are created
only.
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 94a91f54fe30a4dd113fbc1b02bc3f3d52c82a92)
-rw-r--r-- | src/os/bluestore/bluestore_tool.cc | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 2dc1016c38e..f38209504ad 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -676,6 +676,7 @@ int main(int argc, char **argv) parse_devices(cct.get(), devs, &cur_devs_map, &has_db, &has_wal); + const char* rlpath = nullptr; if (has_db && has_wal) { cerr << "can't allocate new device, both WAL and DB exist" << std::endl; @@ -689,24 +690,32 @@ int main(int argc, char **argv) << std::endl; exit(EXIT_FAILURE); } else if(!dev_target.empty() && - realpath(dev_target.c_str(), target_path) == nullptr) { + (rlpath = realpath(dev_target.c_str(), target_path)) == nullptr) { cerr << "failed to retrieve absolute path for " << dev_target << ": " << cpp_strerror(errno) << std::endl; exit(EXIT_FAILURE); } - // Create either DB or WAL volume - int r = EXIT_FAILURE; - if (need_db && cct->_conf->bluestore_block_db_size == 0) { - cerr << "DB size isn't specified, " - "please set Ceph bluestore-block-db-size config parameter " - << std::endl; - } else if (!need_db && cct->_conf->bluestore_block_wal_size == 0) { - cerr << "WAL size isn't specified, " - "please set Ceph bluestore-block-wal-size config parameter " - << std::endl; - } else { + // Attach either DB or WAL volume, create if needed + struct stat st; + int r = ::stat(rlpath, &st); + // check if we need additional size specification + if (r == ENOENT || (r == 0 && S_ISREG(st.st_mode) && st.st_size == 0)) { + r = 0; + if (need_db && cct->_conf->bluestore_block_db_size == 0) { + cerr << "Might need DB size specification, " + "please set Ceph bluestore-block-db-size config parameter " + << std::endl; + r = EXIT_FAILURE; + } else if (!need_db && cct->_conf->bluestore_block_wal_size == 0) { + cerr << "Might need WAL size specification, " + "please set Ceph bluestore-block-wal-size config parameter " + << std::endl; + r = EXIT_FAILURE; + } + } + if (r == 0) { BlueStore bluestore(cct.get(), path); r = bluestore.add_new_bluefs_device( need_db ? BlueFS::BDEV_NEWDB : BlueFS::BDEV_NEWWAL, @@ -719,8 +728,8 @@ int main(int argc, char **argv) << cpp_strerror(r) << std::endl; } - return r; } + return r; } else if (action == "bluefs-bdev-migrate") { map<string, int> cur_devs_map; set<int> src_dev_ids; |