From d33ad154bf04382974a0349606721f77ef69d67d Mon Sep 17 00:00:00 2001 From: Varada Kari Date: Thu, 13 Aug 2015 11:01:40 +0530 Subject: [PATCH] Adding statfs api to KeyValueDB If any backend supports and implements statfs will extract the stats from backend to show correct utilization in the status. Signed-off-by: Varada Kari --- src/os/KeyValueDB.h | 3 +++ src/os/KeyValueStore.cc | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/os/KeyValueDB.h b/src/os/KeyValueDB.h index 6568df8968924..a49c49bc9684a 100644 --- a/src/os/KeyValueDB.h +++ b/src/os/KeyValueDB.h @@ -176,6 +176,9 @@ public: } virtual uint64_t get_estimated_size(map &extra) = 0; + virtual int get_statfs(struct statfs *buf) { + return -EOPNOTSUPP; + } virtual ~KeyValueDB() {} diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index 4b3cf71579b05..bcb6b250d32b8 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -592,9 +592,12 @@ KeyValueStore::~KeyValueStore() int KeyValueStore::statfs(struct statfs *buf) { - if (::statfs(basedir.c_str(), buf) < 0) { - int r = -errno; - return r; + int r = backend->db->get_statfs(buf); + if (r < 0) { + if (::statfs(basedir.c_str(), buf) < 0) { + int r = -errno; + return r; + } } return 0; } -- 2.47.3