From nobody Fri Apr 3 03:53:24 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A839C6FA86 for ; Sun, 18 Sep 2022 04:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbiIREfn (ORCPT ); Sun, 18 Sep 2022 00:35:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiIREfO (ORCPT ); Sun, 18 Sep 2022 00:35:14 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A19175B2 for ; Sat, 17 Sep 2022 21:35:13 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id w13so9431443plp.1 for ; Sat, 17 Sep 2022 21:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=y6Z4QOKHCiEESumRJUmDeS9lxU9MKoynA0yak47BDUs=; b=Omx/AStHDVgnuuMGtA4QKr8D4JqpEFOSMifYkwBBlHe5o2WFqrLFvpkUGRUzNT2u52 KWe9paJQb/9+2gFTAcFqwH51Cj90SXr4tPwhda/E+I8BXJr9sMfeUfyvzdQP4NAbZJ/e 4qqePmzMtQ5SC505Mr0+rywrt2rxERFPQ741ma8WrotmJSyBtBRZw5epbrrFyyD3YMmQ zOWc3+8K+codgL0X8nwLfBLvTXmAUZw/G5Yed7TFhiSn1beadVMkVeleSlYKgqw/y+fQ jrwK5KKqgLbA64eqoIEi27bN3He+bbIGj59ZYufIo+FyiaIVvPrTvxRYo8cZAvUgbG5z HI/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=y6Z4QOKHCiEESumRJUmDeS9lxU9MKoynA0yak47BDUs=; b=Guhw6ZGaMozz8+kB/wFzunI944iSdD7527jSa5isHvAT+HSaTRKTj13fYGwiqZR0rL FDBHf0RhF6eynMPE5j5WYgc1+EbZca6vvbjCHXi+pNVVyWI96SIP5X8D3uMF8qwK83tY 1SIcOB2KYzpVWBdjAsZcg1lEqotT0YUe/P137THKXTty+QHTs3k2gV56Bt3zdTFjrf6n FmeK19FVp8v2eoGAswqsaJgl0eT5bgSjS2s/nJD7qp+vgnUPTyhakRKQ1i3Knwg5puBY 7BVQnrxqG1FLOtR1MYb1kSjmrljsHMZIivtggnTZKEckW2rBlF0zuTvECCFFa0aYLbw0 la8Q== X-Gm-Message-State: ACrzQf0SzUaZJCgywLH1+jofRhiu1Z0ie+/w/fIGQtVarPkPHu05V7XH QfzFEPg7BxyTFlAlwhS/SRlSAg== X-Google-Smtp-Source: AMsMyM5oX0r429mRm3f6dArn+jaI0JIlsOoInPWK9gObBdp0a+c0KzhrT2Q03NIVwGJ3ziTbgCjuAA== X-Received: by 2002:a17:90a:e7d1:b0:200:94fd:967a with SMTP id kb17-20020a17090ae7d100b0020094fd967amr13055990pjb.57.1663475712889; Sat, 17 Sep 2022 21:35:12 -0700 (PDT) Received: from localhost.localdomain ([111.201.134.95]) by smtp.gmail.com with ESMTPSA id l63-20020a622542000000b0054b5239f7fesm3955248pfl.210.2022.09.17.21.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 21:35:12 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, Jia Zhu Subject: [PATCH V6 4/6] erofs: introduce a pseudo mnt to manage shared cookies Date: Sun, 18 Sep 2022 12:34:54 +0800 Message-Id: <20220918043456.147-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220918043456.147-1-zhujia.zj@bytedance.com> References: <20220918043456.147-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use a pseudo mnt to manage shared cookies. Signed-off-by: Jia Zhu Reviewed-by: Jingbo Xu --- fs/erofs/fscache.c | 13 +++++++++++++ fs/erofs/internal.h | 1 + fs/erofs/super.c | 33 +++++++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 9c82284e66ee..4a7346b9fa73 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -8,6 +8,7 @@ =20 static DEFINE_MUTEX(erofs_domain_list_lock); static LIST_HEAD(erofs_domain_list); +static struct vfsmount *erofs_pseudo_mnt; =20 static struct netfs_io_request *erofs_fscache_alloc_request(struct address= _space *mapping, loff_t start, size_t len) @@ -428,6 +429,10 @@ static void erofs_fscache_domain_put(struct erofs_doma= in *domain) mutex_lock(&erofs_domain_list_lock); if (refcount_dec_and_test(&domain->ref)) { list_del(&domain->list); + if (list_empty(&erofs_domain_list)) { + kern_unmount(erofs_pseudo_mnt); + erofs_pseudo_mnt =3D NULL; + } mutex_unlock(&erofs_domain_list_lock); fscache_relinquish_volume(domain->volume, NULL, false); kfree(domain->domain_id); @@ -482,6 +487,14 @@ static int erofs_fscache_init_domain(struct super_bloc= k *sb) if (err) goto out; =20 + if (!erofs_pseudo_mnt) { + erofs_pseudo_mnt =3D kern_mount(&erofs_fs_type); + if (IS_ERR(erofs_pseudo_mnt)) { + err =3D PTR_ERR(erofs_pseudo_mnt); + goto out; + } + } + domain->volume =3D sbi->volume; refcount_set(&domain->ref, 1); list_add(&domain->list, &erofs_domain_list); diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 4c11313a072f..273fb35170e2 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -402,6 +402,7 @@ struct page *erofs_grab_cache_page_nowait(struct addres= s_space *mapping, } =20 extern const struct super_operations erofs_sops; +extern struct file_system_type erofs_fs_type; =20 extern const struct address_space_operations erofs_raw_access_aops; extern const struct address_space_operations z_erofs_aops; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 884e7ed3d760..ab746181ae08 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -676,6 +676,13 @@ static const struct export_operations erofs_export_ops= =3D { .get_parent =3D erofs_get_parent, }; =20 +static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_co= ntext *fc) +{ + static const struct tree_descr empty_descr =3D {""}; + + return simple_fill_super(sb, EROFS_SUPER_MAGIC, &empty_descr); +} + static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *= fc) { struct inode *inode; @@ -776,6 +783,11 @@ static int erofs_fc_fill_super(struct super_block *sb,= struct fs_context *fc) return 0; } =20 +static int erofs_fc_anon_get_tree(struct fs_context *fc) +{ + return get_tree_nodev(fc, erofs_fc_fill_pseudo_super); +} + static int erofs_fc_get_tree(struct fs_context *fc) { struct erofs_fs_context *ctx =3D fc->fs_private; @@ -844,10 +856,21 @@ static const struct fs_context_operations erofs_conte= xt_ops =3D { .free =3D erofs_fc_free, }; =20 +static const struct fs_context_operations erofs_anon_context_ops =3D { + .get_tree =3D erofs_fc_anon_get_tree, +}; + static int erofs_init_fs_context(struct fs_context *fc) { - struct erofs_fs_context *ctx =3D kzalloc(sizeof(*ctx), GFP_KERNEL); + struct erofs_fs_context *ctx; + + /* pseudo mount for anon inodes */ + if (fc->sb_flags & SB_KERNMOUNT) { + fc->ops =3D &erofs_anon_context_ops; + return 0; + } =20 + ctx =3D kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->devs =3D kzalloc(sizeof(struct erofs_dev_context), GFP_KERNEL); @@ -874,6 +897,12 @@ static void erofs_kill_sb(struct super_block *sb) =20 WARN_ON(sb->s_magic !=3D EROFS_SUPER_MAGIC); =20 + /* pseudo mount for anon inodes */ + if (sb->s_flags & SB_KERNMOUNT) { + kill_anon_super(sb); + return; + } + if (erofs_is_fscache_mode(sb)) kill_anon_super(sb); else @@ -907,7 +936,7 @@ static void erofs_put_super(struct super_block *sb) erofs_fscache_unregister_fs(sb); } =20 -static struct file_system_type erofs_fs_type =3D { +struct file_system_type erofs_fs_type =3D { .owner =3D THIS_MODULE, .name =3D "erofs", .init_fs_context =3D erofs_init_fs_context, --=20 2.20.1