From patchwork Thu Nov 9 07:20:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 10050351 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 01460601EA for ; Thu, 9 Nov 2017 07:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8FF62A7F5 for ; Thu, 9 Nov 2017 07:51:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD4B92AB2C; Thu, 9 Nov 2017 07:51:54 +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 autolearn=unavailable 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 76A0D2A7F5 for ; Thu, 9 Nov 2017 07:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753120AbdKIHvF (ORCPT ); Thu, 9 Nov 2017 02:51:05 -0500 Received: from mx2.suse.de ([195.135.220.15]:49058 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085AbdKIHvD (ORCPT ); Thu, 9 Nov 2017 02:51:03 -0500 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 mx2.suse.de (Postfix) with ESMTP id 740D5AC5F; Thu, 9 Nov 2017 07:51:01 +0000 (UTC) From: NeilBrown To: Ian Kent , Latchesar Ionkov , Jeff Layton , Eric Van Hensbergen , Al Viro , Ron Minnich , Trond Myklebust Date: Thu, 09 Nov 2017 18:20:24 +1100 Subject: [PATCH 2/3] VFS: remove user_path_mountpoint_at() Cc: linux-nfs@vger.kernel.org, autofs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, v9fs-developer@lists.sourceforge.net, Linus Torvalds Message-ID: <151021202424.22743.15152208623289288317.stgit@noble> In-Reply-To: <151021179901.22743.15252956909042161062.stgit@noble> References: <151021179901.22743.15252956909042161062.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that d_weak_revalidate doesn't revalidate the inode (unless LOOKUP_OPEN is set), we don't need any extra care when umounting. A simple user_path_at() will find the desired dentry without performing any access on the mounted filesystems. So we don't need user_path_mountpoint_at(). By switching to user_path_at(), there are other changes than just the d_weak_revalidate() change. - We no longer use LOOKUP_NO_REVAL on the last component, in the unlikely case that d_lookup() failed. It is hard to see why this is relevant. Most likely if d_lookup() failed we will have called i_op->lookup, which is at least as much of a problem as d_revalidate() might be. - we now call follow_managed() on the final dentry. This cannot trigger an automount, due to the flags used, but might call ->d_manage(). There is no reason to expect that this might cause problems. So we can safely switch to user_path_at() and discard user_path_mountpoint_at(). kern_path_mountpoint() is still in use by autofs, and so cannot go just yet. Signed-off-by: NeilBrown --- fs/internal.h | 1 - fs/namei.c | 21 --------------------- fs/namespace.c | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index 48cee21b4f14..d1228af28761 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -52,7 +52,6 @@ extern void __init chrdev_init(void); /* * namei.c */ -extern int user_path_mountpoint_at(int, const char __user *, unsigned int, struct path *); extern int vfs_path_lookup(struct dentry *, struct vfsmount *, const char *, unsigned int, struct path *); diff --git a/fs/namei.c b/fs/namei.c index ed8b9488a890..6639203d7eba 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2722,27 +2722,6 @@ filename_mountpoint(int dfd, struct filename *name, struct path *path, return error; } -/** - * user_path_mountpoint_at - lookup a path from userland in order to umount it - * @dfd: directory file descriptor - * @name: pathname from userland - * @flags: lookup flags - * @path: pointer to container to hold result - * - * A umount is a special case for path walking. We're not actually interested - * in the inode in this situation, and ESTALE errors can be a problem. We - * simply want track down the dentry and vfsmount attached at the mountpoint - * and avoid revalidating the last component. - * - * Returns 0 and populates "path" on success. - */ -int -user_path_mountpoint_at(int dfd, const char __user *name, unsigned int flags, - struct path *path) -{ - return filename_mountpoint(dfd, getname(name), path, flags); -} - int kern_path_mountpoint(int dfd, const char *name, struct path *path, unsigned int flags) diff --git a/fs/namespace.c b/fs/namespace.c index 23cdf6c62895..6de22f658359 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1696,7 +1696,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) if (!(flags & UMOUNT_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; - retval = user_path_mountpoint_at(AT_FDCWD, name, lookup_flags, &path); + retval = user_path_at(AT_FDCWD, name, lookup_flags, &path); if (retval) goto out; mnt = real_mount(path.mnt);