From b97f3d6761208a1d317db3d0dba8371181e0b49f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 21 Aug 2016 18:33:47 -0500 Subject: [PATCH] os/bluestore: include bluefs space in statfs result We were counting all (free) space allocated to bluefs as used. Instead, query bluefs to find out what is used and what is free. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index eac416d0e8e..3064fea8074 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3388,15 +3388,20 @@ void BlueStore::_sync() int BlueStore::statfs(struct store_statfs_t *buf) { - uint64_t bluefs_len = 0; - for (interval_set::iterator p = bluefs_extents.begin(); - p != bluefs_extents.end(); p++) - bluefs_len += p.get_len(); - buf->reset(); buf->total = bdev->get_size(); - assert(alloc->get_free() >= bluefs_len); - buf->available = (alloc->get_free() - bluefs_len); + buf->available = alloc->get_free(); + + if (bluefs) { + // part of our shared device is "free" accordingly to BlueFS + buf->available += bluefs->get_free(bluefs_shared_bdev); + + // include dedicated db, too, if that isn't the shared device. + if (bluefs_shared_bdev != BlueFS::BDEV_DB) { + buf->available += bluefs->get_free(BlueFS::BDEV_DB); + buf->total += bluefs->get_total(BlueFS::BDEV_DB); + } + } bufferlist bl; int r = db->get(PREFIX_STAT, "bluestore_statfs", &bl);