Skip to content

Commit

Permalink
lxd/storage/drivers: Remove unnecessary DeleteProject
Browse files Browse the repository at this point in the history
`DeleteProject` unsets the project for the path unnecessarily since the new project will be set afterwards. And that is an expensive operation since it implies another filepath walk. So this just unsets the quota on the project instead.

Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Aug 30, 2024
1 parent ee16591 commit 735f9c1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lxd/storage/drivers/driver_dir_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,15 @@ func (d *dir) setQuota(path string, volID int64, sizeBytes int64) error {

// Clear and create new project if desired project ID is different.
if currentProjectID != d.quotaProjectID(volID) {
err = quota.DeleteProject(path, currentProjectID)
err = quota.SetProject(path, projectID)
if err != nil {
return err
return fmt.Errorf("Failed setting project: %w", err)
}

err = quota.SetProject(path, projectID)
// Unset the quota on the current project.
err = quota.SetProjectQuota(path, currentProjectID, 0)
if err != nil {
return fmt.Errorf("Failed setting project: %w", err)
return err
}
}

Expand Down

0 comments on commit 735f9c1

Please sign in to comment.