Richard W.M. Jones
2015-Jul-23 16:30 UTC
[Libguestfs] [PATCH] daemon: umount-all: Give a "second chance" for temporary umount failures (RHBZ#1246032).
When unmounting all filesystems, it appears that large amounts of writes in flight + very slow storage may cause the umount command to fail temporarily. Even the briefest of pauses appears to let the umount succeed. In this patch, call umount as normal, but if it fails, wait a few seconds then call it again (if it fails a second time, we report the error and fail the operation). I considered using 'umount -l' instead, but that is unsafe since when using umount-all we usually want the filesystem to be unmounted and synchronized properly by the time umount-all returns. --- daemon/mount.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/daemon/mount.c b/daemon/mount.c index c5b7d89..a076305 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -419,13 +419,20 @@ do_umount_all (void) /* Unmount them. */ for (i = 0; i < mounts.size; ++i) { - CLEANUP_FREE char *err = NULL; - - r = command (NULL, &err, str_umount, mounts.argv[i], NULL); + /* To avoid problems caused by temporary failures, such as a udev + * operation still completing, allow a second chance for each umount. + */ + r = command (NULL, NULL, str_umount, mounts.argv[i], NULL); if (r == -1) { - reply_with_error ("umount: %s: %s", mounts.argv[i], err); - free_stringslen (mounts.argv, mounts.size); - return -1; + CLEANUP_FREE char *err = NULL; + + sleep (5); + r = command (NULL, &err, str_umount, mounts.argv[i], NULL); + if (r == -1) { + reply_with_error ("umount: %s: %s", mounts.argv[i], err); + free_stringslen (mounts.argv, mounts.size); + return -1; + } } } -- 2.4.3
Richard W.M. Jones
2015-Jul-23 16:37 UTC
Re: [Libguestfs] [PATCH] daemon: umount-all: Give a "second chance" for temporary umount failures (RHBZ#1246032).
Hmm, this patch doesn't work. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Reasonably Related Threads
- [PATCH] daemon: Run lsof when an umount command fails in umount_all call.
- Re: [PATCH] daemon: Run lsof when an umount command fails in umount_all call.
- Re: [PATCH] daemon: Run lsof when an umount command fails in umount_all call.
- [PATCH 2/2] daemon: fix cleanup of stringsbuf usages
- [PATCH v3 01/11] daemon: btrfs: add helper functions mount and umount