51 lines
1.6 KiB
Diff
51 lines
1.6 KiB
Diff
|
am-utils-6.2-0.git.9b652fb4 - linux umount wait on ebusy
|
||
|
|
||
|
From: Ian Kent <ikent@redhat.com>
|
||
|
|
||
|
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 782c2cd..81b0527 100644
|
||
|
--- a/conf/umount/umount_linux.c
|
||
|
+++ b/conf/umount/umount_linux.c
|
||
|
@@ -63,6 +63,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);
|
||
|
|
||
|
@@ -94,6 +95,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
|
||
|
@@ -111,6 +113,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)) {
|