From 05d70a184e594b6cb53183b318b158d6de7d064a Mon Sep 17 00:00:00 2001 From: zoulasc Date: Thu, 20 Mar 2014 20:54:09 -0400 Subject: [PATCH] From: Ian Kent For some reason, when umounting autofs mounts after closing the ioctl file handle, the kernel can return EBUSY for some small amount of time. This can cause umounts to incorrectly fail when in fact they should succeed. Retrying for about a second and a half seems to work quite well. --- conf/umount/umount_linux.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/conf/umount/umount_linux.c b/conf/umount/umount_linux.c index ea0e4e31..873ecf23 100644 --- a/conf/umount/umount_linux.c +++ b/conf/umount/umount_linux.c @@ -59,6 +59,7 @@ umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) char loopstr[] = "loop="; char *loopdev; #endif /* HAVE_LOOP_DEVICE */ + unsigned int retries = 8; mp = mlist = read_mtab(mntdir, mnttabname); @@ -91,6 +92,7 @@ umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ +again: #if defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_DETACH) /* * If user asked to try forced unmounts, then do a quick check to see if @@ -108,6 +110,14 @@ umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) } else #endif /* defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_DETACH) */ error = UNMOUNT_TRAP(mp_save->mnt); + + /* Linux kernel can be sluggish for some reason */ + if (error == EBUSY && retries--) { + struct timespec tm = {0, 200000000}; + nanosleep(&tm, NULL); + goto again; + } + if (error < 0) { plog(XLOG_WARNING, "unmount(%s) failed: %m", mp_save->mnt->mnt_dir); switch ((error = errno)) { -- 2.34.1