[lxc-devel] [lxd/master] lxd/storage/zfs: Fix usage calculation

stgraber on Github lxc-bot at linuxcontainers.org
Fri Mar 6 15:32:41 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 354 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200306/c6316cca/attachment.bin>
-------------- next part --------------
From f36fa5adedb5d25f03084ba65ff27c1a422db553 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Fri, 6 Mar 2020 16:32:14 +0100
Subject: [PATCH] lxd/storage/zfs: Fix usage calculation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/storage/drivers/driver_zfs.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lxd/storage/drivers/driver_zfs.go b/lxd/storage/drivers/driver_zfs.go
index 0667aa7909..010a2747fa 100644
--- a/lxd/storage/drivers/driver_zfs.go
+++ b/lxd/storage/drivers/driver_zfs.go
@@ -398,12 +398,12 @@ func (d *zfs) Unmount() (bool, error) {
 
 func (d *zfs) GetResources() (*api.ResourcesStoragePool, error) {
 	// Get the total amount of space.
-	totalStr, err := d.getDatasetProperty(d.config["zfs.pool_name"], "available")
+	availableStr, err := d.getDatasetProperty(d.config["zfs.pool_name"], "available")
 	if err != nil {
 		return nil, err
 	}
 
-	total, err := strconv.ParseUint(strings.TrimSpace(totalStr), 10, 64)
+	available, err := strconv.ParseUint(strings.TrimSpace(availableStr), 10, 64)
 	if err != nil {
 		return nil, err
 	}
@@ -422,7 +422,7 @@ func (d *zfs) GetResources() (*api.ResourcesStoragePool, error) {
 	// Build the struct.
 	// Inode allocation is dynamic so no use in reporting them.
 	res := api.ResourcesStoragePool{}
-	res.Space.Total = total
+	res.Space.Total = used + available
 	res.Space.Used = used
 
 	return &res, nil


More information about the lxc-devel mailing list