[lxc-devel] [lxd/master] lxd/storage/drivers/driver/btrfs/volumes: Dont activate quotas if not used

tomponline on Github lxc-bot at linuxcontainers.org
Mon Mar 16 14:37:37 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 442 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200316/b66ff385/attachment.bin>
-------------- next part --------------
From 7b99d26e118625757cead61f984125b50cdf304b Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 16 Mar 2020 14:36:26 +0000
Subject: [PATCH] lxd/storage/drivers/driver/btrfs/volumes: Dont activate
 quotas if not used

We shouldn't activate BTRFS quotas if not actually being used.

Fixes #7029

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/storage/drivers/driver_btrfs_volumes.go | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lxd/storage/drivers/driver_btrfs_volumes.go b/lxd/storage/drivers/driver_btrfs_volumes.go
index 202211cb30..ee8994b1fb 100644
--- a/lxd/storage/drivers/driver_btrfs_volumes.go
+++ b/lxd/storage/drivers/driver_btrfs_volumes.go
@@ -443,6 +443,11 @@ func (d *btrfs) SetVolumeQuota(vol Volume, size string, op *operations.Operation
 	if err != nil && !d.state.OS.RunningInUserNS {
 		// If quotas are disabled, attempt to enable them.
 		if err == errBtrfsNoQuota {
+			if sizeBytes <= 0 {
+				// Nothing to do if the quota is being removed and we don't currently have quota.
+				return nil
+			}
+
 			path := GetPoolMountPath(d.name)
 
 			_, err = shared.RunCommand("btrfs", "quota", "enable", path)


More information about the lxc-devel mailing list