From 94af5f07f26d579d1130a1c37d86b135bf736f12 Mon Sep 17 00:00:00 2001 From: Adam Kupczyk Date: Fri, 28 Jun 2024 06:02:52 +0000 Subject: [PATCH] os/bluestore: Fix BlueRocksEnv attempts to use POSIX How is it possible that we are mixing BlueFS and posix operations? BlueRocksEnv implements rocksdb::Env interface. To make things simpler it inherits from rocksdb::EnvWrapper. The rocksdb::EnvWrapper is initialized from DefaultEnv, which brings default implementation for threads and files. We override file-related interface. The problem is when we forget to implement something, or if rocksdb::Env interface gets expanded. The function returns ENOTSUPP, and rocksdb can handle it. But it does not matter, because it is implemented in DefaultEnv. In future we should drop inheriting from EnvWrapper and call DefaultEnv directly wherever we need. Fixes https://tracker.ceph.com/issues/66717. Signed-off-by: Adam Kupczyk (cherry picked from commit 76fb0820e60d65d205f85503abaf1dbf77adcdd1) --- src/os/bluestore/BlueRocksEnv.h | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/os/bluestore/BlueRocksEnv.h b/src/os/bluestore/BlueRocksEnv.h index 62bcddcf67626..71be27debbeba 100644 --- a/src/os/bluestore/BlueRocksEnv.h +++ b/src/os/bluestore/BlueRocksEnv.h @@ -17,6 +17,14 @@ class BlueFS; class BlueRocksEnv : public rocksdb::EnvWrapper { public: + // See FileSystem::RegisterDbPaths. + rocksdb::Status RegisterDbPaths(const std::vector& paths) override { + return rocksdb::Status::OK(); + } + // See FileSystem::UnregisterDbPaths. + rocksdb::Status UnregisterDbPaths(const std::vector& paths) override { + return rocksdb::Status::OK(); + } // Create a brand new sequentially-readable file with the specified name. // On success, stores a pointer to the new file in *result and returns OK. // On failure, stores nullptr in *result and returns non-OK. If the file does @@ -52,6 +60,21 @@ public: std::unique_ptr* result, const rocksdb::EnvOptions& options) override; + // Create an object that writes to a file with the specified name. + // `WritableFile::Append()`s will append after any existing content. If the + // file does not already exist, creates it. + // + // On success, stores a pointer to the file in *result and returns OK. On + // failure stores nullptr in *result and returns non-OK. + // + // The returned file will only be accessed by one thread at a time. + rocksdb::Status ReopenWritableFile( + const std::string& fname, + std::unique_ptr* result, + const rocksdb::EnvOptions& options) override { + return rocksdb::Status::NotSupported("ReopenWritableFile() not supported."); + } + // Reuse an existing file by renaming it and opening it as writable. rocksdb::Status ReuseWritableFile( const std::string& fname, @@ -59,6 +82,17 @@ public: std::unique_ptr* result, const rocksdb::EnvOptions& options) override; + // Open `fname` for random read and write, if file doesn't exist the file + // will be created. On success, stores a pointer to the new file in + // *result and returns OK. On failure returns non-OK. + // + // The returned file will only be accessed by one thread at a time. + rocksdb::Status NewRandomRWFile(const std::string& fname, + std::unique_ptr* result, + const rocksdb::EnvOptions& options)override { + return rocksdb::Status::NotSupported("RandomRWFile is not implemented in this Env"); + } + // Create an object that represents a directory. Will fail if directory // doesn't exist. If the directory exists, it will open the directory // and create a new Directory object. @@ -86,6 +120,11 @@ public: // Delete the named file. rocksdb::Status DeleteFile(const std::string& fname) override; + // Truncate the named file to the specified size. + rocksdb::Status Truncate(const std::string& fname, size_t size) override { + return rocksdb::Status::NotSupported("Truncate is not supported for this Env"); + } + // Create the specified directory. Returns error if directory exists. rocksdb::Status CreateDir(const std::string& dirname) override; -- 2.39.5