Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1841283pxb; Wed, 9 Feb 2022 05:44:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8r2JSUQPbwXvL7WKvKAqsyMt2UfvusF2HId/RFaOK6DqzKLTyshCDRR9warvz2TL68Ezc X-Received: by 2002:a17:902:6b49:: with SMTP id g9mr2107804plt.111.1644414289728; Wed, 09 Feb 2022 05:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644414289; cv=none; d=google.com; s=arc-20160816; b=GbWcK3k9QIOt4cStRbFaQyOOgxxdVCi3Z/lvH8YMtmIJz842SnsxFXhaEoCZgKzFV1 1omTIZL58eELuWbKkX0MDSO/g+4GeVSWZKN2yaUz4TK2gwltoDyioFDtmcm740pcaBnK leFpDpcQYJGfU5LIDqVUZp/oGgY3dAjqm9YQQ0YMyOYxU6k+nPhiEJ4pLX9F0Ilfuz6w A/64ycnJGfUCPumlLV1aP2Tq8tahdvUB/0m/DtcUbsFyRiy1pGd0yoUDJ69KGBI75smw ery3vyt8l65Nv5Wg4M7bmKu0kdIfUyO3grD9Im/cCDKELnpLUq88RMPvI63L55WNyU7/ MQpA== 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=0BJOQOUScGT/WTk1n8lSq3+ANHPdE8lQgt3vFiCpWNQ=; b=io8O7DstPETi5nqtwdP/Ue86zaIHPt6QWJEATIxE53NOuWgYc/DtTtXJsP1AsRt9mA CHk5ct1+d+fytCddaXH2ovprYl1rAgJ+QwED/HAyiISB35dLLmWGoKxI43xuVjdjqQz7 EzyaKX/vRO8k/iFyoXduIECZGNLw7WTiZFRxTkc/4GgfWSaiMRDz9d7GZOg34ARybqWG RaZ8ltkSc5Sf8ZACequdrzKwUASi9APfgEFwmSprGYoHWZbvTtMlYFntQexvmJ4hYS3m M1kvnnjjymKnvPto+9M4wsvv+2bYfINgzGKOJwzYqfaQ+m7J11zTkGJP1dq0IYTl1jKq ZLQw== 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: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 184si16588798pgc.643.2022.02.09.05.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 05:44:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA6C6E09CF2A; Wed, 9 Feb 2022 02:26:16 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238409AbiBIGHs (ORCPT + 99 others); Wed, 9 Feb 2022 01:07:48 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:53128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235750AbiBIGBt (ORCPT ); Wed, 9 Feb 2022 01:01:49 -0500 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 1A816C05CB91; Tue, 8 Feb 2022 22:01:52 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0V3zaQTe_1644386487; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V3zaQTe_1644386487) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Feb 2022 14:01:27 +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 Subject: [PATCH v3 14/22] erofs: implement fscache-based metadata read Date: Wed, 9 Feb 2022 14:01:00 +0800 Message-Id: <20220209060108.43051-15-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220209060108.43051-1-jefflexu@linux.alibaba.com> References: <20220209060108.43051-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 This patch implements the data plane of reading metadata from bootstrap blob file over fscache. Be noted that currently it only supports the scenario where the backing file has no hole. Once it hits a hole of the backing file, erofs will fail the IO with -EOPNOTSUPP for now. The following patch will fix this issue, i.e. implementing the demand reading mode. Signed-off-by: Jeffle Xu --- fs/erofs/data.c | 11 +++++++++-- fs/erofs/fscache.c | 24 ++++++++++++++++++++++++ fs/erofs/internal.h | 3 +++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 6e2a28242453..1bff99576883 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -31,15 +31,22 @@ void erofs_put_metabuf(struct erofs_buf *buf) void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb, erofs_blk_t blkaddr, enum erofs_kmap_type type) { - struct address_space *const mapping = sb->s_bdev->bd_inode->i_mapping; + struct address_space *mapping; + struct erofs_sb_info *sbi = EROFS_SB(sb); erofs_off_t offset = blknr_to_addr(blkaddr); pgoff_t index = offset >> PAGE_SHIFT; struct page *page = buf->page; if (!page || page->index != index) { erofs_put_metabuf(buf); - page = read_cache_page_gfp(mapping, index, + if (erofs_bdev_mode(sb)) { + mapping = sb->s_bdev->bd_inode->i_mapping; + page = read_cache_page_gfp(mapping, index, mapping_gfp_constraint(mapping, ~__GFP_FS)); + } else { + page = erofs_fscache_read_cache_page(sbi->bootstrap, + index); + } if (IS_ERR(page)) return page; /* should already be PageUptodate, no need to lock page */ diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index f4aade711664..a29d2ecff58b 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -42,9 +42,33 @@ static int erofs_fscache_read_page(struct fscache_cookie *cookie, return ret; } +static int erofs_fscache_readpage_blob(struct file *data, struct page *page) +{ + int ret; + struct erofs_fscache_context *ctx = + (struct erofs_fscache_context *)data; + + ret = erofs_fscache_read_page(ctx->cookie, page, page_offset(page)); + if (ret) + SetPageError(page); + else + SetPageUptodate(page); + + unlock_page(page); + return ret; +} + static const struct address_space_operations erofs_fscache_blob_aops = { + .readpage = erofs_fscache_readpage_blob, }; +struct page *erofs_fscache_read_cache_page(struct erofs_fscache_context *ctx, + pgoff_t index) +{ + DBG_BUGON(!ctx->inode); + return read_mapping_page(ctx->inode->i_mapping, index, ctx); +} + static int erofs_fscache_init_cookie(struct erofs_fscache_context *ctx, char *path) { diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 277dcd5888ea..fca706cfaf72 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -633,6 +633,9 @@ struct erofs_fscache_context *erofs_fscache_get_ctx(struct super_block *sb, char *path, bool need_inode); void erofs_fscache_put_ctx(struct erofs_fscache_context *ctx); +struct page *erofs_fscache_read_cache_page(struct erofs_fscache_context *ctx, + pgoff_t index); + #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ #endif /* __EROFS_INTERNAL_H */ -- 2.27.0