Browse code

Use lazy umount on Put for overlay2 and overlay

we see a lot of
```
level=debug msg="Failed to unmount a03b1bb6f569421857e5407d73d89451f92724674caa56bfc2170de7e585a00b-init overlay: device or resource busy"
```
in daemon logs and there is a lot of mountpoint leftover.
This cause failed to remove container.

Signed-off-by: Lei Jitang <leijitang@huawei.com>

Lei Jitang authored on 2017/06/12 22:07:25
Showing 2 changed files
... ...
@@ -404,7 +404,7 @@ func (d *Driver) Put(id string) error {
404 404
 	if count := d.ctr.Decrement(mountpoint); count > 0 {
405 405
 		return nil
406 406
 	}
407
-	if err := syscall.Unmount(mountpoint, 0); err != nil {
407
+	if err := syscall.Unmount(mountpoint, syscall.MNT_DETACH); err != nil {
408 408
 		logrus.Debugf("Failed to unmount %s overlay: %v", id, err)
409 409
 	}
410 410
 	return nil
... ...
@@ -587,7 +587,7 @@ func (d *Driver) Put(id string) error {
587 587
 	if count := d.ctr.Decrement(mountpoint); count > 0 {
588 588
 		return nil
589 589
 	}
590
-	if err := syscall.Unmount(mountpoint, 0); err != nil {
590
+	if err := syscall.Unmount(mountpoint, syscall.MNT_DETACH); err != nil {
591 591
 		logrus.Debugf("Failed to unmount %s overlay: %s - %v", id, mountpoint, err)
592 592
 	}
593 593
 	return nil