[lxc-devel] [lxd/master] lxd/storage/zfs: Optimize getting disk usage
stgraber on Github
lxc-bot at linuxcontainers.org
Fri Aug 10 03:23:24 UTC 2018
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/20180810/80838f45/attachment.bin>
-------------- next part --------------
From 6150b6113b81417b019bc95fc470384c3ba5785a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 9 Aug 2018 23:23:04 -0400
Subject: [PATCH] lxd/storage/zfs: Optimize getting disk usage
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_zfs.go | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/lxd/storage_zfs.go b/lxd/storage_zfs.go
index 2a0190ab7e..4fe9ae6891 100644
--- a/lxd/storage_zfs.go
+++ b/lxd/storage_zfs.go
@@ -10,6 +10,7 @@ import (
"path/filepath"
"strconv"
"strings"
+ "syscall"
"github.com/gorilla/websocket"
@@ -1505,6 +1506,18 @@ func (s *storageZfs) ContainerGetUsage(container container) (int64, error) {
property = "referenced"
}
+ // Shortcut for refquota
+ mountpoint := getContainerMountPoint(s.pool.Name, container.Name())
+ if property == "referenced" && shared.IsMountPoint(mountpoint) {
+ var stat syscall.Statfs_t
+ err := syscall.Statfs(mountpoint, &stat)
+ if err != nil {
+ return -1, err
+ }
+
+ return int64(stat.Blocks-stat.Bfree) * int64(stat.Bsize), nil
+ }
+
value, err := zfsFilesystemEntityPropertyGet(s.getOnDiskPoolName(), fs, property)
if err != nil {
return -1, err
More information about the lxc-devel
mailing list