From patchwork Sat Jun 2 21:26:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans van Kranenburg X-Patchwork-Id: 10445009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA89B602BC for ; Sat, 2 Jun 2018 21:33:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B28542886B for ; Sat, 2 Jun 2018 21:33:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A777C2899D; Sat, 2 Jun 2018 21:33:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A1082886B for ; Sat, 2 Jun 2018 21:33:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751503AbeFBVcV (ORCPT ); Sat, 2 Jun 2018 17:32:21 -0400 Received: from smtp.dpl.mendix.net ([83.96.177.10]:40163 "EHLO smtp.dpl.mendix.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750886AbeFBVcV (ORCPT ); Sat, 2 Jun 2018 17:32:21 -0400 X-Greylist: delayed 337 seconds by postgrey-1.27 at vger.kernel.org; Sat, 02 Jun 2018 17:32:20 EDT Received: from mekker.bofh.hq.mendix.net (mekker.bofh.hq.mendix.net [IPv6:2001:828:13c8:10b::21]) by smtp.dpl.mendix.net (Postfix) with ESMTP id DDCBB20103 for ; Sat, 2 Jun 2018 23:26:41 +0200 (CEST) From: Hans van Kranenburg To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: fi-usage: fix RAID10 raw disk usage Date: Sat, 2 Jun 2018 23:26:41 +0200 Message-Id: <20180602212641.928-1-hans@knorrie.org> X-Mailer: git-send-email 2.17.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of RAID10, fi usage is reporting half the amount of allocated space and twice the amount of unallocated disk space. Let's fix this. For example, a RAID10 chunk of 3GiB with num_stripes 6, half of the stripes (dev extents) are a mirror of the other half, so the 3GiB of actual data has to be divided by 3, and not 6 to get the size of each of those device extents. Signed-off-by: Hans van Kranenburg --- cmds-fi-usage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c index b9a2b1c8..3bd2ccdf 100644 --- a/cmds-fi-usage.c +++ b/cmds-fi-usage.c @@ -660,7 +660,7 @@ static u64 calc_chunk_size(struct chunk_info *ci) else if (ci->type & BTRFS_BLOCK_GROUP_RAID6) return ci->size / (ci->num_stripes -2); else if (ci->type & BTRFS_BLOCK_GROUP_RAID10) - return ci->size / ci->num_stripes; + return ci->size / (ci->num_stripes / 2); return ci->size; }