[lxc-devel] [lxd/master] lxd/storage/quota/projectquota: Only set quota on directories and regular files
tomponline on Github
lxc-bot at linuxcontainers.org
Fri Jun 12 16:18:01 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 457 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200612/cfe98a75/attachment.bin>
-------------- next part --------------
From 81bd3e6897e9f7759b610cd199ad08a69cd728c5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 12 Jun 2020 17:16:13 +0100
Subject: [PATCH] lxd/storage/quota/projectquota: Only set quota on directories
and regular files
Trying to set/remove quota on a pipe file causes a hang at the ioctl C level.
Fixes #7516
Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
lxd/storage/quota/projectquota.go | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/lxd/storage/quota/projectquota.go b/lxd/storage/quota/projectquota.go
index 5810833d45..541b49c5d0 100644
--- a/lxd/storage/quota/projectquota.go
+++ b/lxd/storage/quota/projectquota.go
@@ -241,9 +241,13 @@ func SetProject(path string, id uint32) error {
}
inherit := false
-
if info.IsDir() {
inherit = true // Only can set FS_XFLAG_PROJINHERIT on directories.
+ } else if !info.Mode().IsRegular() {
+ // Cannot set project ID cannot be set on non-regular files after file creation. Infact
+ // trying to set project ID on some file types just blocks forever (such as pipe files).
+ // So skip them as they don't take up disk space anyway.
+ return nil
}
// Call ioctl through CGo.
@@ -251,16 +255,6 @@ func SetProject(path string, id uint32) error {
defer C.free(unsafe.Pointer(cPath))
if C.quota_set_path(cPath, C.uint32_t(id), C.bool(inherit)) != 0 {
- // Currently project ID cannot be set on non-regular files after file creation.
- // However if the parent directory has a project and the inherit flag set on it then
- // non-regular files do get accounted for under the parent's project, so we do still try
- // and set the post-create project on non-regular files in case at some point in the future
- // this inconsistency in behavior is fixed. However because it doesn't work today we will
- // ignore any errors setting project on non-regular files.
- if !info.Mode().IsRegular() {
- return nil
- }
-
return fmt.Errorf(`Failed to set project ID "%d" on %q (inherit %t)`, id, filePath, inherit)
}
More information about the lxc-devel
mailing list