Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1237625pxj; Fri, 4 Jun 2021 09:16:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeEfGp8KKy0mRdpJmPNGfn6LQrh3pcQxvCi5/6Ggr33TJyTHROU1xWjbAFIHgOjc7wynxN X-Received: by 2002:a17:906:34d6:: with SMTP id h22mr4104171ejb.413.1622823387313; Fri, 04 Jun 2021 09:16:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622823387; cv=none; d=google.com; s=arc-20160816; b=Ec4n4OGqXFxzPpdbwSzxQRj7y8inC4p1ymYgr/k7X6GMebO1UhBfZ0p6UYEp5PA8C1 PZl/2ycH+h0xeh15TC3r/2tEtGc7qiWKtkXUJ5K8z3WashUrphhyg1IiSkWeIB9/pUgh Dh3Q6X2rCPQWpeJVYtP7eI5p1T0Qy7NzuGjSNTrI9XtGJbUTpXshTSDbt91+FPmfybSh t2VIcy6xbHyfeHuEa67ANUE79rXYH7N1BFFHP9U2YgH/7xfQrfyAy3TviDSvolJQu18O 3WA8QMCmZPA7jbY3HFMslsRRC4122dMzmiRm+L+JmHNvTDYRVIGsQjiuM1WxMifcBr7+ xc0A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pTH2dzqrGsAVLcU22KUkf6wypy8DqQCbhHKeoFudMq8=; b=HsIAAGhr0w7Isax5fpsnlb42uT8fOgdjOU72EDLIBpNj8Aen4h7Af+6pqHTdMpOYVr gSVPwO3ywcHFo2b1mZbx25rh9ASMegdaeWKxolzBrqk81xQ29hkcWsTiWsVyb9jXROeF 211bDKm1eqMsAbScqEDW5p2G95tlCX/CTpbOrlMzes1QP6oa/IM0oFs304Rfe5SvrPsu 4p+3pvq7CbtANcodGPElcdpm2p4hXfQEqltirl+9P6TijIBCxbqljFcvyMdLJQNF5q7J IkfPnWkpvZw34287Zd+tgCl5cHBPtv9IsRbEWLYY6koQiWd3q/EHlVT9Q/Ik+MMmoOA+ dFsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 m2si4837270ejj.215.2021.06.04.09.16.03; Fri, 04 Jun 2021 09:16:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231423AbhFDQOK convert rfc822-to-8bit (ORCPT + 99 others); Fri, 4 Jun 2021 12:14:10 -0400 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:51542 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbhFDQOI (ORCPT ); Fri, 4 Jun 2021 12:14:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-t0Dzju7TPcSRjZqzmv1G4Q-1; Fri, 04 Jun 2021 12:12:18 -0400 X-MC-Unique: t0Dzju7TPcSRjZqzmv1G4Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4E0011007B1A; Fri, 4 Jun 2021 16:12:17 +0000 (UTC) Received: from bahia.lan (ovpn-112-232.ams2.redhat.com [10.36.112.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7DAF648A1; Fri, 4 Jun 2021 16:12:15 +0000 (UTC) From: Greg Kurz To: Miklos Szeredi Cc: linux-kernel@vger.kernel.org, Max Reitz , linux-fsdevel@vger.kernel.org, virtio-fs@redhat.com, Vivek Goyal , Greg Kurz Subject: [PATCH v2 4/7] fuse: Add dedicated filesystem context ops for submounts Date: Fri, 4 Jun 2021 18:11:53 +0200 Message-Id: <20210604161156.408496-5-groug@kaod.org> In-Reply-To: <20210604161156.408496-1-groug@kaod.org> References: <20210604161156.408496-1-groug@kaod.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=groug@kaod.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kaod.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The creation of a submount is open-coded in fuse_dentry_automount(). This brings a lot of complexity and we recently had to fix bugs because we weren't setting SB_BORN or because we were unlocking sb->s_umount before sb was fully configured. Most of these could have been avoided by using the mount API instead of open-coding. Basically, this means coming up with a proper ->get_tree() implementation for submounts and call vfs_get_tree(), or better fc_mount(). The creation of the superblock for submounts is quite different from the root mount. Especially, it doesn't require to allocate a FUSE filesystem context, nor to parse parameters. Introduce a dedicated context ops for submounts to make this clear. This is just a placeholder for now, fuse_get_tree_submount() will be populated in a subsequent patch. Only visible change is that we stop allocating/freeing a useless FUSE filesystem context with submounts. Signed-off-by: Greg Kurz --- fs/fuse/fuse_i.h | 5 +++++ fs/fuse/inode.c | 16 ++++++++++++++++ fs/fuse/virtio_fs.c | 3 +++ 3 files changed, 24 insertions(+) diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 7e463e220053..862ad317bc89 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1097,6 +1097,11 @@ int fuse_fill_super_submount(struct super_block *sb, */ bool fuse_mount_remove(struct fuse_mount *fm); +/* + * Setup context ops for submounts + */ +int fuse_init_fs_context_submount(struct fs_context *fsc); + /* * Shut down the connection (possibly sending DESTROY request). */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 393e36b74dc4..fa96a3762ea2 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -1313,6 +1313,22 @@ int fuse_fill_super_submount(struct super_block *sb, return 0; } +static int fuse_get_tree_submount(struct fs_context *fsc) +{ + return 0; +} + +static const struct fs_context_operations fuse_context_submount_ops = { + .get_tree = fuse_get_tree_submount, +}; + +int fuse_init_fs_context_submount(struct fs_context *fsc) +{ + fsc->ops = &fuse_context_submount_ops; + return 0; +} +EXPORT_SYMBOL_GPL(fuse_init_fs_context_submount); + int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx) { struct fuse_dev *fud = NULL; diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index bcb8a02e2d8b..e68467cc765c 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -1496,6 +1496,9 @@ static int virtio_fs_init_fs_context(struct fs_context *fsc) { struct fuse_fs_context *ctx; + if (fsc->purpose == FS_CONTEXT_FOR_SUBMOUNT) + return fuse_init_fs_context_submount(fsc); + ctx = kzalloc(sizeof(struct fuse_fs_context), GFP_KERNEL); if (!ctx) return -ENOMEM; -- 2.31.1