Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp58035ybh; Fri, 13 Mar 2020 17:00:40 -0700 (PDT) X-Google-Smtp-Source: ADFU+vseku2R1QWqtoInsVQWV1PRwRWJH9FLTaQsWIdP4VEeh3l8O7u3IR9Y8t2Ph7Af8042gpX8 X-Received: by 2002:a05:6830:14cd:: with SMTP id t13mr1120534otq.357.1584144040441; Fri, 13 Mar 2020 17:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584144040; cv=none; d=google.com; s=arc-20160816; b=LSLCCUmLdJdhsQLB5koaKGotDTz1zlo1rGDw8oPwweBOaOLV9OuyhW//DJPFdwmp2q 3zfOMlL1VFJTJHzjL5/C8IY+YRsiAPhUUaUVnWcA7ne4NZft3/F/bVPOkf41I0tI0FrD oU/0uDSL1bIUQcoS/SCtrlnCjuGoGOu3frciggaPY81uzMAPQkmNIWz+5MLqk3jCl+Z2 wEYTR8wyL3GiJjYsKF//qZbvmSVufkJPGOJ81NfAjD2w82nEvUyKJvFQXvPfVL+k8XbY VhM/Li/9O8oJhrGgUNSc+M+DHO2ue8lDjurONL8ApZTV93KpwdwggCp2t/50V6Dt5nFK qhow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=388vHCQCjDWQMP3asfUMZ56y/tkrK9jDjFUSnPTMoR8=; b=HvTFqhxhjPtsdwYfiVaX/EE1oObzXinlyea/wl8MJcpadSg8KGOPUArzcdSmk9hsIO Wqitr7mn5ys8r6XKpauX+1ldvvL5EavMxCht/XCJ7f8qyT4EKbLnTjnybDfLLnub8c0l Rb5IcmKX9/foISBu7T/t2kDeCQxochoSDTq2EjGxUSZU2knp8HfWwWAYBvcwAhmZ3jel JiBuwGmh7OG7qX/2xYGfICMBf8qAcjZXtrupFiQvcBQU9RlKJMaJUgDmBrIqktpxUO2A FQGr6JVfj/yD3rasLx9Q1FkwviTicGSWSf+hFCuwX+A5OUNgLjTPrMCrXD1YMJQ0k3aC qGQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k28si3340976otb.94.2020.03.13.17.00.26; Fri, 13 Mar 2020 17:00:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727693AbgCMXx7 (ORCPT + 99 others); Fri, 13 Mar 2020 19:53:59 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:49954 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727669AbgCMXx6 (ORCPT ); Fri, 13 Mar 2020 19:53:58 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jCu7p-00B6YQ-HO; Fri, 13 Mar 2020 23:53:57 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds Subject: [RFC][PATCH v4 03/69] follow_automount(): get rid of dead^Wstillborn code Date: Fri, 13 Mar 2020 23:52:51 +0000 Message-Id: <20200313235357.2646756-3-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> References: <20200313235303.GP23230@ZenIV.linux.org.uk> <20200313235357.2646756-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro 1) no instances of ->d_automount() have ever made use of the "return ERR_PTR(-EISDIR) if you don't feel like mounting anything" - that's a rudiment of plans that got superseded before the thing went into the tree. Despite the comment in follow_automount(), autofs has never done that. 2) if there's no ->d_automount() in dentry_operations, filesystems should not set DCACHE_NEED_AUTOMOUNT in the first place. None have ever done so... Signed-off-by: Al Viro --- fs/namei.c | 28 +++------------------------- fs/namespace.c | 9 ++++++++- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 626eddb33508..39dd56f5171f 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1210,10 +1210,7 @@ EXPORT_SYMBOL(follow_up); */ static int follow_automount(struct path *path, struct nameidata *nd) { - struct vfsmount *mnt; - - if (!path->dentry->d_op || !path->dentry->d_op->d_automount) - return -EREMOTE; + struct dentry *dentry = path->dentry; /* We don't want to mount if someone's just doing a stat - * unless they're stat'ing a directory and appended a '/' to @@ -1228,33 +1225,14 @@ static int follow_automount(struct path *path, struct nameidata *nd) */ if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY | LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) && - path->dentry->d_inode) + dentry->d_inode) return -EISDIR; nd->total_link_count++; if (nd->total_link_count >= 40) return -ELOOP; - mnt = path->dentry->d_op->d_automount(path); - if (IS_ERR(mnt)) { - /* - * The filesystem is allowed to return -EISDIR here to indicate - * it doesn't want to automount. For instance, autofs would do - * this so that its userspace daemon can mount on this dentry. - * - * However, we can only permit this if it's a terminal point in - * the path being looked up; if it wasn't then the remainder of - * the path is inaccessible and we should say so. - */ - if (PTR_ERR(mnt) == -EISDIR && (nd->flags & LOOKUP_PARENT)) - return -EREMOTE; - return PTR_ERR(mnt); - } - - if (!mnt) - return 0; - - return finish_automount(mnt, path); + return finish_automount(dentry->d_op->d_automount(path), path); } /* diff --git a/fs/namespace.c b/fs/namespace.c index 777c3116e62e..743980380a8f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2824,9 +2824,16 @@ static int do_new_mount(struct path *path, const char *fstype, int sb_flags, int finish_automount(struct vfsmount *m, struct path *path) { struct dentry *dentry = path->dentry; - struct mount *mnt = real_mount(m); struct mountpoint *mp; + struct mount *mnt; int err; + + if (!m) + return 0; + if (IS_ERR(m)) + return PTR_ERR(m); + + mnt = real_mount(m); /* The new mount record should have at least 2 refs to prevent it being * expired before we get a chance to add it */ -- 2.11.0