diff mbox series

[LEDE-DEV,mountd,1/2] mount: try lazy unmount if normal one fails

Message ID 20180221123217.28211-1-zajec5@gmail.com
State Accepted
Headers show
Series [LEDE-DEV,mountd,1/2] mount: try lazy unmount if normal one fails | expand

Commit Message

Rafał Miłecki Feb. 21, 2018, 12:32 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

If umount calls fails (e.g. because of some application accessing old
path) the only chance of getting mount entry cleaned is receiving autofs
expire packet. This isn't fully reliable:
1) Sometimes expire can happen before closing all handles. In such case
   a second unmount try will fail as well and there won't be a next one.
2) Expire happens after specified timeout. If device reappears quickly
   (e.g. due to being replugged or USB controller restart) it may be
   worth having old mount cleaned up earlier for better user experience.

This problem can be easily handled by using MNT_DETACH (lazy) umount as
a fallback.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 mount.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/mount.c b/mount.c
index ddcd5b3..3994149 100644
--- a/mount.c
+++ b/mount.c
@@ -604,6 +604,7 @@  static int mount_dev_del(struct mount *mount)
 		log_printf("device %s has disappeared ... unmounting %s\n", mount->dev, tmp);
 		if (umount(tmp)) {
 			err = -errno;
+			umount2(tmp, MNT_DETACH);
 		}
 		rmdir(tmp);
 		mount_dump_uci_state();