From 00fd63e55807c36fedf0878645dfec995fba381d Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Fri, 9 Jan 2015 17:14:52 -0500 Subject: [PATCH] graphdriver: change (*Driver).Put signature There are a couple of drivers that swallow errors that may occur in their Put() implementation. This changes the signature of (*Driver).Put for all the drivers implemented. Signed-off-by: Vincent Batts --- daemon/graphdriver/aufs/aufs.go | 3 ++- daemon/graphdriver/btrfs/btrfs.go | 3 ++- daemon/graphdriver/devmapper/driver.go | 6 ++++-- daemon/graphdriver/driver.go | 2 +- daemon/graphdriver/overlay/overlay.go | 14 ++++++++------ daemon/graphdriver/vfs/driver.go | 3 ++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 220be2de55..5d08bfc5d9 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -278,7 +278,7 @@ func (a *Driver) Get(id, mountLabel string) (string, error) { return out, nil } -func (a *Driver) Put(id string) { +func (a *Driver) Put(id string) error { // Protect the a.active from concurrent access a.Lock() defer a.Unlock() @@ -293,6 +293,7 @@ func (a *Driver) Put(id string) { } delete(a.active, id) } + return nil } // Diff produces an archive of the changes between the specified diff --git a/daemon/graphdriver/btrfs/btrfs.go b/daemon/graphdriver/btrfs/btrfs.go index a3964b963c..1830ad4e8f 100644 --- a/daemon/graphdriver/btrfs/btrfs.go +++ b/daemon/graphdriver/btrfs/btrfs.go @@ -220,9 +220,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { return dir, nil } -func (d *Driver) Put(id string) { +func (d *Driver) Put(id string) error { // Get() creates no runtime resources (like e.g. mounts) // so this doesn't need to do anything. + return nil } func (d *Driver) Exists(id string) bool { diff --git a/daemon/graphdriver/devmapper/driver.go b/daemon/graphdriver/devmapper/driver.go index 91e9491e30..aa22f0b403 100644 --- a/daemon/graphdriver/devmapper/driver.go +++ b/daemon/graphdriver/devmapper/driver.go @@ -141,10 +141,12 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { return rootFs, nil } -func (d *Driver) Put(id string) { - if err := d.DeviceSet.UnmountDevice(id); err != nil { +func (d *Driver) Put(id string) error { + err := d.DeviceSet.UnmountDevice(id) + if err != nil { log.Errorf("Warning: error unmounting device %s: %s", id, err) } + return err } func (d *Driver) Exists(id string) bool { diff --git a/daemon/graphdriver/driver.go b/daemon/graphdriver/driver.go index 1c06012781..e9b99f394b 100644 --- a/daemon/graphdriver/driver.go +++ b/daemon/graphdriver/driver.go @@ -40,7 +40,7 @@ type ProtoDriver interface { Get(id, mountLabel string) (dir string, err error) // Put releases the system resources for the specified id, // e.g, unmounting layered filesystem. - Put(id string) + Put(id string) error // Exists returns whether a filesystem layer with the specified // ID exists on this driver. Exists(id string) bool diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index c59d0ea8fd..438ff55b4b 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -299,7 +299,7 @@ func (d *Driver) Get(id string, mountLabel string) (string, error) { return mount.path, nil } -func (d *Driver) Put(id string) { +func (d *Driver) Put(id string) error { // Protect the d.active from concurrent access d.Lock() defer d.Unlock() @@ -307,21 +307,23 @@ func (d *Driver) Put(id string) { mount := d.active[id] if mount == nil { log.Debugf("Put on a non-mounted device %s", id) - return + return nil } mount.count-- if mount.count > 0 { - return + return nil } + defer delete(d.active, id) if mount.mounted { - if err := syscall.Unmount(mount.path, 0); err != nil { + err := syscall.Unmount(mount.path, 0) + if err != nil { log.Debugf("Failed to unmount %s overlay: %v", id, err) } + return err } - - delete(d.active, id) + return nil } func (d *Driver) ApplyDiff(id string, parent string, diff archive.ArchiveReader) (size int64, err error) { diff --git a/daemon/graphdriver/vfs/driver.go b/daemon/graphdriver/vfs/driver.go index 0cffb1ffde..fe4d38230e 100644 --- a/daemon/graphdriver/vfs/driver.go +++ b/daemon/graphdriver/vfs/driver.go @@ -83,9 +83,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) { return dir, nil } -func (d *Driver) Put(id string) { +func (d *Driver) Put(id string) error { // The vfs driver has no runtime resources (e.g. mounts) // to clean up, so we don't need anything here + return nil } func (d *Driver) Exists(id string) bool {