os/bluestore: prevent statfs available from going negative

Fixes: https://tracker.ceph.com/issues/23040
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2018-02-19 10:16:24 -06:00
parent 1b3d19a46b
commit 8709cbc2ec

View File

@ -6396,10 +6396,14 @@ int BlueStore::statfs(struct store_statfs_t *buf)
buf->available = alloc->get_free();
if (bluefs) {
// part of our shared device is "free" according to BlueFS
// Don't include bluestore_bluefs_min because that space can't
// be used for any other purpose.
buf->available += bluefs->get_free(bluefs_shared_bdev) - cct->_conf->bluestore_bluefs_min;
// part of our shared device is "free" according to BlueFS, but we
// can't touch bluestore_bluefs_min of it.
int64_t shared_available = std::min(
bluefs->get_free(bluefs_shared_bdev),
bluefs->get_total(bluefs_shared_bdev) - cct->_conf->bluestore_bluefs_min);
if (shared_available > 0) {
buf->available += shared_available;
}
// include dedicated db, too, if that isn't the shared device.
if (bluefs_shared_bdev != BlueFS::BDEV_DB) {