From 21906d66f619a498936545509c40af6abd084dc2 Mon Sep 17 00:00:00 2001
From: zczhu <>
Date: Fri, 3 Jun 2022 12:53:28 -0700
Subject: [PATCH] Add default impl to dir close (#10101)

Summary:
As pointed by anand1976 in his [comment](https://github.com/facebook/rocksdb/pull/10049#pullrequestreview-994255819), previous implementation is not backward-compatible. In this implementation, the default implementation `return Status::NotSupported("Close")` or `return IOStatus::NotSupported("Close")` is added for `Close()` function for `*Directory` classes.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10101

Test Plan: DBBasicTest.DBCloseAllDirectoryFDs

Reviewed By: anand1976

Differential Revision: D36899346

Pulled By: littlepig2013

fbshipit-source-id: 430624793362f330cbb8837960f0e8712a944ab9
---
 include/rocksdb/env.h         | 2 +-
 include/rocksdb/file_system.h | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/rocksdb/env.h b/include/rocksdb/env.h
index cda120e84..262bc24ca 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() = 0;
+  virtual Status Close() { return Status::NotSupported("Close"); }
   virtual Status Flush() = 0;
   virtual Status Sync() = 0;  // sync data
 
diff --git a/include/rocksdb/file_system.h b/include/rocksdb/file_system.h
index 6eab0d84e..9006921b4 100644
--- a/include/rocksdb/file_system.h
+++ b/include/rocksdb/file_system.h
@@ -1021,7 +1021,10 @@ class FSWritableFile {
                             IODebugContext* /*dbg*/) {
     return IOStatus::OK();
   }
-  virtual IOStatus Close(const IOOptions& options, IODebugContext* dbg) = 0;
+  virtual IOStatus Close(const IOOptions& /*options*/,
+                         IODebugContext* /*dbg*/) {
+    return IOStatus::NotSupported("Close");
+  }
   virtual IOStatus Flush(const IOOptions& options, IODebugContext* dbg) = 0;
   virtual IOStatus Sync(const IOOptions& options,
                         IODebugContext* dbg) = 0;  // sync data