Merge pull request #10047 from vbatts/vbatts-graphdriver_driver_put_with_error
graphdriver: change (*Driver).Put signature
This commit is contained in:
commit
83ab6237ac
6 changed files with 19 additions and 12 deletions
|
@ -278,7 +278,7 @@ func (a *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Driver) Put(id string) {
|
func (a *Driver) Put(id string) error {
|
||||||
// Protect the a.active from concurrent access
|
// Protect the a.active from concurrent access
|
||||||
a.Lock()
|
a.Lock()
|
||||||
defer a.Unlock()
|
defer a.Unlock()
|
||||||
|
@ -293,6 +293,7 @@ func (a *Driver) Put(id string) {
|
||||||
}
|
}
|
||||||
delete(a.active, id)
|
delete(a.active, id)
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diff produces an archive of the changes between the specified
|
// Diff produces an archive of the changes between the specified
|
||||||
|
|
|
@ -220,9 +220,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
return dir, nil
|
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)
|
// Get() creates no runtime resources (like e.g. mounts)
|
||||||
// so this doesn't need to do anything.
|
// so this doesn't need to do anything.
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Exists(id string) bool {
|
func (d *Driver) Exists(id string) bool {
|
||||||
|
|
|
@ -141,10 +141,12 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
return rootFs, nil
|
return rootFs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Put(id string) {
|
func (d *Driver) Put(id string) error {
|
||||||
if err := d.DeviceSet.UnmountDevice(id); err != nil {
|
err := d.DeviceSet.UnmountDevice(id)
|
||||||
|
if err != nil {
|
||||||
log.Errorf("Warning: error unmounting device %s: %s", id, err)
|
log.Errorf("Warning: error unmounting device %s: %s", id, err)
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Exists(id string) bool {
|
func (d *Driver) Exists(id string) bool {
|
||||||
|
|
|
@ -40,7 +40,7 @@ type ProtoDriver interface {
|
||||||
Get(id, mountLabel string) (dir string, err error)
|
Get(id, mountLabel string) (dir string, err error)
|
||||||
// Put releases the system resources for the specified id,
|
// Put releases the system resources for the specified id,
|
||||||
// e.g, unmounting layered filesystem.
|
// e.g, unmounting layered filesystem.
|
||||||
Put(id string)
|
Put(id string) error
|
||||||
// Exists returns whether a filesystem layer with the specified
|
// Exists returns whether a filesystem layer with the specified
|
||||||
// ID exists on this driver.
|
// ID exists on this driver.
|
||||||
Exists(id string) bool
|
Exists(id string) bool
|
||||||
|
|
|
@ -299,7 +299,7 @@ func (d *Driver) Get(id string, mountLabel string) (string, error) {
|
||||||
return mount.path, nil
|
return mount.path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Put(id string) {
|
func (d *Driver) Put(id string) error {
|
||||||
// Protect the d.active from concurrent access
|
// Protect the d.active from concurrent access
|
||||||
d.Lock()
|
d.Lock()
|
||||||
defer d.Unlock()
|
defer d.Unlock()
|
||||||
|
@ -307,21 +307,23 @@ func (d *Driver) Put(id string) {
|
||||||
mount := d.active[id]
|
mount := d.active[id]
|
||||||
if mount == nil {
|
if mount == nil {
|
||||||
log.Debugf("Put on a non-mounted device %s", id)
|
log.Debugf("Put on a non-mounted device %s", id)
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mount.count--
|
mount.count--
|
||||||
if mount.count > 0 {
|
if mount.count > 0 {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer delete(d.active, id)
|
||||||
if mount.mounted {
|
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)
|
log.Debugf("Failed to unmount %s overlay: %v", id, err)
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
delete(d.active, id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) ApplyDiff(id string, parent string, diff archive.ArchiveReader) (size int64, err error) {
|
func (d *Driver) ApplyDiff(id string, parent string, diff archive.ArchiveReader) (size int64, err error) {
|
||||||
|
|
|
@ -83,9 +83,10 @@ func (d *Driver) Get(id, mountLabel string) (string, error) {
|
||||||
return dir, nil
|
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)
|
// The vfs driver has no runtime resources (e.g. mounts)
|
||||||
// to clean up, so we don't need anything here
|
// to clean up, so we don't need anything here
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) Exists(id string) bool {
|
func (d *Driver) Exists(id string) bool {
|
||||||
|
|
Loading…
Reference in a new issue