Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp261588rwe; Wed, 31 Aug 2022 21:32:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6x7tgshec92RId0U9Q+n6jSCFreut+AAQMF4HTiWcZUz0lKvCMKS6gMPGWxuxxmuN/03mI X-Received: by 2002:a63:cc51:0:b0:41f:12f5:675b with SMTP id q17-20020a63cc51000000b0041f12f5675bmr24154343pgi.69.1662006745305; Wed, 31 Aug 2022 21:32:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662006745; cv=none; d=google.com; s=arc-20160816; b=dYgUxkbqNBLsochcxtGrTkvW3ct33rTwwJLjmM9L8SaiIltQe4PrcFaIHscbRxU6U6 Id4YpAwRqJtL4i5aZ0euA5ncDl7X0ZvmV20s4SXywbvdb3dBTO5ASR6PJIFlrGPjWnMB umxXNF3T0jT/xVoo3w6m46vjD1KTwC7J3JQmFeH/DUFf0eGiRJWjzo6g9HLmR9RlxOrH nH9jiA4LLudCLNGF9kpEUlAEjMnHyKRBV6kW2vUMhOUnkq2JsWbhFHhwa6K2zx7Lpby+ VDyTXJnBr379YS0AD7CiVoqKgrrVvzMqPBaQaO/YM6MjC051wOmbRamzyWmnjgHe2Eqk lUdQ== 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:mail-followup-to:message-id:subject:cc:to:from:date; bh=4PiiPdJ/9pZVYTM1SiwSDNO21yEYXkVMBRuEsfMwGyg=; b=zVDy46uTXotc05sXjDaWr0DAkP9Q3EuFY1hawgolhgabBzWnj2BeaLyTzAWuyjzjHf 6KcXJ01I6UZwPVrmoer6XCs6Lc6Kz4VA/NMQMTjmleyQK9ybl/U+Ake0HygeYpWOe9nn R4NqPIclWULLCWXGOfR3ZQpWu/C7axwhMZLqH3PKSXJnJxopvBYz8G+JQstER+Ee33bV rec9JcJu+4o3C1aB1W62xhazphy19YcHa4iHpJdjl2H5CgP6yyrhYyyybKx2+BVHsoTV 390twJiQkFI1umQJrqGkATHa9PI+9o5EwBHssA4MXdp8DI3OJIqGsvxXr10xHLlIGi6v rgQw== ARC-Authentication-Results: i=1; mx.google.com; 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=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l8-20020a056a00140800b0052ae8f0c52fsi10343861pfu.152.2022.08.31.21.32.13; Wed, 31 Aug 2022 21:32:25 -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; 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=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbiIADtz (ORCPT + 99 others); Wed, 31 Aug 2022 23:49:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229766AbiIADtw (ORCPT ); Wed, 31 Aug 2022 23:49:52 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E80332FE; Wed, 31 Aug 2022 20:49:44 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R271e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VNul.ye_1662004180; Received: from B-P7TQMD6M-0146.local(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VNul.ye_1662004180) by smtp.aliyun-inc.com; Thu, 01 Sep 2022 11:49:41 +0800 Date: Thu, 1 Sep 2022 11:49:39 +0800 From: Gao Xiang To: Jia Zhu Cc: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com Subject: Re: [RFC PATCH 2/5] erofs: introduce fscache-based domain Message-ID: Mail-Followup-To: Jia Zhu , linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com References: <20220831123125.68693-1-zhujia.zj@bytedance.com> <20220831123125.68693-3-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220831123125.68693-3-zhujia.zj@bytedance.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 On Wed, Aug 31, 2022 at 08:31:22PM +0800, Jia Zhu wrote: > 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 := super.o inode.o data.o namei.o dir.o utils.o pcpubuf.o sysfs.o > erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o > erofs-$(CONFIG_EROFS_FS_ZIP) += decompressor.o zmap.o zdata.o > erofs-$(CONFIG_EROFS_FS_ZIP_LZMA) += decompressor_lzma.o > -erofs-$(CONFIG_EROFS_FS_ONDEMAND) += fscache.o > +erofs-$(CONFIG_EROFS_FS_ONDEMAND) += 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 `domain` is now still entirely designed for fscache backend. I'd suggest moving the code below to fscache.c for now until we could find more use cases more than fscache. > @@ -0,0 +1,115 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (C) 2022, Bytedance Inc. All rights reserved. Also you could move this line to fscache.c as well. > + */ > + > +#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 = init_pseudo(fc, ANON_INODE_FS_MAGIC); > + > + if (!ctx) > + return -ENOMEM; > + return 0; > +} > + > +static struct file_system_type anon_inode_fs_type = { > + .name = "pseudo_domainfs", > + .init_fs_context = anon_inodefs_init_fs_context, > + .kill_sb = kill_anon_super, > +}; Could we just use erofs filesystem type but with a special sb instead? No need to cause messes like this. Thanks, Gao Xiang