Merge pull request #10047 from vbatts/vbatts-graphdriver_driver_put_with_error

graphdriver: change (*Driver).Put signature
This commit is contained in:
Alexander Morozov 2015-01-12 11:42:11 -08:00
commit 83ab6237ac
6 changed files with 19 additions and 12 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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 {

View file

@ -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

View file

@ -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) {

View file

@ -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 {