From patchwork Thu Aug 10 06:30:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9892787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4989660236 for ; Thu, 10 Aug 2017 06:33:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F6D628ACE for ; Thu, 10 Aug 2017 06:33:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3412328AD1; Thu, 10 Aug 2017 06:33:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9839F28AD1 for ; Thu, 10 Aug 2017 06:33:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751361AbdHJGdE (ORCPT ); Thu, 10 Aug 2017 02:33:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:39964 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750841AbdHJGdE (ORCPT ); Thu, 10 Aug 2017 02:33:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F178DAF63; Thu, 10 Aug 2017 06:33:02 +0000 (UTC) From: NeilBrown To: Al Viro Date: Thu, 10 Aug 2017 16:30:36 +1000 Subject: [PATCH] VFS: lookup path of "-o remount" the same way as "umount" cc: Linux NFS Mailing List , lkml Message-ID: <87shh0q6ib.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "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 --- 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;