Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1048856pxb; Wed, 6 Apr 2022 07:31:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlVBNscGHCU0HKTu6OMmZOeI19AqoJApjAuJtq8kLKKpKIgCHPnqMXZsurELrbK5pM2ynZ X-Received: by 2002:a05:6870:c222:b0:e2:505:f512 with SMTP id z34-20020a056870c22200b000e20505f512mr4100957oae.279.1649255491291; Wed, 06 Apr 2022 07:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255491; cv=none; d=google.com; s=arc-20160816; b=LiRUc/giTxr7Fcsf77XiGcyfBHqwgyrckRkZtmZiXJDI1GZAUmhQTlFHBZO0krAkfT cOI1xHTifzSsrHWDpMXLZbaBwlnoFo7cgmSbLMrleSNKCb1BKXRsdR7r3/Koo9/CchnF CPMA6Opb4Xy/7e5BraXtI2jw9MjjCWTRcRpqoQDAggCuyBoPye+JqJyBkjcah+VdxX6+ 0baxOPhoMpC96AvhP0nyTalS415+LbEiLimAPnNzFxIf5TBVBzFBXmyh8iVI+8MKLsun lZFCY3azfp95uhoKkUb7/v7MjnduWxwFIAx1mR0W7TlQhnEM06mP29d42dUCBanDeLf3 +adQ== 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=nkqAFQDNtyxdT5hWz0tJSogIqUwF5RYNs8Ol7YrgPfE=; b=Jx2dWSAolge3ROMrEMejmjNfdlb5jJW+X6kY9M6ZGYhPlaIDzzSaumX0qqhN80vXuj OU1Ft88NqyjnEUgSZmi/+mgU0GNdBbUynuhxm70/XWyyvplesVvZ13PF1q+4VoiFgwEY YlQ3Owgok2bnJU5qxLYjMJJEkC9xsQLwrChvbdeTW/c+09LdxG5QSKcDbBfPCsj829HR 2Z/5bFI8zWE7otLpT7YU+AouN94sWpHGaJaOZOF6NfFsHdKdypKe6IjH0uqDmw7gRCcn o/4rtkVXFBGuFlXQEGNn2bnchuBopgrujjozY0LTTRVV9w/JbHAxLG59zYdZiqWYr1de JbNA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u12-20020a056870304c00b000da716e6295si9114016oau.286.2022.04.06.07.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:31:31 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CEB1B51833D; Wed, 6 Apr 2022 05:12:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbiDFMNV (ORCPT + 99 others); Wed, 6 Apr 2022 08:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiDFMLx (ORCPT ); Wed, 6 Apr 2022 08:11:53 -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 CF216432D4C; Wed, 6 Apr 2022 00:56:41 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R201e4;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=18;SR=0;TI=SMTPD_---0V9LC88e_1649231796; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V9LC88e_1649231796) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Apr 2022 15:56: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: 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, tianzichen@kuaishou.com, fannaihao@baidu.com Subject: [PATCH v8 15/20] erofs: register fscache context for extra data blobs Date: Wed, 6 Apr 2022 15:56:07 +0800 Message-Id: <20220406075612.60298-16-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220406075612.60298-1-jefflexu@linux.alibaba.com> References: <20220406075612.60298-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no 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 Similar to the multi device mode, erofs could be mounted from one primary data blob (mandatory) and multiple extra data blobs (optional). Register fscache context for each extra data blob. Signed-off-by: Jeffle Xu --- fs/erofs/data.c | 3 +++ fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 25 +++++++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index bc22642358ec..14b64d960541 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -199,6 +199,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) map->m_bdev = sb->s_bdev; map->m_daxdev = EROFS_SB(sb)->dax_dev; map->m_dax_part_off = EROFS_SB(sb)->dax_part_off; + map->m_fscache = EROFS_SB(sb)->s_fscache; if (map->m_deviceid) { down_read(&devs->rwsem); @@ -210,6 +211,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) map->m_bdev = dif->bdev; map->m_daxdev = dif->dax_dev; map->m_dax_part_off = dif->dax_part_off; + map->m_fscache = dif->fscache; up_read(&devs->rwsem); } else if (devs->extra_devices) { down_read(&devs->rwsem); @@ -227,6 +229,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) map->m_bdev = dif->bdev; map->m_daxdev = dif->dax_dev; map->m_dax_part_off = dif->dax_part_off; + map->m_fscache = dif->fscache; break; } } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index eb37b33bce37..90f7d6286a4f 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -49,6 +49,7 @@ typedef u32 erofs_blk_t; struct erofs_device_info { char *path; + struct erofs_fscache *fscache; struct block_device *bdev; struct dax_device *dax_dev; u64 dax_part_off; @@ -482,6 +483,7 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode, #endif /* !CONFIG_EROFS_FS_ZIP */ struct erofs_map_dev { + struct erofs_fscache *m_fscache; struct block_device *m_bdev; struct dax_device *m_daxdev; u64 m_dax_part_off; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 9498b899b73b..8c7181cd37e6 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -259,15 +259,23 @@ 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_is_fscache_mode(sb)) { + err = erofs_fscache_register_cookie(sb, &dif->fscache, + dif->path, false); + if (err) + break; + } else { + 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); } - 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; @@ -701,6 +709,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data) fs_put_dax(dif->dax_dev); if (dif->bdev) blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL); + erofs_fscache_unregister_cookie(&dif->fscache); kfree(dif->path); kfree(dif); return 0; -- 2.27.0