osd: compute full ratio from kb_avail
PATCH 1/1 osd: compute full ratio from kb_avail
On btrfs, kb_used + kb_avail can be much smaller than total kb, and what really matters to avoid filling up the disk is how much space is available, not how much we've used. Thus, compute the ratio we use to determine full or nearfull from kb_avail rather than from kb_used.
Signed-off-by Alexandre Oliva <[email protected]>
--- src/osd/OSD.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/osd/OSD.cc +6 -1
@@ -2457,7 +2457,12 @@ void OSDService::check_nearfull_warning(const osd_stat_t &osd_stat) time_t now = ceph_clock_gettime(NULL); - float ratio = ((float)osd_stat.kb_used) / ((float)osd_stat.kb); + // We base ratio on kb_avail rather than kb_used because they can + // differ significantly e.g. on btrfs volumes with a large number of + // chunks reserved for metadata, and for our purposes (avoiding + // completely filling the disk) it's far more important to know how + // much space is available to use than how much we've already used. + float ratio = ((float)(osd_stat.kb - osd_stat.kb_avail)) / ((float)osd_stat.kb); float nearfull_ratio = get_nearfull_ratio(); float full_ratio = get_full_ratio(); cur_ratio = ratio;
Signature · 4 lines
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer
Sage Weil
AppliedApplied, thanks!
s
Quoted 40 lines · Alexandre Oliva
On btrfs,
kb_used+kb_availcan be much smaller than total kb, and what really matters to avoid filling up the disk is how much space is available, not how much we've used. Thus, compute the ratio we use to determine full or nearfull fromkb_availrather than fromkb_used.Signed-off-by Alexandre Oliva <[email protected]>--- src/osd/OSD.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)src/osd/OSD.cc +6
-1@@ -2457,7 +2457,12 @@ void OSDService::check_nearfull_warning(const osd_stat_t &osd_stat) time_t now = ceph_clock_gettime(NULL); - float ratio = ((float)osd_stat.kb_used) / ((float)osd_stat.kb); + // We base ratio on kb_avail rather than kb_used because they can + // differ significantly e.g. on btrfs volumes with a large number of + // chunks reserved for metadata, and for our purposes (avoiding + // completely filling the disk) it's far more important to know how + // much space is available to use than how much we've already used. + float ratio = ((float)(osd_stat.kb - osd_stat.kb_avail)) / ((float)osd_stat.kb); float nearfull_ratio = get_nearfull_ratio(); float full_ratio = get_full_ratio(); cur_ratio = ratio;Signature · 9 lines
-- Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/ You must be the change you wish to see in the world. -- Gandhi Be Free! -- http://FSFLA.org/ FSF Latin America board member Free Software Evangelist Red Hat Brazil Compiler Engineer -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html