From mboxrd@z Thu Jan 1 00:00:00 1970 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 1F222C6FA8B for ; Fri, 16 Sep 2022 09:00:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231166AbiIPJAd (ORCPT ); Fri, 16 Sep 2022 05:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230467AbiIPJAE (ORCPT ); Fri, 16 Sep 2022 05:00:04 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0C2E19C1A for ; Fri, 16 Sep 2022 02:00:01 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id e68so20634814pfe.1 for ; Fri, 16 Sep 2022 02:00:01 -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=Zz/+Lsdw1NAyt93VpvNl+aPHSPA2CVkBmnUTlKe09/0=; b=4qisNJbdWma+Rj2zjr5zlVAEZQnSrQKMLkASGKO9b9BlqIf+QJoNRXVKb25sg4L635 6FRURwKaUva+G4QzGfd6AC+eUNG5Y2huqO/xNxYJXx/h10d8LvxRmExOZWq+1CfcG0CJ lYV/XlNtE/DFY7d8O/fSVob2DvLvEgq9OpekqbOPw/AdHPcmeU51WJG5n2MeJKa6rrgx y9ushi0VJ8eQgXZzh5FkZ6k9Vu07x7neSc4pqZQX958Z0nrxsmLpfRGrf1xWqsZ4P5Ap jCZUMh9rpji47FCmAopP9ZV6RpOLMtPnUo+6gn369MtV7M9esrCYVQ4K2IjriobhAtNo cVDw== 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=Zz/+Lsdw1NAyt93VpvNl+aPHSPA2CVkBmnUTlKe09/0=; b=VJP4UHaPahtwjK2zJGbnHc2fzBbE56EBdceDNbXHPgh7ih3qfUznGnWWrxpEXo9Psd W7E+s0LzM5dtuNfWR/SY/24JoFtXMkVVvuusOBqFzQbJvZixznunWu/v0FmRDKChXkYw hNL0jZnZerPPOwaXuYLcqpw0aj0+p5SXMPFgTHjlwRj+LSLV28suRRnLzZGbutuH3dYb hfJIiZgRWpuKiIou/Sv+N3NFztYt9hVYt1Cr4ysjsqpp9XjjHYhxFUBO0NbSvU7jvmxI b+hXeS4evAP1S6WPn30j6TNte3daN84HgfiiBIyTILcsVUbhVlcaiGVSUH4/fXYCFRd/ KeNw== X-Gm-Message-State: ACrzQf3TUPBo2sFwX1FK5E7IyOB8XvhDO46VBAnj9/JC0nO6VHavfzjO wB2NQspZvq/Tmv4pvo49nTGOLg== X-Google-Smtp-Source: AMsMyM6mjN/hhjbJavtb35w5HcWdX+J19mmRIFSbgt+vLjaofefxuqE1urSkfveGhpCEsIx7whvDLA== X-Received: by 2002:a63:8848:0:b0:434:b5d7:b4fa with SMTP id l69-20020a638848000000b00434b5d7b4famr3525042pgd.181.1663318801474; Fri, 16 Sep 2022 02:00:01 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id u11-20020a17090a450b00b001fd7fe7d369sm970578pjg.54.2022.09.16.01.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:00:01 -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 V5 3/6] erofs: introduce fscache-based domain Date: Fri, 16 Sep 2022 16:59:37 +0800 Message-Id: <20220916085940.89392-4-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220916085940.89392-1-zhujia.zj@bytedance.com> References: <20220916085940.89392-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. The implementation of sharing blobs will be introduced in subsequent patches. Signed-off-by: Jia Zhu Reviewed-by: Jingbo Xu --- fs/erofs/fscache.c | 129 ++++++++++++++++++++++++++++++++++++++------ fs/erofs/internal.h | 9 ++++ 2 files changed, 121 insertions(+), 17 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index d3a90103abb7..9c82284e66ee 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -1,10 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2022, Alibaba Cloud + * Copyright (C) 2022, Bytedance Inc. All rights reserved. */ #include #include "internal.h" +static DEFINE_MUTEX(erofs_domain_list_lock); +static LIST_HEAD(erofs_domain_list); + static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space *mapping, loff_t start, size_t len) { @@ -417,6 +421,99 @@ const struct address_space_operations erofs_fscache_access_aops = { .readahead = erofs_fscache_readahead, }; +static void erofs_fscache_domain_put(struct erofs_domain *domain) +{ + if (!domain) + return; + mutex_lock(&erofs_domain_list_lock); + if (refcount_dec_and_test(&domain->ref)) { + list_del(&domain->list); + mutex_unlock(&erofs_domain_list_lock); + fscache_relinquish_volume(domain->volume, NULL, false); + kfree(domain->domain_id); + kfree(domain); + return; + } + mutex_unlock(&erofs_domain_list_lock); +} + +static int erofs_fscache_register_volume(struct super_block *sb) +{ + struct erofs_sb_info *sbi = EROFS_SB(sb); + char *domain_id = sbi->opt.domain_id; + struct fscache_volume *volume; + char *name; + int ret = 0; + + name = kasprintf(GFP_KERNEL, "erofs,%s", + domain_id ? domain_id : sbi->opt.fsid); + if (!name) + return -ENOMEM; + + volume = fscache_acquire_volume(name, NULL, NULL, 0); + if (IS_ERR_OR_NULL(volume)) { + erofs_err(sb, "failed to register volume for %s", name); + ret = volume ? PTR_ERR(volume) : -EOPNOTSUPP; + volume = NULL; + } + + sbi->volume = volume; + kfree(name); + return ret; +} + +static int erofs_fscache_init_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct erofs_sb_info *sbi = EROFS_SB(sb); + + domain = kzalloc(sizeof(struct erofs_domain), GFP_KERNEL); + if (!domain) + return -ENOMEM; + + domain->domain_id = kstrdup(sbi->opt.domain_id, GFP_KERNEL); + if (!domain->domain_id) { + kfree(domain); + return -ENOMEM; + } + + err = erofs_fscache_register_volume(sb); + if (err) + goto out; + + domain->volume = sbi->volume; + refcount_set(&domain->ref, 1); + list_add(&domain->list, &erofs_domain_list); + sbi->domain = domain; + return 0; +out: + kfree(domain->domain_id); + kfree(domain); + return err; +} + +static int erofs_fscache_register_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct erofs_sb_info *sbi = EROFS_SB(sb); + + mutex_lock(&erofs_domain_list_lock); + list_for_each_entry(domain, &erofs_domain_list, list) { + if (!strcmp(domain->domain_id, sbi->opt.domain_id)) { + sbi->domain = domain; + sbi->volume = domain->volume; + refcount_inc(&domain->ref); + mutex_unlock(&erofs_domain_list_lock); + return 0; + } + } + err = erofs_fscache_init_domain(sb); + mutex_unlock(&erofs_domain_list_lock); + return err; +} + struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb, char *name, bool need_inode) { @@ -480,27 +577,19 @@ void erofs_fscache_unregister_cookie(struct erofs_fscache *ctx) int erofs_fscache_register_fs(struct super_block *sb) { + int ret; struct erofs_sb_info *sbi = EROFS_SB(sb); - struct fscache_volume *volume; struct erofs_fscache *fscache; - char *name; - - name = kasprintf(GFP_KERNEL, "erofs,%s", sbi->opt.fsid); - if (!name) - return -ENOMEM; - volume = fscache_acquire_volume(name, NULL, NULL, 0); - if (IS_ERR_OR_NULL(volume)) { - erofs_err(sb, "failed to register volume for %s", name); - kfree(name); - return volume ? PTR_ERR(volume) : -EOPNOTSUPP; - } - - sbi->volume = volume; - kfree(name); + if (sbi->opt.domain_id) + ret = erofs_fscache_register_domain(sb); + else + ret = erofs_fscache_register_volume(sb); + if (ret) + return ret; + /* acquired domain/volume will be relinquished in kill_sb() on error */ fscache = erofs_fscache_register_cookie(sb, sbi->opt.fsid, true); - /* acquired volume will be relinquished in kill_sb() */ if (IS_ERR(fscache)) return PTR_ERR(fscache); @@ -513,7 +602,13 @@ void erofs_fscache_unregister_fs(struct super_block *sb) struct erofs_sb_info *sbi = EROFS_SB(sb); erofs_fscache_unregister_cookie(sbi->s_fscache); - 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->s_fscache = NULL; sbi->volume = NULL; + sbi->domain = NULL; } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index b36850dd7813..4c11313a072f 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; }; struct erofs_dev_context { @@ -98,6 +99,13 @@ struct erofs_sb_lz4_info { u16 max_pclusterblks; }; +struct erofs_domain { + refcount_t ref; + struct list_head list; + struct fscache_volume *volume; + char *domain_id; +}; + struct erofs_fscache { struct fscache_cookie *cookie; struct inode *inode; @@ -157,6 +165,7 @@ struct erofs_sb_info { /* fscache support */ struct fscache_volume *volume; struct erofs_fscache *s_fscache; + struct erofs_domain *domain; }; #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) -- 2.20.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 04FF4C54EE9 for ; Fri, 16 Sep 2022 09:00:11 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MTSh9410Wz3br0 for ; Fri, 16 Sep 2022 19:00:09 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=4qisNJbd; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com (client-ip=2607:f8b0:4864:20::432; helo=mail-pf1-x432.google.com; envelope-from=zhujia.zj@bytedance.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=4qisNJbd; dkim-atps=neutral Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MTSh50nfvz3c3G for ; Fri, 16 Sep 2022 19:00:04 +1000 (AEST) Received: by mail-pf1-x432.google.com with SMTP id b23so20600048pfp.9 for ; Fri, 16 Sep 2022 02:00:04 -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=Zz/+Lsdw1NAyt93VpvNl+aPHSPA2CVkBmnUTlKe09/0=; b=4qisNJbdWma+Rj2zjr5zlVAEZQnSrQKMLkASGKO9b9BlqIf+QJoNRXVKb25sg4L635 6FRURwKaUva+G4QzGfd6AC+eUNG5Y2huqO/xNxYJXx/h10d8LvxRmExOZWq+1CfcG0CJ lYV/XlNtE/DFY7d8O/fSVob2DvLvEgq9OpekqbOPw/AdHPcmeU51WJG5n2MeJKa6rrgx y9ushi0VJ8eQgXZzh5FkZ6k9Vu07x7neSc4pqZQX958Z0nrxsmLpfRGrf1xWqsZ4P5Ap jCZUMh9rpji47FCmAopP9ZV6RpOLMtPnUo+6gn369MtV7M9esrCYVQ4K2IjriobhAtNo cVDw== 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=Zz/+Lsdw1NAyt93VpvNl+aPHSPA2CVkBmnUTlKe09/0=; b=6Q6mZD3CRkmxK0mCtWykuf3pm8bpxXLygHJcgpxW01cMOjbATl9n/ce4+niZsGmB3R mSMOhG5JKoKDDFfkSn1l21TUKosujssfQ0KeoZV0sAdQjcjFpMl/Gn/0KmBuLnHuUAqy v0fQr0rO/byIuD/YwJgFBCggzpVPrcArcMfURqdk9rNlU4BFP8tiICLHUUVaQG2gJNYO 4g4kIPGnbHw9DOGrqeYtRlkrx2I/S0gRYk43tmsE6RP3YdpCOTFtHDX8TsHEZD2t7P2y qF77K0l8ASwFC3B7KqBy0i3JR+nvmEavCYAsqj4Mwa4lfVz4QG7J+YiHqspDvlRUAfP/ xy3A== X-Gm-Message-State: ACrzQf24q2GfSJ/u2j8Y72ninRgN0Y3ux/aEjPgobfFUfEzgazfwzr1U vQvS3un14Y1omyJnSA2F1F1aWOUcXrG//g== X-Google-Smtp-Source: AMsMyM6mjN/hhjbJavtb35w5HcWdX+J19mmRIFSbgt+vLjaofefxuqE1urSkfveGhpCEsIx7whvDLA== X-Received: by 2002:a63:8848:0:b0:434:b5d7:b4fa with SMTP id l69-20020a638848000000b00434b5d7b4famr3525042pgd.181.1663318801474; Fri, 16 Sep 2022 02:00:01 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id u11-20020a17090a450b00b001fd7fe7d369sm970578pjg.54.2022.09.16.01.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:00:01 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org Subject: [PATCH V5 3/6] erofs: introduce fscache-based domain Date: Fri, 16 Sep 2022 16:59:37 +0800 Message-Id: <20220916085940.89392-4-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220916085940.89392-1-zhujia.zj@bytedance.com> References: <20220916085940.89392-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" 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. The implementation of sharing blobs will be introduced in subsequent patches. Signed-off-by: Jia Zhu Reviewed-by: Jingbo Xu --- fs/erofs/fscache.c | 129 ++++++++++++++++++++++++++++++++++++++------ fs/erofs/internal.h | 9 ++++ 2 files changed, 121 insertions(+), 17 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index d3a90103abb7..9c82284e66ee 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -1,10 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2022, Alibaba Cloud + * Copyright (C) 2022, Bytedance Inc. All rights reserved. */ #include #include "internal.h" +static DEFINE_MUTEX(erofs_domain_list_lock); +static LIST_HEAD(erofs_domain_list); + static struct netfs_io_request *erofs_fscache_alloc_request(struct address_space *mapping, loff_t start, size_t len) { @@ -417,6 +421,99 @@ const struct address_space_operations erofs_fscache_access_aops = { .readahead = erofs_fscache_readahead, }; +static void erofs_fscache_domain_put(struct erofs_domain *domain) +{ + if (!domain) + return; + mutex_lock(&erofs_domain_list_lock); + if (refcount_dec_and_test(&domain->ref)) { + list_del(&domain->list); + mutex_unlock(&erofs_domain_list_lock); + fscache_relinquish_volume(domain->volume, NULL, false); + kfree(domain->domain_id); + kfree(domain); + return; + } + mutex_unlock(&erofs_domain_list_lock); +} + +static int erofs_fscache_register_volume(struct super_block *sb) +{ + struct erofs_sb_info *sbi = EROFS_SB(sb); + char *domain_id = sbi->opt.domain_id; + struct fscache_volume *volume; + char *name; + int ret = 0; + + name = kasprintf(GFP_KERNEL, "erofs,%s", + domain_id ? domain_id : sbi->opt.fsid); + if (!name) + return -ENOMEM; + + volume = fscache_acquire_volume(name, NULL, NULL, 0); + if (IS_ERR_OR_NULL(volume)) { + erofs_err(sb, "failed to register volume for %s", name); + ret = volume ? PTR_ERR(volume) : -EOPNOTSUPP; + volume = NULL; + } + + sbi->volume = volume; + kfree(name); + return ret; +} + +static int erofs_fscache_init_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct erofs_sb_info *sbi = EROFS_SB(sb); + + domain = kzalloc(sizeof(struct erofs_domain), GFP_KERNEL); + if (!domain) + return -ENOMEM; + + domain->domain_id = kstrdup(sbi->opt.domain_id, GFP_KERNEL); + if (!domain->domain_id) { + kfree(domain); + return -ENOMEM; + } + + err = erofs_fscache_register_volume(sb); + if (err) + goto out; + + domain->volume = sbi->volume; + refcount_set(&domain->ref, 1); + list_add(&domain->list, &erofs_domain_list); + sbi->domain = domain; + return 0; +out: + kfree(domain->domain_id); + kfree(domain); + return err; +} + +static int erofs_fscache_register_domain(struct super_block *sb) +{ + int err; + struct erofs_domain *domain; + struct erofs_sb_info *sbi = EROFS_SB(sb); + + mutex_lock(&erofs_domain_list_lock); + list_for_each_entry(domain, &erofs_domain_list, list) { + if (!strcmp(domain->domain_id, sbi->opt.domain_id)) { + sbi->domain = domain; + sbi->volume = domain->volume; + refcount_inc(&domain->ref); + mutex_unlock(&erofs_domain_list_lock); + return 0; + } + } + err = erofs_fscache_init_domain(sb); + mutex_unlock(&erofs_domain_list_lock); + return err; +} + struct erofs_fscache *erofs_fscache_register_cookie(struct super_block *sb, char *name, bool need_inode) { @@ -480,27 +577,19 @@ void erofs_fscache_unregister_cookie(struct erofs_fscache *ctx) int erofs_fscache_register_fs(struct super_block *sb) { + int ret; struct erofs_sb_info *sbi = EROFS_SB(sb); - struct fscache_volume *volume; struct erofs_fscache *fscache; - char *name; - - name = kasprintf(GFP_KERNEL, "erofs,%s", sbi->opt.fsid); - if (!name) - return -ENOMEM; - volume = fscache_acquire_volume(name, NULL, NULL, 0); - if (IS_ERR_OR_NULL(volume)) { - erofs_err(sb, "failed to register volume for %s", name); - kfree(name); - return volume ? PTR_ERR(volume) : -EOPNOTSUPP; - } - - sbi->volume = volume; - kfree(name); + if (sbi->opt.domain_id) + ret = erofs_fscache_register_domain(sb); + else + ret = erofs_fscache_register_volume(sb); + if (ret) + return ret; + /* acquired domain/volume will be relinquished in kill_sb() on error */ fscache = erofs_fscache_register_cookie(sb, sbi->opt.fsid, true); - /* acquired volume will be relinquished in kill_sb() */ if (IS_ERR(fscache)) return PTR_ERR(fscache); @@ -513,7 +602,13 @@ void erofs_fscache_unregister_fs(struct super_block *sb) struct erofs_sb_info *sbi = EROFS_SB(sb); erofs_fscache_unregister_cookie(sbi->s_fscache); - 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->s_fscache = NULL; sbi->volume = NULL; + sbi->domain = NULL; } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index b36850dd7813..4c11313a072f 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; }; struct erofs_dev_context { @@ -98,6 +99,13 @@ struct erofs_sb_lz4_info { u16 max_pclusterblks; }; +struct erofs_domain { + refcount_t ref; + struct list_head list; + struct fscache_volume *volume; + char *domain_id; +}; + struct erofs_fscache { struct fscache_cookie *cookie; struct inode *inode; @@ -157,6 +165,7 @@ struct erofs_sb_info { /* fscache support */ struct fscache_volume *volume; struct erofs_fscache *s_fscache; + struct erofs_domain *domain; }; #define EROFS_SB(sb) ((struct erofs_sb_info *)(sb)->s_fs_info) -- 2.20.1