]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: Fix BlueRocksEnv attempts to use POSIX
authorAdam Kupczyk <akupczyk@ibm.com>
Fri, 28 Jun 2024 06:02:52 +0000 (06:02 +0000)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Sat, 11 Jan 2025 07:27:26 +0000 (14:27 +0700)
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 <akupczyk@ibm.com>
(cherry picked from commit 76fb0820e60d65d205f85503abaf1dbf77adcdd1)

src/os/bluestore/BlueRocksEnv.h

index 62bcddcf67626e4e802081849d1f3b0ff46be352..71be27debbeba69b97d017e67e42c6f81684d1d8 100644 (file)
@@ -17,6 +17,14 @@ class BlueFS;
 
 class BlueRocksEnv : public rocksdb::EnvWrapper {
 public:
+  // See FileSystem::RegisterDbPaths.
+  rocksdb::Status RegisterDbPaths(const std::vector<std::string>& paths) override {
+    return rocksdb::Status::OK();
+  }
+  // See FileSystem::UnregisterDbPaths.
+  rocksdb::Status UnregisterDbPaths(const std::vector<std::string>& 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<rocksdb::WritableFile>* 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<rocksdb::WritableFile>* 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<rocksdb::WritableFile>* 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<rocksdb::RandomRWFile>* 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;