diff mbox

btrfs-progs: device usage: don't calculate slack on missing device

Message ID 20170831110024.9580-1-patrik.lundquist@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Patrik Lundquist Aug. 31, 2017, 11 a.m. UTC
Print      Device slack:              0.00B
instead of Device slack:           16.00EiB

Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>
---
 cmds-fi-usage.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

David Sterba Sept. 4, 2017, 4:35 p.m. UTC | #1
On Thu, Aug 31, 2017 at 01:00:24PM +0200, Patrik Lundquist wrote:
> Print      Device slack:              0.00B
> instead of Device slack:           16.00EiB
> 
> Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com>

Applied, thanks. I've added a test.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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));
 }