From ee1659105b0c0c6b772128f46004c75a1ee3d677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 28 Aug 2024 23:43:18 -0400 Subject: [PATCH] lxd/storage/drivers: Don't needlessly re-apply project id on quota changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber Reported-by: Marius Klocke (cherry picked from commit 4d4f97804721014a78fefb16d10126ae5556d436) Signed-off-by: hamistao License: Apache-2.0 --- lxd/storage/drivers/driver_dir_utils.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lxd/storage/drivers/driver_dir_utils.go b/lxd/storage/drivers/driver_dir_utils.go index 90242bd3a574..6300990368c2 100644 --- a/lxd/storage/drivers/driver_dir_utils.go +++ b/lxd/storage/drivers/driver_dir_utils.go @@ -118,18 +118,17 @@ func (d *dir) setQuota(path string, volID int64, sizeBytes int64) error { return err } - // Remove current project if desired project ID is different. + // Clear and create new project if desired project ID is different. if currentProjectID != d.quotaProjectID(volID) { err = quota.DeleteProject(path, currentProjectID) if err != nil { return err } - } - // Initialise the project. - err = quota.SetProject(path, projectID) - if err != nil { - return fmt.Errorf("Failed setting project: %w", err) + err = quota.SetProject(path, projectID) + if err != nil { + return fmt.Errorf("Failed setting project: %w", err) + } } // Set the project quota size.