Linux NFS development
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] VFS: lookup path of "-o remount" the same way as "umount"
Date: Thu, 10 Aug 2017 16:30:36 +1000	[thread overview]
Message-ID: <87shh0q6ib.fsf@notabene.neil.brown.name> (raw)

[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]


"mount -o remount" does not need to validate the target directory
for the same reasons that "umount" doesn't.  It just needs to
find the mountpoint and verify it is a mountpount.

So change do_mount() to use user_path_mountpoint_at() in the
MS_REMOUNT case.

This means that mount(.., MS_REMOUNT|MS_RO, ..) on a network
attached filesystem will only access the network if there
is data to be written out.  This reduces the chance of a hang
when the network is down.

Systemd-shutdown currently calls
   mount(NULL, path, NULL, MS_REMOUNT|MS_RDONLY, ...);
   umount2(path, 0);

which is not unreasonable for local filesystems which may still
be in use, but causes a hang for NFS filesystems which have not
been unmounted.

Note that this change does not affect
   /usr/bin/mount -o remount,ro ...
as that currently calls "lstat()" on the mount point.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 fs/namespace.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index f8893dc6a989..31ded3a1cdff 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2718,7 +2718,10 @@ long do_mount(const char *dev_name, const char __user *dir_name,
 		((char *)data_page)[PAGE_SIZE - 1] = 0;
 
 	/* ... and get the mountpoint */
-	retval = user_path(dir_name, &path);
+	if (flags & MS_REMOUNT)
+		retval = user_path_mountpoint_at(AT_FDCWD, dir_name, 0, &path);
+	else
+		retval = user_path(dir_name, &path);
 	if (retval)
 		return retval;
 
-- 
2.12.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

                 reply	other threads:[~2017-08-10  6:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shh0q6ib.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox