[lxc-devel] [lxd/master] lxd/storage/dir: Don't apply quotas on snapshots

stgraber on Github lxc-bot at linuxcontainers.org
Thu Nov 7 15:37:37 UTC 2019


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/20191107/beb6c673/attachment.bin>
-------------- next part --------------
From 5cfdadf9104b476cdf4944ae1d0a12dbfae3e63e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Thu, 7 Nov 2019 10:37:13 -0500
Subject: [PATCH] lxd/storage/dir: Don't apply quotas on snapshots
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_dir.go | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/lxd/storage/drivers/driver_dir.go b/lxd/storage/drivers/driver_dir.go
index fdb9507217..d9395933bc 100644
--- a/lxd/storage/drivers/driver_dir.go
+++ b/lxd/storage/drivers/driver_dir.go
@@ -767,19 +767,13 @@ func (d *dir) deleteQuota(path string, volID int64) error {
 
 // CreateVolumeSnapshot creates a snapshot of a volume.
 func (d *dir) CreateVolumeSnapshot(volType VolumeType, volName string, newSnapshotName string, op *operations.Operation) error {
-	// Get the volume ID for the parent volume, which is used to set project quota on snapshot.
-	volID, err := d.getVolID(volType, volName)
-	if err != nil {
-		return err
-	}
-
 	srcPath := GetVolumeMountPath(d.name, volType, volName)
 	fullSnapName := GetSnapshotVolumeName(volName, newSnapshotName)
 	snapVol := NewVolume(d, d.name, volType, ContentTypeFS, fullSnapName, nil)
 	snapPath := snapVol.MountPath()
 
 	// Create snapshot directory.
-	err = snapVol.CreateMountPath()
+	err := snapVol.CreateMountPath()
 	if err != nil {
 		return err
 	}
@@ -787,17 +781,10 @@ func (d *dir) CreateVolumeSnapshot(volType VolumeType, volName string, newSnapsh
 	revertPath := true
 	defer func() {
 		if revertPath {
-			d.deleteQuota(snapPath, volID)
 			os.RemoveAll(snapPath)
 		}
 	}()
 
-	// Initialise the snapshot's quota with the parent volume's ID.
-	err = d.initQuota(snapPath, volID)
-	if err != nil {
-		return err
-	}
-
 	bwlimit := d.config["rsync.bwlimit"]
 
 	// Copy volume into snapshot directory.
@@ -813,22 +800,10 @@ func (d *dir) CreateVolumeSnapshot(volType VolumeType, volName string, newSnapsh
 // DeleteVolumeSnapshot removes a snapshot from the storage device. The volName and snapshotName
 // must be bare names and should not be in the format "volume/snapshot".
 func (d *dir) DeleteVolumeSnapshot(volType VolumeType, volName string, snapshotName string, op *operations.Operation) error {
-	// Get the volume ID for the parent volume, which is used to remove project quota.
-	volID, err := d.getVolID(volType, volName)
-	if err != nil {
-		return err
-	}
-
 	snapPath := GetVolumeMountPath(d.name, volType, GetSnapshotVolumeName(volName, snapshotName))
 
-	// Remove the project quota.
-	err = d.deleteQuota(snapPath, volID)
-	if err != nil {
-		return err
-	}
-
 	// Remove the snapshot from the storage device.
-	err = os.RemoveAll(snapPath)
+	err := os.RemoveAll(snapPath)
 	if err != nil {
 		return err
 	}


More information about the lxc-devel mailing list