From cbd3892d2810295b9cc24feb7fdfa0b4e0050f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 16 Feb 2024 16:18:52 -0500 Subject: [PATCH 1/2] incusd/storage: Create rootfs dir on empty instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- internal/server/storage/backend.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/server/storage/backend.go b/internal/server/storage/backend.go index b0e12d9a498..0a59a9799c3 100644 --- a/internal/server/storage/backend.go +++ b/internal/server/storage/backend.go @@ -687,7 +687,22 @@ func (b *backend) CreateInstance(inst instance.Instance, op *operations.Operatio return err } - err = b.driver.CreateVolume(vol, nil, op) + var filler *drivers.VolumeFiller + if inst.Type() == instancetype.Container { + filler = &drivers.VolumeFiller{ + Fill: func(vol drivers.Volume, rootBlockPath string, allowUnsafeResize bool) (int64, error) { + // Create an empty rootfs. + err := os.Mkdir(filepath.Join(vol.MountPath(), "rootfs"), 0755) + if err != nil && !os.IsExist(err) { + return 0, err + } + + return 0, nil + }, + } + } + + err = b.driver.CreateVolume(vol, filler, op) if err != nil { return err } From 3f253a143d73961dd5acc076bcca780701c66b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Fri, 16 Feb 2024 17:14:10 -0500 Subject: [PATCH 2/2] incusd/storage/quota: Don't fail on missing project MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases the deletion of all files within the project is enough to cause it to disappear on its own, when that happens, don't fail trying to delete it. Signed-off-by: Stéphane Graber --- internal/server/storage/quota/projectquota.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/server/storage/quota/projectquota.go b/internal/server/storage/quota/projectquota.go index 901f7880a33..f1e997fe660 100644 --- a/internal/server/storage/quota/projectquota.go +++ b/internal/server/storage/quota/projectquota.go @@ -12,6 +12,7 @@ package quota #include #include #include +#include #ifndef FS_XFLAG_PROJINHERIT struct fsxattr { @@ -80,6 +81,9 @@ int quota_set(char *dev_path, uint32_t id, uint64_t hard_bytes) { fs_disk_quota_t xfsquota; if (quotactl(QCMD(Q_GETQUOTA, PRJQUOTA), dev_path, id, (caddr_t)"a) < 0) { + if (hard_bytes == 0 && errno == ENOENT) + return 0; + return -1; }