diff mbox

[nfs-utils] umount.nfs: assume path name is canonical.

Message ID 8737bfduq8.fsf@notabene.neil.brown.name (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown June 5, 2017, 2:38 a.m. UTC
/usr/bin/umount will always pass a canonical name
to umount.nfs, so it is safe to disable canonicalization.

When umounting an NFS filesystem, it is generally safest to
not "stat" the mountpoint at all as that can block
indefinitely.  umount() will not block, but lstat() etc can.
By disabling canonicalization in libmount, we discourage it
from ever calling 'stat' family operations, and thus reduce
the chance of a hang.

Note that to be fully effective, this requires changes to
util-linux which have not yet been accepted.
When both that change and this are in effect, automounters
can use "umount -c $PATH" to safely unmount a filesystem
without blocking.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 utils/mount/mount_libmount.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Steve Dickson June 13, 2017, 12:40 p.m. UTC | #1
On 06/04/2017 10:38 PM, NeilBrown wrote:
> 
> /usr/bin/umount will always pass a canonical name
> to umount.nfs, so it is safe to disable canonicalization.
> 
> When umounting an NFS filesystem, it is generally safest to
> not "stat" the mountpoint at all as that can block
> indefinitely.  umount() will not block, but lstat() etc can.
> By disabling canonicalization in libmount, we discourage it
> from ever calling 'stat' family operations, and thus reduce
> the chance of a hang.
> 
> Note that to be fully effective, this requires changes to
> util-linux which have not yet been accepted.
> When both that change and this are in effect, automounters
> can use "umount -c $PATH" to safely unmount a filesystem
> without blocking.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>
Committed... 

steved.

> ---
>  utils/mount/mount_libmount.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/utils/mount/mount_libmount.c b/utils/mount/mount_libmount.c
> index 1f01f7f7a4e7..2d4065759a6c 100644
> --- a/utils/mount/mount_libmount.c
> +++ b/utils/mount/mount_libmount.c
> @@ -188,6 +188,7 @@ static int umount_main(struct libmnt_context *cxt, int argc, char **argv)
>  	};
>  
>  	mnt_context_init_helper(cxt, MNT_ACT_UMOUNT, 0);
> +	mnt_context_disable_canonicalize(cxt, 1);
>  
>  	while ((c = getopt_long (argc, argv, "fvnrlh", longopts, NULL)) != -1) {
>  
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/mount/mount_libmount.c b/utils/mount/mount_libmount.c
index 1f01f7f7a4e7..2d4065759a6c 100644
--- a/utils/mount/mount_libmount.c
+++ b/utils/mount/mount_libmount.c
@@ -188,6 +188,7 @@  static int umount_main(struct libmnt_context *cxt, int argc, char **argv)
 	};
 
 	mnt_context_init_helper(cxt, MNT_ACT_UMOUNT, 0);
+	mnt_context_disable_canonicalize(cxt, 1);
 
 	while ((c = getopt_long (argc, argv, "fvnrlh", longopts, NULL)) != -1) {