From 9f244b211909a974af1724c6bf08b4537c923fa8 Mon Sep 17 00:00:00 2001 From: zczhu <> Date: Mon, 6 Jun 2022 14:27:31 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20default=20implementaton=20of=20close()=20?= =?UTF-8?q?function=20for=20Directory/FSDirecto=E2=80=A6=20(#10123)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: As pointed by anand1976 in his [comment](https://github.com/facebook/rocksdb/pull/10049#pullrequestreview-994255819), previous implementation (adding Close() function in Directory/FSDirectory class) is not backward-compatible. And we mistakenly added the default implementation `return Status::NotSupported("Close")` or `return IOStatus::NotSupported("Close")` in WritableFile class in this [pull request](https://github.com/facebook/rocksdb/pull/10101). This pull request fixes the above issue. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10123 Reviewed By: ajkr Differential Revision: D36943661 Pulled By: littlepig2013 fbshipit-source-id: 9dc45f4d2ab3a9d51c30bdfde679f1d13c4d5509 --- include/rocksdb/env.h | 4 ++-- include/rocksdb/file_system.h | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h index 262bc24ca..04198d32d 100644 --- a/include/rocksdb/env.h +++ b/include/rocksdb/env.h @@ -936,7 +936,7 @@ class WritableFile { // size due to whole pages writes. The behavior is undefined if called // with other writes to follow. virtual Status Truncate(uint64_t /*size*/) { return Status::OK(); } - virtual Status Close() { return Status::NotSupported("Close"); } + virtual Status Close() = 0; virtual Status Flush() = 0; virtual Status Sync() = 0; // sync data @@ -1149,7 +1149,7 @@ class Directory { // Fsync directory. Can be called concurrently from multiple threads. virtual Status Fsync() = 0; // Close directory. - virtual Status Close() = 0; + virtual Status Close() { return Status::NotSupported("Close"); } virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { return 0; diff --git a/include/rocksdb/file_system.h b/include/rocksdb/file_system.h index 9006921b4..7bc19976b 100644 --- a/include/rocksdb/file_system.h +++ b/include/rocksdb/file_system.h @@ -1022,9 +1022,8 @@ class FSWritableFile { return IOStatus::OK(); } virtual IOStatus Close(const IOOptions& /*options*/, - IODebugContext* /*dbg*/) { - return IOStatus::NotSupported("Close"); - } + IODebugContext* /*dbg*/) = 0; + virtual IOStatus Flush(const IOOptions& options, IODebugContext* dbg) = 0; virtual IOStatus Sync(const IOOptions& options, IODebugContext* dbg) = 0; // sync data @@ -1271,7 +1270,10 @@ class FSDirectory { } // Close directory - virtual IOStatus Close(const IOOptions& options, IODebugContext* dbg) = 0; + virtual IOStatus Close(const IOOptions& /*options*/, + IODebugContext* /*dbg*/) { + return IOStatus::NotSupported("Close"); + } virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { return 0;