From nobody Tue Apr 7 03:56:46 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 0F2B7C0502C for ; Wed, 31 Aug 2022 12:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231216AbiHaMcL (ORCPT ); Wed, 31 Aug 2022 08:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbiHaMcE (ORCPT ); Wed, 31 Aug 2022 08:32:04 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 303F3D1E0D for ; Wed, 31 Aug 2022 05:32:03 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id q3so10750038pjg.3 for ; Wed, 31 Aug 2022 05:32:03 -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; bh=/63KM3wyfELIawz0klhvCCYXeq+xfEs4T43zEY9eKME=; b=M8H8JUbIYde0xqj3oQuttD73l6sjhdY9fhJcRMSEilPziu1+x5YARpHDcsixAvcUJr /IiCcMRdOM3pXrAcUM/e6IglwRHWSjWnzBrV6P0pmgPMe5sNveuq4yJiNHTEu9PRfG6j oEfTZYzYcKJXV2/XqsFSBq/TsqcYl5AyMWUpijwHDumSEZUDfMTK3i0WknLnZ58eH7Au moAPwCyCSwq6WwS+8mQsw+zbnv34gT4lg7bPkvk05TK6xVEwJpSglJcP8zQo8W+plYBM tW8IQwejRhDBj3hxqrykkMTd6/mwAwfCE7BK4Pgdjv4EAEP7RiTfa3HKRxrQRpczzMmd Vq8A== 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; bh=/63KM3wyfELIawz0klhvCCYXeq+xfEs4T43zEY9eKME=; b=kxIswL45AFyM70I0C34pnccX7bnuHlDZ32zwRsiRf9XZZyMPcc/s1E4KpND/Hj1xo+ b1vbCx8MCZ1pIQTFUARZZSSG7LMGFrZ/RvEOQyissWWas7ZDSVcWD/x6IZmzKEzhxlcZ rBP9aiYTq3ArvBz9t1gdbr3SoDv+HjLemcZQuAuuSNzgJhbFdOxWn5ams1ZkrP4YXhUY HcqM3a+/vd+kprk6tzqvFCMDOMHANM47v5w/8Skapr0Du2c60uFGvsHEGdOU/Q4+l2BY jiwCIn9bZMoD3crN/RbLwJQ16EVcCofE+Skf5OHKGPoaq+ZGKkg730RfpuNx9dAJCK9P LYAw== X-Gm-Message-State: ACgBeo2kAuSK3eyfkkd5jZA8LVtLDkk2diVIunhKyNeWoystnJbRQDRm gJX1gbQKrqFQeYw99kfMiH1tBg== X-Google-Smtp-Source: AA6agR6CqYAH3QKHOoDBvhQmp9uHrrQPT7DpAE9K6gg0dUHeqmZsA49Uke/52XvPDFXyv1fqwGwFtA== X-Received: by 2002:a17:902:f64a:b0:172:7576:2124 with SMTP id m10-20020a170902f64a00b0017275762124mr25020406plg.155.1661949122637; Wed, 31 Aug 2022 05:32:02 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id n12-20020a170902e54c00b0016efad0a63csm11769896plf.100.2022.08.31.05.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 05:32:02 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [RFC PATCH 1/5] erofs: add 'domain_id' mount option for on-demand read sementics Date: Wed, 31 Aug 2022 20:31:21 +0800 Message-Id: <20220831123125.68693-2-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220831123125.68693-1-zhujia.zj@bytedance.com> References: <20220831123125.68693-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" Introduce 'domain_id' mount option to enable shared domain sementics. In which case, the related cookie is shared if two mountpoints in the same domain have the same data blob. Users could specify the name of domain by this mount option. Signed-off-by: Jia Zhu --- fs/erofs/internal.h | 1 + fs/erofs/super.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index cfee49d33b95..fe435d077f1a 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -76,6 +76,7 @@ struct erofs_mount_opts { #endif unsigned int mount_opt; char *fsid; + char *domain_id; }; =20 struct erofs_dev_context { diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 3173debeaa5a..fb5a84a07bd5 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -440,6 +440,7 @@ enum { Opt_dax_enum, Opt_device, Opt_fsid, + Opt_domain_id, Opt_err }; =20 @@ -465,6 +466,7 @@ static const struct fs_parameter_spec erofs_fs_paramete= rs[] =3D { fsparam_enum("dax", Opt_dax_enum, erofs_dax_param_enums), fsparam_string("device", Opt_device), fsparam_string("fsid", Opt_fsid), + fsparam_string("domain_id", Opt_domain_id), {} }; =20 @@ -568,6 +570,16 @@ static int erofs_fc_parse_param(struct fs_context *fc, return -ENOMEM; #else errorfc(fc, "fsid option not supported"); +#endif + break; + case Opt_domain_id: + kfree(ctx->opt.domain_id); + ctx->opt.domain_id =3D kstrdup(param->string, GFP_KERNEL); + if (!ctx->opt.domain_id) + return -ENOMEM; +#ifdef CONFIG_EROFS_FS_ONDEMAND +#else + errorfc(fc, "domain_id option not supported"); #endif break; default: @@ -695,6 +707,7 @@ static int erofs_fc_fill_super(struct super_block *sb, = struct fs_context *fc) sb->s_fs_info =3D sbi; sbi->opt =3D ctx->opt; ctx->opt.fsid =3D NULL; + ctx->opt.domain_id =3D NULL; sbi->devs =3D ctx->devs; ctx->devs =3D NULL; =20 @@ -838,6 +851,7 @@ static void erofs_fc_free(struct fs_context *fc) =20 erofs_free_dev_context(ctx->devs); kfree(ctx->opt.fsid); + kfree(ctx->opt.domain_id); kfree(ctx); } =20 @@ -892,6 +906,7 @@ static void erofs_kill_sb(struct super_block *sb) erofs_fscache_unregister_cookie(&sbi->s_fscache); erofs_fscache_unregister_fs(sb); kfree(sbi->opt.fsid); + kfree(sbi->opt.domain_id); kfree(sbi); sb->s_fs_info =3D NULL; } @@ -1044,6 +1059,8 @@ static int erofs_show_options(struct seq_file *seq, s= truct dentry *root) #ifdef CONFIG_EROFS_FS_ONDEMAND if (opt->fsid) seq_printf(seq, ",fsid=3D%s", opt->fsid); + if (opt->domain_id) + seq_printf(seq, ",domain_id=3D%s", opt->domain_id); #endif return 0; } --=20 2.20.1 From nobody Tue Apr 7 03:56:46 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 AD97DECAAD5 for ; Wed, 31 Aug 2022 12:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbiHaMcQ (ORCPT ); Wed, 31 Aug 2022 08:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbiHaMcJ (ORCPT ); Wed, 31 Aug 2022 08:32:09 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DEBD1E25 for ; Wed, 31 Aug 2022 05:32:07 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id o4so13994801pjp.4 for ; Wed, 31 Aug 2022 05:32:07 -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; bh=hKdWBWYDJXs3UW3r3n8QFJOIlhbYwEmeU3wrkibpOYY=; b=pK3IAzKKQvStYX4DzEh+ITweFS7+vZS9qSQ6azRv6tawU7l+L4AfSSEbKYnTlX3NNV T3SPmRcSpufC7NjP8RH4Fhs65lTQtA8PhrWMqMOEwx/SXmWIZJFCuSOzqiYvodZfoPnq zQ2j6YVqNeu0G3hMm5V8x7/cGNKlvH/QrzNLp43nd1Ty0m8C3NNaicVt+VRsehgSiU6x J5Gbnl/P6l/Sbz7laxsv3yvzHKT30l79GFiTcQpAmu0B0+LVJhwzqD0fyFq4vkAvy0jf STcrdCaSsELHXPnH9J42B//HYhxVLrXuYOuTNupjL1yWeK2yE/7jqvMGT2aT1B6+wZ7H D38A== 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; bh=hKdWBWYDJXs3UW3r3n8QFJOIlhbYwEmeU3wrkibpOYY=; b=KadJfKRSAiulpkguN4pV0NRlm20YygEBEnRiRObh8UcJF2MqDpOvEURkTgzhZv2bg3 vMPJaEA/MANX6ayK75EXGmy2y8ymQdc2/yjr2ZEy9U4+yWtxX33Brf59cXDtNjFN/V3L 02TcF3uNx3B8WGI85eppPBdaN3fVivp7w7YBkXdFxEljfEKQy9AAPUPF2+vYIb/onwY4 acYFCutg2lO8Hb4y0NiX86gM2ydBc9QrqNFOl6cN0xzdm+888FzRye9afcaDdRohKr/V DJ7lNpf5P/GgUftXHm/w4ZYkdyDB/S6v5YDDbBsQ05ZniO4GuZJ511CzZcINlvPhEdOG FR7A== X-Gm-Message-State: ACgBeo1onRdrvGIlpIZYqITE0NqyUcOTDzKKuYOsb2j4gro1sZX2lJhw hrtrlFTL/lQHgLOhr3qnhHLRtQ== X-Google-Smtp-Source: AA6agR4+sdkfStqKcbUG8P3Il+NIzfdjpnLXYTLm2Vg4zvQgw+UbRR/T3Hc/sNcImlkk+cIYwkm+8Q== X-Received: by 2002:a17:902:cec7:b0:172:5b09:161c with SMTP id d7-20020a170902cec700b001725b09161cmr24846276plg.60.1661949127383; Wed, 31 Aug 2022 05:32:07 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id n12-20020a170902e54c00b0016efad0a63csm11769896plf.100.2022.08.31.05.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 05:32:07 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [RFC PATCH 2/5] erofs: introduce fscache-based domain Date: Wed, 31 Aug 2022 20:31:22 +0800 Message-Id: <20220831123125.68693-3-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220831123125.68693-1-zhujia.zj@bytedance.com> References: <20220831123125.68693-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" A new fscache-based shared domain mode is going to be introduced for erofs. In which case, same data blobs in same domain will be shared and reused to reduce on-disk space usage. As the first step, we use pseudo mnt to manage and maintain domain's lifecycle. The implementation of sharing blobs will be introduced in subsequent patches. Signed-off-by: Jia Zhu --- fs/erofs/Makefile | 2 +- fs/erofs/domain.c | 115 ++++++++++++++++++++++++++++++++++++++++++++ fs/erofs/fscache.c | 10 +++- fs/erofs/internal.h | 20 +++++++- fs/erofs/super.c | 17 ++++--- 5 files changed, 154 insertions(+), 10 deletions(-) create mode 100644 fs/erofs/domain.c diff --git a/fs/erofs/Makefile b/fs/erofs/Makefile index 99bbc597a3e9..a4af7ecf636f 100644 --- a/fs/erofs/Makefile +++ b/fs/erofs/Makefile @@ -5,4 +5,4 @@ erofs-objs :=3D super.o inode.o data.o namei.o dir.o utils.= o pcpubuf.o sysfs.o erofs-$(CONFIG_EROFS_FS_XATTR) +=3D xattr.o erofs-$(CONFIG_EROFS_FS_ZIP) +=3D decompressor.o zmap.o zdata.o erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) +=3D decompressor_lzma.o -erofs-$(CONFIG_EROFS_FS_ONDEMAND) +=3D fscache.o +erofs-$(CONFIG_EROFS_FS_ONDEMAND) +=3D fscache.o domain.o diff --git a/fs/erofs/domain.c b/fs/erofs/domain.c new file mode 100644 index 000000000000..6461e4ee3582 --- /dev/null +++ b/fs/erofs/domain.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2022, Bytedance Inc. All rights reserved. + */ + +#include +#include +#include +#include + +#include "internal.h" + +static DEFINE_SPINLOCK(erofs_domain_list_lock); +static LIST_HEAD(erofs_domain_list); + +void erofs_fscache_domain_get(struct erofs_domain *domain) +{ + if (!domain) + return; + refcount_inc(&domain->ref); +} + +void erofs_fscache_domain_put(struct erofs_domain *domain) +{ + if (!domain) + return; + if (refcount_dec_and_test(&domain->ref)) { + fscache_relinquish_volume(domain->volume, NULL, false); + spin_lock(&erofs_domain_list_lock); + list_del(&domain->list); + spin_unlock(&erofs_domain_list_lock); + kern_unmount(domain->mnt); + kfree(domain->domain_id); + kfree(domain); + } +} + +static int anon_inodefs_init_fs_context(struct fs_context *fc) +{ + struct pseudo_fs_context *ctx =3D init_pseudo(fc, ANON_INODE_FS_MAGIC); + + if (!ctx) + return -ENOMEM; + return 0; +} + +static struct file_system_type anon_inode_fs_type =3D { + .name =3D "pseudo_domainfs", + .init_fs_context =3D anon_inodefs_init_fs_context, + .kill_sb =3D kill_anon_super, +}; + +static int erofs_fscache_init_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct vfsmount *pseudo_mnt; + struct erofs_sb_info *sbi =3D EROFS_SB(sb); + + domain =3D kzalloc(sizeof(struct erofs_domain), GFP_KERNEL); + if (!domain) + return -ENOMEM; + + domain->domain_id =3D kstrdup(sbi->opt.domain_id, GFP_KERNEL); + if (!domain->domain_id) { + kfree(domain); + return -ENOMEM; + } + sbi->domain =3D domain; + pseudo_mnt =3D kern_mount(&anon_inode_fs_type); + if (IS_ERR(pseudo_mnt)) { + err =3D PTR_ERR(pseudo_mnt); + goto out; + } + err =3D erofs_fscache_register_fs(sb); + if (err) { + kern_unmount(pseudo_mnt); + goto out; + } + + domain->mnt =3D pseudo_mnt; + domain->volume =3D sbi->volume; + refcount_set(&domain->ref, 1); + mutex_init(&domain->mutex); + pseudo_mnt->mnt_sb->s_fs_info =3D domain; + list_add(&domain->list, &erofs_domain_list); + return 0; +out: + kfree(domain->domain_id); + kfree(domain); + sbi->domain =3D NULL; + return err; +} + +int erofs_fscache_register_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct erofs_sb_info *sbi =3D EROFS_SB(sb); + + spin_lock(&erofs_domain_list_lock); + list_for_each_entry(domain, &erofs_domain_list, list) { + if (!strcmp(domain->domain_id, sbi->opt.domain_id)) { + erofs_fscache_domain_get(domain); + sbi->domain =3D domain; + sbi->volume =3D domain->volume; + spin_unlock(&erofs_domain_list_lock); + return 0; + } + } + err =3D erofs_fscache_init_domain(sb); + spin_unlock(&erofs_domain_list_lock); + + return err; +} diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 8e01d89c3319..5c918a06ae9a 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -495,7 +495,8 @@ int erofs_fscache_register_fs(struct super_block *sb) char *name; int ret =3D 0; =20 - name =3D kasprintf(GFP_KERNEL, "erofs,%s", sbi->opt.fsid); + name =3D kasprintf(GFP_KERNEL, "erofs,%s", + sbi->domain ? sbi->domain->domain_id : sbi->opt.fsid); if (!name) return -ENOMEM; =20 @@ -515,6 +516,11 @@ void erofs_fscache_unregister_fs(struct super_block *s= b) { struct erofs_sb_info *sbi =3D EROFS_SB(sb); =20 - fscache_relinquish_volume(sbi->volume, NULL, false); + if (sbi->domain) + erofs_fscache_domain_put(sbi->domain); + else + fscache_relinquish_volume(sbi->volume, NULL, false); + sbi->volume =3D NULL; + sbi->domain =3D NULL; } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index fe435d077f1a..bca4e9c57890 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -99,6 +99,15 @@ struct erofs_sb_lz4_info { u16 max_pclusterblks; }; =20 +struct erofs_domain { + refcount_t ref; + struct mutex mutex; + struct vfsmount *mnt; + struct list_head list; + struct fscache_volume *volume; + char *domain_id; +}; + struct erofs_fscache { struct fscache_cookie *cookie; struct inode *inode; @@ -158,6 +167,7 @@ struct erofs_sb_info { /* fscache support */ struct fscache_volume *volume; struct erofs_fscache *s_fscache; + struct erofs_domain *domain; }; =20 #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) @@ -608,8 +618,11 @@ static inline int z_erofs_load_lzma_config(struct supe= r_block *sb, =20 /* fscache.c */ #ifdef CONFIG_EROFS_FS_ONDEMAND +void erofs_fscache_domain_get(struct erofs_domain *domain); +void erofs_fscache_domain_put(struct erofs_domain *domain); int erofs_fscache_register_fs(struct super_block *sb); void erofs_fscache_unregister_fs(struct super_block *sb); +int erofs_fscache_register_domain(struct super_block *sb); =20 int erofs_fscache_register_cookie(struct super_block *sb, struct erofs_fscache **fscache, @@ -620,10 +633,15 @@ extern const struct address_space_operations erofs_fs= cache_access_aops; #else static inline int erofs_fscache_register_fs(struct super_block *sb) { - return 0; + return -EOPNOTSUPP; } static inline void erofs_fscache_unregister_fs(struct super_block *sb) {} =20 +static inline int erofs_fscache_register_domain(const struct super_block *= sb) +{ + return -EOPNOTSUPP; +} + static inline int erofs_fscache_register_cookie(struct super_block *sb, struct erofs_fscache **fscache, char *name, bool need_inode) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index fb5a84a07bd5..55d2343c18a4 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -715,12 +715,17 @@ static int erofs_fc_fill_super(struct super_block *sb= , struct fs_context *fc) sb->s_blocksize =3D EROFS_BLKSIZ; sb->s_blocksize_bits =3D LOG_BLOCK_SIZE; =20 - err =3D erofs_fscache_register_fs(sb); - if (err) - return err; - - err =3D erofs_fscache_register_cookie(sb, &sbi->s_fscache, - sbi->opt.fsid, true); + if (sbi->opt.domain_id) { + err =3D erofs_fscache_register_domain(sb); + if (err) + return err; + } else { + err =3D erofs_fscache_register_fs(sb); + if (err) + return err; + err =3D erofs_fscache_register_cookie(sb, &sbi->s_fscache, + sbi->opt.fsid, true); + } if (err) return err; =20 --=20 2.20.1 From nobody Tue Apr 7 03:56:46 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 B88A6ECAAD4 for ; Wed, 31 Aug 2022 12:32:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231255AbiHaMca (ORCPT ); Wed, 31 Aug 2022 08:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231224AbiHaMcY (ORCPT ); Wed, 31 Aug 2022 08:32:24 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98055D34FC for ; Wed, 31 Aug 2022 05:32:13 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id t5so14034651pjs.0 for ; Wed, 31 Aug 2022 05:32: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; bh=Jk44PJvjdjdt0bhfpwnVqhAy54lOcNkatPLUifUkm78=; b=a69A5kXxCghZWvwb8YYV75Ozfttgowwd2GDPhnjFzjz+qEazPSR4vukwVjDh7QBPgG DsLfR21QtnFhVcOQEysq6Jco6goRw3OWeI6cA9DjxyCyRfdB2zDiWvyPyUcdLZ9EqD5M BvK5D6hByMcgaMRQh8s+I8VAX7SBzNISEkj7LjHvVxqShxdTkSOliOrFpfd66IHbD2IR j7w1+shnZDMc09iyr44+fiP6fribUX1dqpgfXPeZ1gkiFj2SsRf6i5ZcrElH/Ghz+Ehs v9WVDFy4uzKb1PAENyZNriVppdLqadwA31b+PFWbJtON6+TGleh3Evc+QEJhagIG1OpF X5AQ== 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; bh=Jk44PJvjdjdt0bhfpwnVqhAy54lOcNkatPLUifUkm78=; b=42PWTEWoq0X8Np1Xygi9xUOG2zTm5Z3FBdhnWiXpRKWKTgaLROWo+/W1W5nX0sMGfs c/rOTa0pm8wSOz/ZfmQxo9JPwAwSMwIFCmSz0CDha0qzHAlyZShVKZuMAlYs/TL3tFxB yASh032MYWFVvxFNEMdU9tcswbtZiy0HmagBtPNyXODOuRt5mvJa4JZOweHKen5FRJyG x1oexfP2Fb2S4PRqWwqzIsjUOqt8H+wtv8PyDuJK0nXFgW02TcRZN5kozUmd/l5M74/i YSkPhxnu+nLSf1IQ1ljxlhB3AX+0CsuAtzg3kKD7EuJ38UnQEHlWt8TXIER0p6X7otLm w5KA== X-Gm-Message-State: ACgBeo3DnA3lrrSd8tiS3vtyQKQUCTMiKiPNJBXgaaIPj/0RpwmkWE8r 8Km3i++qgo8djylPWWl/NCDgLw== X-Google-Smtp-Source: AA6agR5OOzG/6F5Jtqz0Vb/Nb6BOsK8fByctobqC4HoDomtr9xupaeVXSDCFYbQS7FmbcNB0s5JZWw== X-Received: by 2002:a17:90b:35c3:b0:1fe:10c4:cfb7 with SMTP id nb3-20020a17090b35c300b001fe10c4cfb7mr3056865pjb.60.1661949132226; Wed, 31 Aug 2022 05:32:12 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id n12-20020a170902e54c00b0016efad0a63csm11769896plf.100.2022.08.31.05.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 05:32:11 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [RFC PATCH 3/5] erofs: add 'domain_id' prefix when register sysfs Date: Wed, 31 Aug 2022 20:31:23 +0800 Message-Id: <20220831123125.68693-4-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220831123125.68693-1-zhujia.zj@bytedance.com> References: <20220831123125.68693-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" In shared domain mount procedure, add 'domain_id' prefix to register sysfs entry. Thus we could distinguish mounts that don't use shared domain. Signed-off-by: Jia Zhu --- fs/erofs/sysfs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index c1383e508bbe..c0031d7bd817 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -201,12 +201,21 @@ static struct kobject erofs_feat =3D { int erofs_register_sysfs(struct super_block *sb) { struct erofs_sb_info *sbi =3D EROFS_SB(sb); + char *name =3D NULL; int err; =20 + if (erofs_is_fscache_mode(sb)) { + name =3D kasprintf(GFP_KERNEL, "%s%s%s", sbi->opt.domain_id ? + sbi->opt.domain_id : "", sbi->opt.domain_id ? "," : "", + sbi->opt.fsid); + if (!name) + return -ENOMEM; + } sbi->s_kobj.kset =3D &erofs_root; init_completion(&sbi->s_kobj_unregister); err =3D kobject_init_and_add(&sbi->s_kobj, &erofs_sb_ktype, NULL, "%s", - erofs_is_fscache_mode(sb) ? sbi->opt.fsid : sb->s_id); + name ? name : sb->s_id); + kfree(name); if (err) goto put_sb_kobj; return 0; --=20 2.20.1 From nobody Tue Apr 7 03:56:46 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 34AB3ECAAD1 for ; Wed, 31 Aug 2022 12:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231310AbiHaMcd (ORCPT ); Wed, 31 Aug 2022 08:32:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231259AbiHaMc0 (ORCPT ); Wed, 31 Aug 2022 08:32:26 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8E26D39A4 for ; Wed, 31 Aug 2022 05:32:17 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id 202so13384925pgc.8 for ; Wed, 31 Aug 2022 05:32:17 -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; bh=WugVPm8FmMPSaptmZMd5rqlv9lrGBWi6vcJNH+GONqA=; b=cxa4WizIxSVztAOwqS3p1vrzdIohGVelZD28GH/iej9ofpHRtLhH1cBA7X33awv5uL cFbWTqJtHS0Nf3ytkXuWXvIDZ+W16F2s0SE8uFO9WVsGt50aUgRrJIBTookyKK+4z1MW 0VEh5Dk0odizW6XMn74eGMUNmoShini6IWqHJLKN6srUVYkbwqxwTmyWY2QiAhFqx6sK QyeLRjRDBbnWDoqGWc0Rq9qmFsmAYsOFrpD2C9KiY+Sc/r3L+j2NXv2UVz4WP06MBEVV 0ZysMKgu4nNPNXs18LTsjU9MH3CrPsS1YZFjizFTKYkAIgl20QxwLTeLRSxnx2ob+Tyb lC6A== 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; bh=WugVPm8FmMPSaptmZMd5rqlv9lrGBWi6vcJNH+GONqA=; b=sp5vzF8t2zU6RV5PYL/U85bwKqJlCqBMLRO8LgkFcLzMj9WCPdfwD5p6dr2fYlinym opz9TpN/LRJ7/7QcVmGkTyd8HOyAdLo+c9U2GOhKPdKHI+sXSyjrXEQsgISHbJn52P/D UdX4CgWKlpvy4N2M0QTNVll5EHDFQivswg5hi+Cp5DSvmCSWkNB8T71oI/D6ArzJEN/2 jq7LIDQHTPfW9iFfjCdDsAWOYIrnIo3vg2F1o+np6f7xh01IMzs4uS8CuCPy63Vx6wQc D6Is8/39R4edCHyVuZSVuv4UebFaeqNDghEZt8DjLpx+SFzduNqV8Av+ygxODbKEBPLO Depw== X-Gm-Message-State: ACgBeo1yXH8IJ1w8hestCsJHD6Kwk59jxkni6AVlOlOwfCJg/qWdSiux AWlKMqtNiXwms5YkAGxroNakmQ== X-Google-Smtp-Source: AA6agR48GQvGj6dIP4ogw1z7Eg1rCQiwWE1zxsQ+xnXMrG9ghr/pZ2SUlTyFcCm74OOggxXrTFGE9A== X-Received: by 2002:a05:6a00:228a:b0:538:47a7:706 with SMTP id f10-20020a056a00228a00b0053847a70706mr13569032pfe.62.1661949136951; Wed, 31 Aug 2022 05:32:16 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id n12-20020a170902e54c00b0016efad0a63csm11769896plf.100.2022.08.31.05.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 05:32:16 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [RFC PATCH 4/5] erofs: remove duplicated unregister_cookie Date: Wed, 31 Aug 2022 20:31:24 +0800 Message-Id: <20220831123125.68693-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220831123125.68693-1-zhujia.zj@bytedance.com> References: <20220831123125.68693-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" In erofs umount scenario, erofs_fscache_unregister_cookie() is called twice in kill_sb() and put_super(). It works for original semantics, cause 'ctx' will be set to NULL in put_super() and will not be unregister again in kill_sb(). However, in shared domain scenario, we use refcount to maintain the lifecycle of cookie. Unregister the cookie twice will cause it to be released early. Signed-off-by: Jia Zhu --- fs/erofs/super.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 55d2343c18a4..bbc63b7d546c 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -929,7 +929,6 @@ static void erofs_put_super(struct super_block *sb) iput(sbi->managed_cache); sbi->managed_cache =3D NULL; #endif - erofs_fscache_unregister_cookie(&sbi->s_fscache); } =20 static struct file_system_type erofs_fs_type =3D { --=20 2.20.1 From nobody Tue Apr 7 03:56:46 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 F04CAECAAD1 for ; Wed, 31 Aug 2022 12:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbiHaMcp (ORCPT ); Wed, 31 Aug 2022 08:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbiHaMc1 (ORCPT ); Wed, 31 Aug 2022 08:32:27 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE5DD3996 for ; Wed, 31 Aug 2022 05:32:22 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id t5so14035106pjs.0 for ; Wed, 31 Aug 2022 05:32:22 -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; bh=helHwjQ1amx6sVpTUTNQHDek/KZbVCB+DokfAJJxgvw=; b=xnANbkoYtNEadF8Ow9iiySSrrjB4JBOG1rya4cOCRbkFcAwq2QmkxVZsv3+RaFg81T WPC14ed6swycXqDFFKrtXemoB7HQofevGUbr03bqc+l+w2HmIUxtG43LPfhJcT+roQfy /WYbhkycvUWeblj0KZdSPShub8O9Kc8oAiFokR4jcmc6Uu8qp7RxYQ8sygN3cPabcuOH eYDBZn3kNQXnyihxoOdR17iqNqafD3xA1K/2kJh++H4O3/+vGSQhB021HMZuiRm5lCWl IULjsDAqr3Kq8XW58ZO7OR0sJhIXn3ghXLAx4C+egY1181KV7mbvRsjD/UDIzo+Fcshp XRTA== 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; bh=helHwjQ1amx6sVpTUTNQHDek/KZbVCB+DokfAJJxgvw=; b=xBJPU+u84zuUDXOgBj6a6dQ/RFc+9lSRJzBWXRGEFxPlBC9W9azNSlbthBwzVGtujP xspLTXXENVC0aO4z5vMysn+H/RKjbs136eGs1LWZHo5aoOXCSIDrt2QiAB7ShObodnuB f1YpmH0d6na3wM6R4avQlfbFrsjZQNS5SuJvB/EOZsveKNKfb7fiHC8Fcnu5HOJxLWST uQFG96s7VTwfTXTyJDjvwno71j3XK3a3YlpdB0Q1FW86N5hQpctHgzCOZI8SoEZBEgS5 J557eXKRIDFaQqDh/+q4bUlSCh9QolLuMRqDuwWLeEVd9KVRQGAhswWbjP2uh6iGKfC7 ExBQ== X-Gm-Message-State: ACgBeo1Hkk0Gci5sV8TY6p0Ppqm1odUJ21bBBdrUDZGyc1bJNAyTxhw8 86zKjpeL0xGRx4A00+xsexh4qA== X-Google-Smtp-Source: AA6agR7bL+1gEdR1cwCGxhsTwLthUGNCIQjqaMBLzgdcqa5MECtZu1yardGPFvPLevcAOcM5vyzLvA== X-Received: by 2002:a17:902:c40f:b0:175:3c1e:8493 with SMTP id k15-20020a170902c40f00b001753c1e8493mr4453098plk.19.1661949142037; Wed, 31 Aug 2022 05:32:22 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id n12-20020a170902e54c00b0016efad0a63csm11769896plf.100.2022.08.31.05.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 05:32:21 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [RFC PATCH 5/5] erofs: support fscache based shared domain Date: Wed, 31 Aug 2022 20:31:25 +0800 Message-Id: <20220831123125.68693-6-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20220831123125.68693-1-zhujia.zj@bytedance.com> References: <20220831123125.68693-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" Several erofs filesystems can belong to one domain, and data blobs can be shared among these erofs filesystems of same domain. Users could specify domain_id mount option to create or join into a domain. Signed-off-by: Jia Zhu --- fs/erofs/domain.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ fs/erofs/fscache.c | 7 ++++++ fs/erofs/internal.h | 13 ++++++++++ fs/erofs/super.c | 10 ++++++-- 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/fs/erofs/domain.c b/fs/erofs/domain.c index 6461e4ee3582..ea7b591b7db1 100644 --- a/fs/erofs/domain.c +++ b/fs/erofs/domain.c @@ -13,6 +13,66 @@ static DEFINE_SPINLOCK(erofs_domain_list_lock); static LIST_HEAD(erofs_domain_list); =20 +static int erofs_fscache_domain_init_cookie(struct super_block *sb, + struct erofs_fscache **fscache, char *name, bool need_inode) +{ + int ret; + struct inode *inode; + struct erofs_fscache *ctx; + struct erofs_sb_info *sbi =3D EROFS_SB(sb); + struct erofs_domain *domain =3D sbi->domain; + + ret =3D erofs_fscache_register_cookie(sb, &ctx, name, need_inode); + if (ret) + return ret; + + ctx->name =3D kstrdup(name, GFP_KERNEL); + if (!ctx->name) + return -ENOMEM; + + inode =3D new_inode(domain->mnt->mnt_sb); + if (!inode) { + kfree(ctx->name); + return -ENOMEM; + } + + ctx->domain =3D domain; + ctx->anon_inode =3D inode; + inode->i_private =3D ctx; + refcount_set(&ctx->ref, 1); + erofs_fscache_domain_get(domain); + *fscache =3D ctx; + return 0; +} + +int erofs_domain_register_cookie(struct super_block *sb, + struct erofs_fscache **fscache, char *name, bool need_inode) +{ + int err; + struct inode *inode; + struct erofs_fscache *ctx; + struct erofs_sb_info *sbi =3D EROFS_SB(sb); + struct erofs_domain *domain =3D sbi->domain; + struct super_block *psb =3D domain->mnt->mnt_sb; + + mutex_lock(&domain->mutex); + list_for_each_entry(inode, &psb->s_inodes, i_sb_list) { + ctx =3D inode->i_private; + if (!ctx) + continue; + if (!strcmp(ctx->name, name)) { + *fscache =3D ctx; + refcount_inc(&ctx->ref); + mutex_unlock(&domain->mutex); + return 0; + } + } + err =3D erofs_fscache_domain_init_cookie(sb, fscache, name, need_inode); + mutex_unlock(&domain->mutex); + + return err; +} + void erofs_fscache_domain_get(struct erofs_domain *domain) { if (!domain) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 5c918a06ae9a..51425e310e3d 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -476,6 +476,8 @@ void erofs_fscache_unregister_cookie(struct erofs_fscac= he **fscache) =20 if (!ctx) return; + if (ctx->domain && !refcount_dec_and_test(&ctx->ref)) + return; =20 fscache_unuse_cookie(ctx->cookie, NULL, NULL); fscache_relinquish_cookie(ctx->cookie, false); @@ -483,7 +485,12 @@ void erofs_fscache_unregister_cookie(struct erofs_fsca= che **fscache) =20 iput(ctx->inode); ctx->inode =3D NULL; + iput(ctx->anon_inode); + ctx->anon_inode =3D NULL; + erofs_fscache_domain_put(ctx->domain); =20 + kfree(ctx->name); + ctx->name =3D NULL; kfree(ctx); *fscache =3D NULL; } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index bca4e9c57890..1abdad81bfe3 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -109,8 +109,12 @@ struct erofs_domain { }; =20 struct erofs_fscache { + refcount_t ref; struct fscache_cookie *cookie; struct inode *inode; + struct inode *anon_inode; + struct erofs_domain *domain; + char *name; }; =20 struct erofs_sb_info { @@ -627,6 +631,9 @@ int erofs_fscache_register_domain(struct super_block *s= b); int erofs_fscache_register_cookie(struct super_block *sb, struct erofs_fscache **fscache, char *name, bool need_inode); +int erofs_domain_register_cookie(struct super_block *sb, + struct erofs_fscache **fscache, + char *name, bool need_inode); void erofs_fscache_unregister_cookie(struct erofs_fscache **fscache); =20 extern const struct address_space_operations erofs_fscache_access_aops; @@ -648,6 +655,12 @@ static inline int erofs_fscache_register_cookie(struct= super_block *sb, { return -EOPNOTSUPP; } +static inline int erofs_domain_register_cookie(struct super_block *sb, + struct erofs_fscache **fscache, + char *name, bool need_inode) +{ + return -EOPNOTSUPP; +} =20 static inline void erofs_fscache_unregister_cookie(struct erofs_fscache **= fscache) { diff --git a/fs/erofs/super.c b/fs/erofs/super.c index bbc63b7d546c..aefe7dfcd4c9 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -245,8 +245,12 @@ static int erofs_init_device(struct erofs_buf *buf, st= ruct super_block *sb, } =20 if (erofs_is_fscache_mode(sb)) { - ret =3D erofs_fscache_register_cookie(sb, &dif->fscache, - dif->path, false); + if (sbi->opt.domain_id) + ret =3D erofs_domain_register_cookie(sb, &dif->fscache, dif->path, + false); + else + ret =3D erofs_fscache_register_cookie(sb, &dif->fscache, dif->path, + false); if (ret) return ret; } else { @@ -719,6 +723,8 @@ static int erofs_fc_fill_super(struct super_block *sb, = struct fs_context *fc) err =3D erofs_fscache_register_domain(sb); if (err) return err; + err =3D erofs_domain_register_cookie(sb, &sbi->s_fscache, + sbi->opt.fsid, true); } else { err =3D erofs_fscache_register_fs(sb); if (err) --=20 2.20.1