Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5689209pxb; Thu, 20 Jan 2022 02:31:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1Tj2eydNe0AqNXdWFDR2P90K6qXcSWPxKpHxRcWudPwNe2KSed34uaTheLgiBDbIij9X+ X-Received: by 2002:a17:90a:d184:: with SMTP id fu4mr10092265pjb.26.1642674700837; Thu, 20 Jan 2022 02:31:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642674700; cv=none; d=google.com; s=arc-20160816; b=xVj6h84dAw2JcsQhibSIAOeyfECFc5FDlJkuG2F6/Ag9CpskH+dKnXKXoRVvxfWZP3 nDhSBFArK2v6GkNIU5CpoV56MKxHAUuRyEnLdVruy93gBI4X2DHTQjVEV0VOUTg3KZAT 5snqnNOaY71tWPLk4u4vorujRqv5Tjn9MXmzCl0HrJyl1fHR0bgvKWixEDFCfjSiFiGt CabPS31wD3eZsIblJqruGasDX0/YRsz6zjSdgE226KURXimRLP085O6hl84hgPcNm47a uRFSTy/RjVxlB1xI4TykucgVleI+AzKsAmKPVg24hSmLfbRv6ne4MCnGDyxmLNSkcTrc TheA== 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; bh=BLKsnbaOsOZ4RzRKbmsBxH//5kR5MsnQv7GPO7z6Hkw=; b=ZwiSh+/G174fW8RyDE1NqEyD83zxNDWDW98e7nW0ZzfrJ9u4FO035SXoofd8mchJrH Tc3Peuni1Gs9laVdSNQJ7UZokqZoJPfz2uuK3vtL5SEE8/AfBsYLvTjEbe4UkeFA7GSA C24eDedlGCVfJ0nkVaNnx9S9C5S2RulAh/GRzP16G+LhU9QRfKXncRBWVWI0gxEl8KNz 9cq7nJFgvYFWrqps2vWoMvOjiU80bLPYhMhgJ86dEzWOijZxzDQclZOSe/2ytFknXOzP 0oH9hP/YgCDAylhxMd5Wc/wYMnkNWcMWp8Aej4Y+tW2Cf40AGloxOlYsy+unf+TiNetr et+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mh3si3197945pjb.126.2022.01.20.02.31.29; Thu, 20 Jan 2022 02:31:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S243073AbiARNNW (ORCPT + 99 others); Tue, 18 Jan 2022 08:13:22 -0500 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:62358 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242879AbiARNMw (ORCPT ); Tue, 18 Jan 2022 08:12:52 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0V2C2axr_1642511556; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V2C2axr_1642511556) by smtp.aliyun-inc.com(127.0.0.1); Tue, 18 Jan 2022 21:12:37 +0800 From: Jeffle Xu To: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org Cc: 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 Subject: [PATCH v2 17/20] erofs: register cookie context for data blobs Date: Tue, 18 Jan 2022 21:12:13 +0800 Message-Id: <20220118131216.85338-18-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220118131216.85338-1-jefflexu@linux.alibaba.com> References: <20220118131216.85338-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 548f928b0ded..5d514c7b73cc 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); -- 2.27.0