The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7527

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
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.parr...@canonical.com>
From 81bd3e6897e9f7759b610cd199ad08a69cd728c5 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parr...@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.parr...@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)
                }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to