The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/4897

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 6150b6113b81417b019bc95fc470384c3ba5785a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@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 <stgra...@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
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to