From: Jonas Jelten Date: Mon, 15 Mar 2021 22:21:07 +0000 (+0100) Subject: os/bluestore: strip trailing slash for directory listings X-Git-Tag: v15.2.14~45^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F41757%2Fhead;p=ceph.git os/bluestore: strip trailing slash for directory listings Calls to BlueRocksEnv::GetChildren may contain a trailing / in the queried directory, which is stripped away with this patch. If it's not stripped, the directory entry is not found in BlueFS: ``` 10 bluefs readdir db/ 20 bluefs readdir dir db/ not found 3 rocksdb: [db/db_impl/db_impl_open.cc:1785] Persisting Option File error: OK ``` Fixes: https://tracker.ceph.com/issues/49815 Signed-off-by: Jonas Jelten (cherry picked from commit 3aa31813980d22719277a04797df48310acdff66) --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 06a5cd714e49..2aa8628e8345 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -3719,6 +3719,10 @@ int BlueFS::unlock_file(FileLock *fl) int BlueFS::readdir(std::string_view dirname, vector *ls) { + // dirname may contain a trailing / + if (!dirname.empty() && dirname.back() == '/') { + dirname.remove_suffix(1); + } std::lock_guard l(lock); dout(10) << __func__ << " " << dirname << dendl; if (dirname.empty()) {