From patchwork Tue Sep 17 07:23:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 2901281 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DE1FABFF05 for ; Tue, 17 Sep 2013 07:23:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C350820348 for ; Tue, 17 Sep 2013 07:23:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D17420336 for ; Tue, 17 Sep 2013 07:23:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751475Ab3IQHXp (ORCPT ); Tue, 17 Sep 2013 03:23:45 -0400 Received: from linux-libre.fsfla.org ([208.118.235.54]:56162 "EHLO linux-libre.fsfla.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751392Ab3IQHXo (ORCPT ); Tue, 17 Sep 2013 03:23:44 -0400 Received: from freie (home.lxoliva.fsfla.org [172.31.160.22]) by linux-libre.fsfla.org (8.14.4/8.14.4/Debian-2ubuntu2) with ESMTP id r8H7Ng2F003007 for ; Tue, 17 Sep 2013 07:23:42 GMT Received: from livre.home (livre.home [172.31.160.2]) by freie (8.14.7/8.14.6) with ESMTP id r8H7NWA5023562; Tue, 17 Sep 2013 04:23:32 -0300 From: Alexandre Oliva To: ceph-devel@vger.kernel.org Subject: [PATCH] osd: compute full ratio from kb_avail Organization: Free thinker, not speaking for the GNU Project Date: Tue, 17 Sep 2013 04:23:32 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- src/osd/OSD.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 66364ec3..841f1c4 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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;