From: Sage Weil Date: Sun, 21 Aug 2016 23:33:47 +0000 (-0500) Subject: os/bluestore: include bluefs space in statfs result X-Git-Tag: v11.0.1~415^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F10795%2Fhead;p=ceph.git 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index eac416d0e8e6..3064fea80744 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);