diff options
author | Kefu Chai <kchai@redhat.com> | 2021-05-20 13:55:13 +0800 |
---|---|---|
committer | Igor Fedotov <ifed@suse.com> | 2021-07-16 15:54:19 +0300 |
commit | cf2fa23f72f4f6bebca2eaa665527d9b363e9abf (patch) | |
tree | 8f070fc0f2d3219512663792c67f8cbea7fec754 | |
parent | c2f82daea5d2b686ceebbcce8812fc9bc4538b16 (diff) | |
download | ceph-cf2fa23f72f4f6bebca2eaa665527d9b363e9abf.tar.gz |
os/bluestore/bluestore_tool: compare retval stat() with -1
before this change, stat() is always called to check if the
file specified by --dev-target exists even if this option is not
specified. also, we compare the retval of stat() with ENOENT, while
state() returns -1 on error.
after this change, stat() is called only if --dev-target is specified,
and we compare the retval of stat() with -1 and 0 only, so if
--dev-target option is not specified, the tool still hehaves.
this change addresses a regression introduced by
94a91f54fe30a4dd113fbc1b02bc3f3d52c82a92
Fixes: https://tracker.ceph.com/issues/50891
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit d4c65a368c9cf35e01604fc3321f867cbe3e4109)
-rw-r--r-- | src/os/bluestore/bluestore_tool.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index f38209504ad..2b671484039 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -699,9 +699,12 @@ int main(int argc, char **argv) // Attach either DB or WAL volume, create if needed struct stat st; - int r = ::stat(rlpath, &st); + int r = -1; + if (rlpath != nullptr) { + 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)) { + if (r == -1 || (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, " |