Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp733360rwn; Thu, 15 Sep 2022 05:51:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR6UDiDndkEpjyuDGSdSO2elny1J/PmwQ3MVkF+UgWXUnL+sF+IXa2ZRMMUEUEDaLdcXXINi X-Received: by 2002:a17:907:2722:b0:77e:d84d:9e09 with SMTP id d2-20020a170907272200b0077ed84d9e09mr12307784ejl.679.1663246301139; Thu, 15 Sep 2022 05:51:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663246301; cv=none; d=google.com; s=arc-20160816; b=tPeC6HtpK2gNzt8G0Ih+MuC4nXsNqfU5ccxvxo9v+Q7HECEhnKwVZglXVJLpccftVK jHyY9e1E5V1qiUrEE1egKCK4jxrJClnlPFeez0ntgk43s5pZh2p3k7hrM5519oCBNoHJ uZMOgLOVq0u0fflMC15XhmxHs+l3VpLRFX+q99aGnSzUazf9BgDElFUtVlzZ82IxGmwe /YoatcfTMLCddpnKSBcY9GrYWiET0hhf092qLdW96OF8UzhcsijaDWhULR55hUDr3zKD FOA+zp1RAl/4bAtXaG70VPPTmS+XrK2FvmY1uGoyjZYTwqMK7w/eKlFoXHZg7KKSGyM5 x6iw== 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 :dkim-signature; bh=N+8Ic9syGTC1u0a/MXotLVtHNCtWkf7iFn7tvbMZmlY=; b=jEwy2u453wuOftsr8TltIzd3S81Qj4jSgtX92ARoZG3fvcEp+hOnUFgh+EpL61E+Os K3ENmoq+GMnnAoWleyLMFO7YL+7m/6l3DcOti/31YuqhJGcwRBGFrgnXBv44JfnZqXiw xHRhVZP62b9OxnKI1m9F6L5kvspkuvoDVbuJW/54xBT3JBo54fRNOd0jB/2CGVOMvxeI 4+RVspi47Aw4ivPBcNTN48JPeG5NM/PmU2AF+I6Y3n1iiUSqOlZpqbW4YCChJat2Xa9Q T4K4VZ9a7KYkMMfJGLdPkk3xbEmmDkWgBQFDtegNAQAHekwGcYfDnMlkA61wN2pBw5a0 s7dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=CHGyfbuD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a1709065d1000b0077fdd87a7dfsi7566327ejt.914.2022.09.15.05.51.13; Thu, 15 Sep 2022 05:51:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=CHGyfbuD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230288AbiIOMnJ (ORCPT + 99 others); Thu, 15 Sep 2022 08:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiIOMm5 (ORCPT ); Thu, 15 Sep 2022 08:42:57 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE879A9EF for ; Thu, 15 Sep 2022 05:42:45 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so22222533pjq.3 for ; Thu, 15 Sep 2022 05:42:45 -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=N+8Ic9syGTC1u0a/MXotLVtHNCtWkf7iFn7tvbMZmlY=; b=CHGyfbuDxEYsmMOBtJ5Xs/wDe6c91lFi6Xew7HSn99TcDb2lO22OKPoyVOtbn3MS/1 Bo73PbLBArqJ0Sa+pDi19plOEapcqrlfeXff+lTxwRhp3tH9lnBF0OR2sS0KjbuhfAp9 n2/LkHyiCaKigFN/GBELZWSLM9R3IacTlcu7eptgFVKWJak3WylBP3MkZGRvTXL41DBO 2RxDXhpjM91fR9BWYAkfEy1m51pLajgNOvLpoTBOBQ9bSImNQJZ14NuOdV4MLu1oQOQ+ kuiTkouHlmwyNkmGXfSiiDkhPLDlOgtsTWyg3vXtG7wz9yxvM4tF1D5kKGDrGi7/XE/9 FIuQ== 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=N+8Ic9syGTC1u0a/MXotLVtHNCtWkf7iFn7tvbMZmlY=; b=wKbYks9mfmE9hQJ2PTzQmUCJ0Hu7mufiDKHDtTQOYpTqhtFDavhPv6Bs0s67pYRfrB segOg3UZ/ezG+fKa2UgYrdrkZxYYXpUZ6SOdKKyyGupAeXlnWNKBWuOwoRaWLUYNu6Wy ssJLFyQG+ES0I5XRy+uMwVsPEvllsgqSAs5wAXlLbFpOBMGHpiRZnT+j2mE39khBDu48 9eXUomDSGlV76MQTeNL+dydAs8hHnXtRMk99kr2/2fTLNkQG1/v/k9YPWsvRAQq0UL1S R/f/ZJnR4hRoqtcH1ZQUsBlZpTxSwurglt9V16qisWHMXZRFXFSNkG91bHp9D9mU2p7Z iv1Q== X-Gm-Message-State: ACrzQf1ZNeJR128/M+VbVypaJ0qBJM4PdToSbq1CWKZTGF3ABpT5Caqh E8tz/oOZqnpevHQhNMD+4S8EiemA8Pnlyw== X-Received: by 2002:a17:90a:c70b:b0:200:4366:d047 with SMTP id o11-20020a17090ac70b00b002004366d047mr10660743pjt.240.1663245765338; Thu, 15 Sep 2022 05:42:45 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id p8-20020a170902780800b001637529493esm12721906pll.66.2022.09.15.05.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:42:44 -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 V4 4/6] erofs: introduce a pseudo mnt to manage shared cookies Date: Thu, 15 Sep 2022 20:42:11 +0800 Message-Id: <20220915124213.25767-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220915124213.25767-1-zhujia.zj@bytedance.com> References: <20220915124213.25767-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use a pseudo mnt to manage shared cookies. Signed-off-by: Jia Zhu --- fs/erofs/fscache.c | 13 +++++++++++++ fs/erofs/internal.h | 1 + fs/erofs/super.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 10d3f0511f15..ff8382df493e 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -8,6 +8,7 @@ static DEFINE_MUTEX(erofs_domain_list_lock); static LIST_HEAD(erofs_domain_list); +static struct vfsmount *erofs_pseudo_mnt; static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space *mapping, loff_t start, size_t len) @@ -429,6 +430,10 @@ static void erofs_fscache_domain_put(struct erofs_domain *domain) if (refcount_dec_and_test(&domain->ref)) { list_del(&domain->list); fscache_relinquish_volume(domain->volume, NULL, false); + if (list_empty(&erofs_domain_list)) { + kern_unmount(erofs_pseudo_mnt); + erofs_pseudo_mnt = NULL; + } mutex_unlock(&erofs_domain_list_lock); kfree(domain->domain_id); kfree(domain); @@ -482,6 +487,14 @@ static int erofs_fscache_init_domain(struct super_block *sb) if (err) goto out; + if (!erofs_pseudo_mnt) { + erofs_pseudo_mnt = kern_mount(&erofs_fs_type); + if (IS_ERR(erofs_pseudo_mnt)) { + err = PTR_ERR(erofs_pseudo_mnt); + goto out; + } + } + domain->volume = 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 7f0939f4005b..88c1a46867b3 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -402,6 +402,7 @@ struct page *erofs_grab_cache_page_nowait(struct address_space *mapping, } extern const struct super_operations erofs_sops; +extern struct file_system_type erofs_fs_type; 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 79e871c04fe2..24bac58285e8 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -676,6 +676,13 @@ static const struct export_operations erofs_export_ops = { .get_parent = erofs_get_parent, }; +static int erofs_fc_fill_pseudo_super(struct super_block *sb, struct fs_context *fc) +{ + static const struct tree_descr empty_descr = {""}; + + 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; } +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 = fc->fs_private; @@ -844,10 +856,20 @@ static const struct fs_context_operations erofs_context_ops = { .free = erofs_fc_free, }; +static const struct fs_context_operations erofs_anon_context_ops = { + .get_tree = erofs_fc_anon_get_tree, +}; + static int erofs_init_fs_context(struct fs_context *fc) { - struct erofs_fs_context *ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + struct erofs_fs_context *ctx; + + if (fc->sb_flags & SB_KERNMOUNT) { + fc->ops = &erofs_anon_context_ops; + return 0; + } + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->devs = kzalloc(sizeof(struct erofs_dev_context), GFP_KERNEL); @@ -874,6 +896,11 @@ static void erofs_kill_sb(struct super_block *sb) WARN_ON(sb->s_magic != EROFS_SUPER_MAGIC); + if (sb->s_flags & SB_KERNMOUNT) { + kill_litter_super(sb); + return; + } + if (erofs_is_fscache_mode(sb)) kill_anon_super(sb); else @@ -908,7 +935,7 @@ static void erofs_put_super(struct super_block *sb) sbi->s_fscache = NULL; } -static struct file_system_type erofs_fs_type = { +struct file_system_type erofs_fs_type = { .owner = THIS_MODULE, .name = "erofs", .init_fs_context = erofs_init_fs_context, -- 2.20.1