From 8bab52275aebff5bb22829245456e0d390b07b10 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 1 Sep 2016 18:42:58 +0800 Subject: [PATCH] os/bluestore: don't over-gift if bluefs free is smaller than bluestore_bluefs_min - If free space of bluefs is smaller than bluestore_bluefs_min, then raise it exactly up to bluestore_bluefs_min. - Pre-check if bluestore_bluefs_min will exceed bluestore_bluefs_max_ratio * bluefs_total, so if free space of bluefs is smaller than bluestore_bluefs_min_ratio * bluefs_total, we'll still be able to gift. Signed-off-by: xie xingguo --- src/os/bluestore/BlueStore.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e24dda5f7f0..3d8aa8df126 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -2393,8 +2393,10 @@ int BlueStore::_balance_bluefs_freespace(vector *extents) << " > max_ratio " << g_conf->bluestore_bluefs_max_ratio << ", should reclaim " << pretty_si_t(reclaim) << dendl; } - if (bluefs_total < g_conf->bluestore_bluefs_min) { - uint64_t g = g_conf->bluestore_bluefs_min; + if (bluefs_total < g_conf->bluestore_bluefs_min && + g_conf->bluestore_bluefs_min < + (uint64_t)(g_conf->bluestore_bluefs_max_ratio * total_free)) { + uint64_t g = g_conf->bluestore_bluefs_min - bluefs_total; dout(10) << __func__ << " bluefs_total " << bluefs_total << " < min " << g_conf->bluestore_bluefs_min << ", should gift " << pretty_si_t(g) << dendl; @@ -2402,14 +2404,6 @@ int BlueStore::_balance_bluefs_freespace(vector *extents) gift = g; reclaim = 0; } - if (gift) { - float new_bluefs_ratio = (float)(bluefs_free + gift) / (float)total_free; - if (new_bluefs_ratio >= g_conf->bluestore_bluefs_max_ratio) { - dout(10) << __func__ << " gift would push us past the max_ratio," - << " doing nothing" << dendl; - gift = 0; - } - } if (gift) { // round up to alloc size -- 2.47.3