Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4750587pxv; Tue, 27 Jul 2021 15:44:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi498P5s5CaGaFoWEnOegoO5TtJDQD5yx8EFkDFRiZUVpCP5EtDM+rX/0yaQt4XEUVotzO X-Received: by 2002:a92:d451:: with SMTP id r17mr18817329ilm.109.1627425862768; Tue, 27 Jul 2021 15:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627425862; cv=none; d=google.com; s=arc-20160816; b=HPcYSlNsA6JwgCdJvKzAqxz9pHMfgxZ/gURO/qR0trIwmjRaiVSJIlsBjowqg6Nljl pTAtGZnivU8ex01tGhVBZbmf4wNfg77N6egUcF95d4QeJcpCLoT1cfgQkEVeeQf2rJdl 22aPRWZr/a5V6fAwPXMUjNqXjsKZr0UQU8XnPQWhr92arLd/Zi5QQKZZwmYJh+g0ZYMa WRiAw9m1IeCMnCTG8gGW9QywJ59Y/h1a5G92br77S0yMc7aOh9N/zUopJ30qTSTk0rs6 oIyOOUuxhvekMEp5o1W6EKKRMV9QU45ho+fWsWF6lFm3o36+Q5bfOhXVuCivUe/595lE 48Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=xLs00Rrv/kTcj/5olsX73VJ3zYmRNlaU9tOovlvLkrY=; b=QJ1iFLDxWO+jI0VCX1TfM02URR25WH50uuPQFSX+lM5ayYxPk4vXCtNgAbfrdJW71L y1VofRcPIUv5GwLCsN4DXcoOD9zJRWMTuj/2s5EtEhV9gh9et68I0Y3oRYRXFu/ie7TC xv9SOiEVAa2+9IWj+iiTQQCUpRigllzrukSrrN6CKUGv2H3SukCg4xJQOJP7oZu0nNk5 wN73lbc77bqr5yFOSEs3/5NskZV35oH1h+d6EJljgB42BNKC8rFT5nW6W+9BcsWJqOv1 wzZYJOg5b4zLmPb3odgx6etr9KoTKPh8O3xVS5YRlOssLBNSZha4rBOn8vTNpKbJtnoM hfQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CDYrsqvX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v8si4660436jas.68.2021.07.27.15.44.11; Tue, 27 Jul 2021 15:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CDYrsqvX; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233086AbhG0WnO (ORCPT + 99 others); Tue, 27 Jul 2021 18:43:14 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:57146 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbhG0WnN (ORCPT ); Tue, 27 Jul 2021 18:43:13 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2895B21E78; Tue, 27 Jul 2021 22:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627425792; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xLs00Rrv/kTcj/5olsX73VJ3zYmRNlaU9tOovlvLkrY=; b=CDYrsqvXmziG2cY28/a82LbbwXxEKRAV1gNZwQZZjcmIeTklR0CSSUHSCu/Y8kbUonbe78 wjytZURQAFUN9P7NL1uOozNd/XxH68LBZ2xuRkX6yleEp1GBawrGqI4r5Uq4RZmKoos8RD 3E2YzIB7cRdofn5hdWyD0PIc8fkzukw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627425792; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xLs00Rrv/kTcj/5olsX73VJ3zYmRNlaU9tOovlvLkrY=; b=WP2zRKJ88WSgYMmFFXlnfNH3h946jiyNr0bF/6uXF8WrxO9XhcMa7bNsJ2H42E5Iv6mzYx 6eNbxKV9SskOJzDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 22F9C13A5D; Tue, 27 Jul 2021 22:43:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rca3NPyLAGGzVQAAMHmgww (envelope-from ); Tue, 27 Jul 2021 22:43:08 +0000 Subject: [PATCH 05/11] VFS: new function: mount_is_internal() From: NeilBrown To: Christoph Hellwig , Josef Bacik , "J. Bruce Fields" , Chuck Lever , Chris Mason , David Sterba , Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-btrfs@vger.kernel.org Date: Wed, 28 Jul 2021 08:37:45 +1000 Message-ID: <162742546552.32498.14429836898036234922.stgit@noble.brown> In-Reply-To: <162742539595.32498.13687924366155737575.stgit@noble.brown> References: <162742539595.32498.13687924366155737575.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This patch introduces the concept of an "internal" mount which is a mount where a filesystem has create the mount itself. Both the mounted-on-dentry and the mount's root dentry must refer to the same superblock (they may be the same dentry), and the mounted-on dentry must be an automount. Signed-off-by: NeilBrown --- fs/namespace.c | 29 +++++++++++++++++++++++++++++ include/linux/mount.h | 2 ++ 2 files changed, 31 insertions(+) diff --git a/fs/namespace.c b/fs/namespace.c index 73bbdb921e24..a14efbccfb03 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1273,6 +1273,35 @@ bool path_is_mountpoint(const struct path *path) } EXPORT_SYMBOL(path_is_mountpoint); +/** + * mount_is_internal() - Check if path is a mount internal to a single filesystem + * @mnt: vfsmount to check + * + * Some filesystems present multiple file-sets using a single + * superblock, such as btrfs with multiple subvolumes. Names within a + * parent filesystem which lead to a subordinate filesystem are + * implemented as automounts so that the structure is visible in the + * mount table. nfsd needs visibility into this arrangement so that it + * can determine if a mountpoint requires a new export, or is completely + * covered by an existing mount. + * + * An "internal" mount is one where the parent and child have the same + * superblock, and the mounted-on dentry is "managed" as an automount. A + * filehandle found for an inode in the child can be looked-up using either + * vfsmount. + */ +bool mount_is_internal(struct vfsmount *mnt) +{ + struct mount *m = real_mount(mnt); + + if (!mnt_has_parent(m)) + return false; + if (m->mnt_parent->mnt.mnt_sb != m->mnt.mnt_sb) + return false; + return m->mnt_mountpoint->d_flags & DCACHE_NEED_AUTOMOUNT; +} +EXPORT_SYMBOL(mount_is_internal); + struct vfsmount *mnt_clone_internal(const struct path *path) { struct mount *p; diff --git a/include/linux/mount.h b/include/linux/mount.h index 1d3daed88f83..ab58087728ba 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h @@ -118,6 +118,8 @@ extern unsigned int sysctl_mount_max; extern bool path_is_mountpoint(const struct path *path); +extern bool mount_is_internal(struct vfsmount *mnt); + extern struct vfsmount *lookup_mnt(const struct path *); extern void kern_unmount_array(struct vfsmount *mnt[], unsigned int num);