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

Rafał Miłecki zajec5 at gmail.com
Wed Feb 21 04:32:16 PST 2018


From: Rafał Miłecki <rafal at 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 at milecki.pl>
---
 mount.c | 1 +
 1 file changed, 1 insertion(+)

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();
-- 
2.11.0




More information about the Lede-dev mailing list