From patchwork Wed Mar 16 13:17:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 12782676 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 44E3FC433FE for ; Wed, 16 Mar 2022 13:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356361AbiCPNTy (ORCPT ); Wed, 16 Mar 2022 09:19:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356323AbiCPNTn (ORCPT ); Wed, 16 Mar 2022 09:19:43 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E22465E8; Wed, 16 Mar 2022 06:17:55 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R161e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0V7MlTCQ_1647436671; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V7MlTCQ_1647436671) by smtp.aliyun-inc.com(127.0.0.1); Wed, 16 Mar 2022 21:17:52 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: torvalds@linux-foundation.org, gregkh@linuxfoundation.org, willy@infradead.org, linux-fsdevel@vger.kernel.org, joseph.qi@linux.alibaba.com, bo.liu@linux.alibaba.com, tao.peng@linux.alibaba.com, gerry@linux.alibaba.com, eguan@linux.alibaba.com, linux-kernel@vger.kernel.org, luodaowen.backend@bytedance.com Subject: [PATCH v5 19/22] erofs: register cookie context for data blobs Date: Wed, 16 Mar 2022 21:17:20 +0800 Message-Id: <20220316131723.111553-20-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220316131723.111553-1-jefflexu@linux.alibaba.com> References: <20220316131723.111553-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Similar to the multi device mode, erofs could be mounted from multiple blob files (one bootstrap blob file and optional multiple data blob files). In this case, each device slot contains the path of corresponding data blob file. This patch registers corresponding cookie context for each data blob file. Signed-off-by: Jeffle Xu --- fs/erofs/internal.h | 1 + fs/erofs/super.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index f94a921eff98..d93de8b6ff44 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -53,6 +53,7 @@ struct erofs_device_info { struct block_device *bdev; struct dax_device *dax_dev; u64 dax_part_off; + struct erofs_fscache_context *ctx; u32 blocks; u32 mapped_blkaddr; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 8c5783c6f71f..f058a04a00c7 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -250,6 +250,7 @@ static int erofs_init_devices(struct super_block *sb, down_read(&sbi->devs->rwsem); idr_for_each_entry(&sbi->devs->tree, dif, id) { struct block_device *bdev; + struct erofs_fscache_context *ctx; ptr = erofs_read_metabuf(&buf, sb, erofs_blknr(pos), EROFS_KMAP); @@ -259,15 +260,24 @@ static int erofs_init_devices(struct super_block *sb, } dis = ptr + erofs_blkoff(pos); - bdev = blkdev_get_by_path(dif->path, - FMODE_READ | FMODE_EXCL, - sb->s_type); - if (IS_ERR(bdev)) { - err = PTR_ERR(bdev); - break; + if (erofs_bdev_mode(sb)) { + bdev = blkdev_get_by_path(dif->path, + FMODE_READ | FMODE_EXCL, + sb->s_type); + if (IS_ERR(bdev)) { + err = PTR_ERR(bdev); + break; + } + dif->bdev = bdev; + dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off); + } else { + ctx = erofs_fscache_get_ctx(sb, dif->path, false); + if (IS_ERR(ctx)) { + err = PTR_ERR(ctx); + break; + } + dif->ctx = ctx; } - dif->bdev = bdev; - dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off); dif->blocks = le32_to_cpu(dis->blocks); dif->mapped_blkaddr = le32_to_cpu(dis->mapped_blkaddr); sbi->total_blocks += dif->blocks; @@ -694,6 +704,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data) { struct erofs_device_info *dif = ptr; + erofs_fscache_put_ctx(dif->ctx); fs_put_dax(dif->dax_dev); if (dif->bdev) blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL);