From patchwork Thu Aug 31 11:00:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrik Lundquist X-Patchwork-Id: 9931867 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 DA68B6022E for ; Thu, 31 Aug 2017 11:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC67528904 for ; Thu, 31 Aug 2017 11:00:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C12D42890B; Thu, 31 Aug 2017 11:00:57 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 62D9828904 for ; Thu, 31 Aug 2017 11:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751100AbdHaLAz (ORCPT ); Thu, 31 Aug 2017 07:00:55 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34869 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025AbdHaLAy (ORCPT ); Thu, 31 Aug 2017 07:00:54 -0400 Received: by mail-lf0-f65.google.com with SMTP id h132so230002lfh.2 for ; Thu, 31 Aug 2017 04:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7T/0KAvoeEAdeAsO+sZlDKoC5SbN0BIQtZyfDwxv9uY=; b=KEs40DB306pkMTpJsQJNJWC9J4GkVqWc6NORFFs5ycPM5e4wT7o4zu/8NA6xCR3HFu mPDtfbO27Dg8ll93ohXsIE2FZ8boJ+MGzdlUX8YZxaLGMkdRL+gDr/eo9rwBiKhYOcX5 utXIXdI0rM4bfmynmY8vSpE9iaMREyaWcHSIyroqNvx/3cWks7eXtCNFjU2vV12OB0mt 0w1vP6n1bV1uMsmzRz6FYDBBsMQpuDUbxUIrtzsAny4P4u32ks02yjg/m+MpNlhwXR3E YztD4NtRCtg7h/pHKy1m4GHTNPvC4JYJbYSF8ZA4Uydc5gDepG7WUgvt+ELXuXqaPCs8 c6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7T/0KAvoeEAdeAsO+sZlDKoC5SbN0BIQtZyfDwxv9uY=; b=nyYdwp+yra3a8Fh7k1ehD0qWs2GxZWGpFe3HEHGYq0j/ZYx+urzRsyyS0hm9vm0ZEW e/LXtpqje7Ns2wLeLdqVgtgMKn3Suxgio96iMcgSWUDbcw/ynkBrOyMrq95NlqtUHaPr +1wsBMIzYwjJb9O6jboTsURQ7aHvD8DIs5tLnpcNL/ykAaCgcDGMBh9vPNA1Uu6lGZsg 92s2AhCxg7Hy0APw+HygQZ0EIqr3i5kQyp85C7pny/Cg1T6JPr39AYVqnpRlkBG7gkBD pApO0OYE4YbRw62A9WL/Yw9yGebi1bzjaRLFuywyIT9O1z7t6frQJkopj4/MyeVGr67h Nq/g== X-Gm-Message-State: AHPjjUgwhBp3r0o9yLlvp5Lr5KIQYNKtppUtyeMBmtGtaYIUbVYhbNim wYqE/f9y73qAQyALqTE= X-Received: by 10.25.42.200 with SMTP id q69mr2043488lfq.44.1504177252960; Thu, 31 Aug 2017 04:00:52 -0700 (PDT) Received: from nas.localdomain ([2a01:3b8:1003:ff00:ec4:7aff:fe30:5c78]) by smtp.gmail.com with ESMTPSA id 205sm1540193ljj.12.2017.08.31.04.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 Aug 2017 04:00:52 -0700 (PDT) From: Patrik Lundquist To: linux-btrfs@vger.kernel.org Cc: Patrik Lundquist Subject: [PATCH] btrfs-progs: device usage: don't calculate slack on missing device Date: Thu, 31 Aug 2017 13:00:24 +0200 Message-Id: <20170831110024.9580-1-patrik.lundquist@gmail.com> X-Mailer: git-send-email 2.14.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 Print Device slack: 0.00B instead of Device slack: 16.00EiB Signed-off-by: Patrik Lundquist --- cmds-fi-usage.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c index 101a0c4..6c846c1 100644 --- a/cmds-fi-usage.c +++ b/cmds-fi-usage.c @@ -1040,6 +1040,7 @@ void print_device_sizes(struct device_info *devinfo, unsigned unit_mode) pretty_size_mode(devinfo->device_size, unit_mode)); printf(" Device slack: %*s%10s\n", (int)(20 - strlen("Device slack")), "", - pretty_size_mode(devinfo->device_size - devinfo->size, + pretty_size_mode(devinfo->device_size > 0 ? + devinfo->device_size - devinfo->size : 0, unit_mode)); }