forked from pool/docker
5fb98d193e
- Add patch to update golang.org/x/crypto for CVE-2021-43565 and CVE-2022-27191. bsc#1193930 bsc#1197284 * 0006-bsc1193930-vendor-update-golang.org-x-crypto.patch - Rebase patches: * 0001-SECRETS-daemon-allow-directory-creation-in-run-secre.patch * 0002-SECRETS-SUSE-implement-SUSE-container-secrets.patch * 0003-PRIVATE-REGISTRY-add-private-registry-mirror-support.patch * 0004-bsc1073877-apparmor-clobber-docker-default-profile-o.patch * 0005-bsc1183855-btrfs-Do-not-disable-quota-on-cleanup.patch OBS-URL: https://build.opensuse.org/request/show/973797 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=369
145 lines
4.7 KiB
Diff
145 lines
4.7 KiB
Diff
From 98822d2010c709e64d5e86d7ec8e054861080a53 Mon Sep 17 00:00:00 2001
|
|
From: Michal Rostecki <mrostecki@opensuse.org>
|
|
Date: Thu, 8 Apr 2021 14:42:02 +0100
|
|
Subject: [PATCH 5/6] bsc1183855: btrfs: Do not disable quota on cleanup
|
|
|
|
Before this change, cleanup of the btrfs driver (occuring on each daemon
|
|
shutdown) resulted in disabling quotas. It was done with an assumption
|
|
that quotas can be enabled or disabled on a subvolume level, which is
|
|
not true - enabling or disabling quota is always done on a filesystem
|
|
level.
|
|
|
|
That was leading to disabling quota on btrfs filesystems on each daemon
|
|
shutdown.
|
|
|
|
This change fixes that behavior and removes misleading `subvol` prefix
|
|
from functions and methods which set up quota (on a filesystem level).
|
|
|
|
SUSE-Bugs: bsc#1175081 bsc#1183855
|
|
SUSE-Upstream-Commit: 1ec689c4c2ecda24ed8495451c53072bb0497871
|
|
Fixes: 401c8d176743 ("Add disk quota support for btrfs")
|
|
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
|
|
---
|
|
daemon/graphdriver/btrfs/btrfs.go | 50 +++++--------------------------
|
|
1 file changed, 8 insertions(+), 42 deletions(-)
|
|
|
|
diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go
|
|
index 8fd2854a2673..32c4f07c620d 100644
|
|
--- a/daemon/graphdriver/btrfs/btrfs.go
|
|
+++ b/daemon/graphdriver/btrfs/btrfs.go
|
|
@@ -103,7 +103,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap
|
|
}
|
|
|
|
if userDiskQuota {
|
|
- if err := driver.subvolEnableQuota(); err != nil {
|
|
+ if err := driver.enableQuota(); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
@@ -172,18 +172,10 @@ func (d *Driver) GetMetadata(id string) (map[string]string, error) {
|
|
|
|
// Cleanup unmounts the home directory.
|
|
func (d *Driver) Cleanup() error {
|
|
- err := d.subvolDisableQuota()
|
|
- umountErr := mount.Unmount(d.home)
|
|
-
|
|
- // in case we have two errors, prefer the one from disableQuota()
|
|
- if err != nil {
|
|
+ if err := mount.Unmount(d.home); err != nil {
|
|
return err
|
|
}
|
|
|
|
- if umountErr != nil {
|
|
- return umountErr
|
|
- }
|
|
-
|
|
return nil
|
|
}
|
|
|
|
@@ -341,7 +333,7 @@ func (d *Driver) updateQuotaStatus() {
|
|
d.once.Do(func() {
|
|
if !d.quotaEnabled {
|
|
// In case quotaEnabled is not set, check qgroup and update quotaEnabled as needed
|
|
- if err := subvolQgroupStatus(d.home); err != nil {
|
|
+ if err := qgroupStatus(d.home); err != nil {
|
|
// quota is still not enabled
|
|
return
|
|
}
|
|
@@ -350,7 +342,7 @@ func (d *Driver) updateQuotaStatus() {
|
|
})
|
|
}
|
|
|
|
-func (d *Driver) subvolEnableQuota() error {
|
|
+func (d *Driver) enableQuota() error {
|
|
d.updateQuotaStatus()
|
|
|
|
if d.quotaEnabled {
|
|
@@ -376,32 +368,6 @@ func (d *Driver) subvolEnableQuota() error {
|
|
return nil
|
|
}
|
|
|
|
-func (d *Driver) subvolDisableQuota() error {
|
|
- d.updateQuotaStatus()
|
|
-
|
|
- if !d.quotaEnabled {
|
|
- return nil
|
|
- }
|
|
-
|
|
- dir, err := openDir(d.home)
|
|
- if err != nil {
|
|
- return err
|
|
- }
|
|
- defer closeDir(dir)
|
|
-
|
|
- var args C.struct_btrfs_ioctl_quota_ctl_args
|
|
- args.cmd = C.BTRFS_QUOTA_CTL_DISABLE
|
|
- _, _, errno := unix.Syscall(unix.SYS_IOCTL, getDirFd(dir), C.BTRFS_IOC_QUOTA_CTL,
|
|
- uintptr(unsafe.Pointer(&args)))
|
|
- if errno != 0 {
|
|
- return fmt.Errorf("Failed to disable btrfs quota for %s: %v", dir, errno.Error())
|
|
- }
|
|
-
|
|
- d.quotaEnabled = false
|
|
-
|
|
- return nil
|
|
-}
|
|
-
|
|
func (d *Driver) subvolRescanQuota() error {
|
|
d.updateQuotaStatus()
|
|
|
|
@@ -444,11 +410,11 @@ func subvolLimitQgroup(path string, size uint64) error {
|
|
return nil
|
|
}
|
|
|
|
-// subvolQgroupStatus performs a BTRFS_IOC_TREE_SEARCH on the root path
|
|
+// qgroupStatus performs a BTRFS_IOC_TREE_SEARCH on the root path
|
|
// with search key of BTRFS_QGROUP_STATUS_KEY.
|
|
// In case qgroup is enabled, the retuned key type will match BTRFS_QGROUP_STATUS_KEY.
|
|
// For more details please see https://github.com/kdave/btrfs-progs/blob/v4.9/qgroup.c#L1035
|
|
-func subvolQgroupStatus(path string) error {
|
|
+func qgroupStatus(path string) error {
|
|
dir, err := openDir(path)
|
|
if err != nil {
|
|
return err
|
|
@@ -622,7 +588,7 @@ func (d *Driver) setStorageSize(dir string, driver *Driver) error {
|
|
if d.options.minSpace > 0 && driver.options.size < d.options.minSpace {
|
|
return fmt.Errorf("btrfs: storage size cannot be less than %s", units.HumanSize(float64(d.options.minSpace)))
|
|
}
|
|
- if err := d.subvolEnableQuota(); err != nil {
|
|
+ if err := d.enableQuota(); err != nil {
|
|
return err
|
|
}
|
|
return subvolLimitQgroup(dir, driver.options.size)
|
|
@@ -676,7 +642,7 @@ func (d *Driver) Get(id, mountLabel string) (containerfs.ContainerFS, error) {
|
|
|
|
if quota, err := ioutil.ReadFile(d.quotasDirID(id)); err == nil {
|
|
if size, err := strconv.ParseUint(string(quota), 10, 64); err == nil && size >= d.options.minSpace {
|
|
- if err := d.subvolEnableQuota(); err != nil {
|
|
+ if err := d.enableQuota(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := subvolLimitQgroup(dir, size); err != nil {
|
|
--
|
|
2.35.1
|
|
|