Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6149520pxv; Thu, 29 Jul 2021 07:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+X8kCRAsYJv3lXQUg6oVa9tv5YPCzqbvFjsxzJXCaIlF2bN67D5YUpbIuxi1Myoxpaw5Q X-Received: by 2002:a5e:d508:: with SMTP id e8mr4499422iom.101.1627569528217; Thu, 29 Jul 2021 07:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627569528; cv=none; d=google.com; s=arc-20160816; b=AGz8Jpvdm6Lylig2hsfZOddx9mn5FBZlivFsOXrhb55tXYId8/X+aG/EJYg666k8TL D9e8VdvhV6caMQdsdxSX22oD8Cc9eefWgAUuBNaaPYS5rlXyUhQqBuBfh2BW8bblITN7 oQCF7goXgrqC6t9YQ41ZyfGWreL8ntBj0QKozmiZq8ZScONTqQrKI74tMKO+fXVx+yQt akuh75nq7TXBSKevO9KCTj9Z44D8xADl5wyHcFEGoHvT1+PnAEF47DwvA0GcaRFuHXpN d9bfEHqXJxufh7jd1mshYxUQsNIogncL2w4SEd40686b+4TLhjCve51A3n8mBlihrPlo 5Z6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=0nHdxYHt7zhPDzyqsudMa1TiYCislvf6e3OBj2xOqUw=; b=rh4GS94n+AOA3DWMxbLMsihQcdLWLruSO2HVFzZIB7e7/mLyjB21LuY+d2HkRa0r8w iyzhmNyMeoxfwAW15B3WCGH956GQ87HYYe0hR6/i4rFw5qgbj7du6mHeReZWPKYg/gIu OH7pHCsYw8FsyswAb+s8kd1KdvvKZc6EfucMCOLr9m99qRVIidy+QeJeHXIv3Kg0o+eW 6aSN/o5DMQDnrn4dk3mpnesCPFVssxUTiAQybtUlkCegQmBp+II+NbgAVu8Seq4zQOVH JRsV0Wpfhdz0+pugbHbIinsPBON4bun9zwM49QPLV3WfFFWwvSRwCAewHu8u/1VsM6Ln wCZw== ARC-Authentication-Results: i=1; mx.google.com; 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 d12si4109994ilg.4.2021.07.29.07.38.25; Thu, 29 Jul 2021 07:38:48 -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; 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 S236945AbhG2OiL (ORCPT + 99 others); Thu, 29 Jul 2021 10:38:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:43778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237035AbhG2OiK (ORCPT ); Thu, 29 Jul 2021 10:38:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E8B6A60FD7; Thu, 29 Jul 2021 14:38:03 +0000 (UTC) Date: Thu, 29 Jul 2021 16:38:01 +0200 From: Christian Brauner To: NeilBrown Cc: Christoph Hellwig , Josef Bacik , "J. Bruce Fields" , Chuck Lever , Chris Mason , David Sterba , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: Re: [PATCH 11/11] btrfs: use automount to bind-mount all subvol roots. Message-ID: <20210729143801.k2zq7qm3pm2h4wzx@wittgenstein> References: <162742539595.32498.13687924366155737575.stgit@noble.brown> <162742546558.32498.1901201501617899416.stgit@noble.brown> <20210728131213.pgu3r4m4ulozrcav@wittgenstein> <162751940386.21659.17682627731630829061@noble.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <162751940386.21659.17682627731630829061@noble.neil.brown.name> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Jul 29, 2021 at 10:43:23AM +1000, NeilBrown wrote: > On Wed, 28 Jul 2021, Christian Brauner wrote: > > > > Hey Neil, > > > > Sorry if this is a stupid question but wouldn't you want to copy the > > mount properties from path->mnt here? Couldn't you otherwise use this to > > e.g. suddenly expose a dentry on a read-only mount as read-write? > > There are no stupid questions, and this is a particularly non-stupid > one! > > I hadn't considered that, but having examined the code I see that it > is already handled. > The vfsmount that d_automount returns is passed to finish_automount(), > which hands it to do_add_mount() together with the mnt_flags for the > parent vfsmount (plus MNT_SHRINKABLE). > do_add_mount() sets up the mnt_flags of the new vfsmount. > In fact, the d_automount interface has no control of these flags at all. > Whatever it sets will be over-written by do_add_mount. Ah, interesting thank you very much, Neil. I seemed to have overlooked this yesterday. If btrfs makes use of automounts the way you envisioned to expose subvolumes and also will support idmapped mounts (see [1]) we need to teach do_add_mount() to also take the idmapped mount into account. So you'd need something like (entirely untested): diff --git a/fs/namespace.c b/fs/namespace.c index ab4174a3c802..921f6396c36d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2811,6 +2811,11 @@ static int do_add_mount(struct mount *newmnt, struct mountpoint *mp, return -EINVAL; newmnt->mnt.mnt_flags = mnt_flags; + + newmnt->mnt.mnt_userns = path->mnt; + if (newmnt->mnt.mnt_userns != &init_user_ns) + newmnt->mnt.mnt_userns = get_user_ns(newmnt->mnt.mnt_userns); + return graft_tree(newmnt, parent, mp); } [1]: https://lore.kernel.org/linux-btrfs/20210727104900.829215-1-brauner@kernel.org/T/#mca601363b435e81c89d8ca4f09134faa5c227e6d