Skip to contentSkip to conversation

VFS: lookup path of "-o remount" the same way as "umount"

PATCH New NeilBrown 1 participant 1 message Aug 10, 2017

Subsystems (3)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 VFS: lookup path of "-o remount" the same way as "umount"

"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.

---
 fs/namespace.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/namespace.c +4 -1
index f8893dc6a989..31ded3a1cdff 100644
@@ -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;
 
Signature · 1 line
2.12.2