From 092e59ef7637e4f4e6ec2d426d21be2267ef4317 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 18 Dec 2017 10:23:49 -0800 Subject: [PATCH 1/2] projectquota: treat ENOSYS as quota unsupported If mknod() returns ENOSYS, it most probably means quota is not supported here, so return the appropriate error. This is a conservative* fix to regression in vfs graph driver introduced by commit 7a1618ced359a3ac92 ("add quota support to VFS graphdriver"). On some filesystems, vfs fails to init with the following error: > Error starting daemon: error initializing graphdriver: Failed to mknod > /go/src/github.com/docker/docker/bundles/test-integration/d6bcf6de610e9/root/vfs/backingFsBlockDev: > function not implemented Reported-by: Brian Goff Signed-off-by: Kir Kolyshkin (cherry picked from commit 2dd39b7841bdb9968884bbedc5db97ff77d4fe3e) Signed-off-by: Sebastiaan van Stijn --- .../engine/daemon/graphdriver/quota/projectquota.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/engine/daemon/graphdriver/quota/projectquota.go b/components/engine/daemon/graphdriver/quota/projectquota.go index e25965baf3..8efe5cd8a1 100644 --- a/components/engine/daemon/graphdriver/quota/projectquota.go +++ b/components/engine/daemon/graphdriver/quota/projectquota.go @@ -350,11 +350,17 @@ func makeBackingFsDev(home string) (string, error) { backingFsBlockDev := path.Join(home, "backingFsBlockDev") // Re-create just in case someone copied the home directory over to a new device unix.Unlink(backingFsBlockDev) - if err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)); err != nil { + err := unix.Mknod(backingFsBlockDev, unix.S_IFBLK|0600, int(stat.Dev)) + switch err { + case nil: + return backingFsBlockDev, nil + + case unix.ENOSYS: + return "", ErrQuotaNotSupported + + default: return "", fmt.Errorf("Failed to mknod %s: %v", backingFsBlockDev, err) } - - return backingFsBlockDev, nil } func hasQuotaSupport(backingFsBlockDev string) (bool, error) { From a7ee159424eafb506a79c8da61b26d25ba5ca174 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 Dec 2017 13:47:12 -0800 Subject: [PATCH 2/2] vfs gd: ignore quota setup errors This is a fix to regression in vfs graph driver introduced by commit 7a1618ced359a3ac92 ("add quota support to VFS graphdriver"). On some filesystems, vfs fails to init with the following error: > Error starting daemon: error initializing graphdriver: Failed to mknod > /go/src/github.com/docker/docker/bundles/test-integration/d6bcf6de610e9/root/vfs/backingFsBlockDev: > function not implemented As quota is not essential for vfs, let's ignore (but log as a warning) any error from quota init. Signed-off-by: Kir Kolyshkin (cherry picked from commit 1e8a087850aa9f96c5000a3ad90757d2e9c0499f) Signed-off-by: Sebastiaan van Stijn --- components/engine/daemon/graphdriver/vfs/driver.go | 4 +--- .../engine/daemon/graphdriver/vfs/quota_linux.go | 11 ++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/engine/daemon/graphdriver/vfs/driver.go b/components/engine/daemon/graphdriver/vfs/driver.go index a85d6a7cf0..5f9cad4aef 100644 --- a/components/engine/daemon/graphdriver/vfs/driver.go +++ b/components/engine/daemon/graphdriver/vfs/driver.go @@ -35,9 +35,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, err } - if err := setupDriverQuota(d); err != nil { - return nil, err - } + setupDriverQuota(d) return graphdriver.NewNaiveDiffDriver(d, uidMaps, gidMaps), nil } diff --git a/components/engine/daemon/graphdriver/vfs/quota_linux.go b/components/engine/daemon/graphdriver/vfs/quota_linux.go index 032c15b9ef..ab8501c774 100644 --- a/components/engine/daemon/graphdriver/vfs/quota_linux.go +++ b/components/engine/daemon/graphdriver/vfs/quota_linux.go @@ -2,20 +2,21 @@ package vfs -import "github.com/docker/docker/daemon/graphdriver/quota" +import ( + "github.com/docker/docker/daemon/graphdriver/quota" + "github.com/sirupsen/logrus" +) type driverQuota struct { quotaCtl *quota.Control } -func setupDriverQuota(driver *Driver) error { +func setupDriverQuota(driver *Driver) { if quotaCtl, err := quota.NewControl(driver.home); err == nil { driver.quotaCtl = quotaCtl } else if err != quota.ErrQuotaNotSupported { - return err + logrus.Warnf("Unable to setup quota: %v\n", err) } - - return nil } func (d *Driver) setupQuota(dir string, size uint64) error {