Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2739347pxp; Tue, 8 Mar 2022 00:22:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJybjJKPQoYEIVulhvaPZFBPsQ2emM/3rAe5j1L/ZdK5gRrZ3/ucaDAZHO8WMnM16m3HEtyt X-Received: by 2002:a05:6a00:1816:b0:4f3:404f:1acb with SMTP id y22-20020a056a00181600b004f3404f1acbmr17219589pfa.17.1646727727612; Tue, 08 Mar 2022 00:22:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646727727; cv=none; d=google.com; s=arc-20160816; b=OHvfYx+o/c1dzMdNgN5b9Mp9V5Oy4qrFPHCvcLDlZugcILlPMKJWIHSVdrQJqLoMmj zgsG9JC+ACytFdDkvByUABm7AtBv4D1rRdtTlg+jiqRAXWHf8NH+ztobe01ul5AroZOW gBEXW9xzhXwZMv4f3lUyG8pO36IBZMwJhpUQOXVcTs6ahjWBOqo05Dcci7rM+YksyH6f SMlvW8IMTvh93aGuao3F47mngUl2JtIoyJ1yyVleJun94OjaavktvlIeILI2k1EYgj3d +yAzPriH6JRsigWoaHQnrSefKW2G+g4FpCIPqL2PiZ5cmJ3cUI4WXBXqKL7eYs5ROL8x M8iQ== 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=ETt91NAYNH8U4lCAJRqiD/GGs1oTo8iePbF1ZeAsIK4=; b=oVOtX+9wGiHgCgCiF31sdGKhj676oniQJkV0xts+X2V/5sAPP3zNE6BASZG+PGvTi4 okykPqIU+K3SDjnxA1hiEHufckybu8xJ/aJqvqAt4TddxQG1wuIHEXKeW5U/K3vMbcY4 Sw9f4gy+A3SbRF8Q6awT4TnPukpVR6dLZQ9PeCbUZlw8GVk4cY0rYNbFJWU2OtfE1NwF CwLoom74CbwxiU3+Ux2RzIBT/8zUcn9yH94iDJFFyYWqWeSEKgDfWc3Qkk1ctv754Kt+ KaNhe3Jz9t9Sv7kEv8SbZLQ3kxBErTVExcOlw3lSMduygZ/d2BdA0QzCdZjXhl5ZgUs3 N6kQ== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bm10-20020a656e8a000000b0037c7f968cdasi15047398pgb.182.2022.03.08.00.21.53; Tue, 08 Mar 2022 00:22:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S242446AbiCGMf3 (ORCPT + 99 others); Mon, 7 Mar 2022 07:35:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242428AbiCGMfC (ORCPT ); Mon, 7 Mar 2022 07:35:02 -0500 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2356424B2; Mon, 7 Mar 2022 04:33:34 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=15;SR=0;TI=SMTPD_---0V6VlXz9_1646656410; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V6VlXz9_1646656410) by smtp.aliyun-inc.com(127.0.0.1); Mon, 07 Mar 2022 20:33:31 +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 v4 17/21] erofs: implement fscache-based data read for inline layout Date: Mon, 7 Mar 2022 20:33:01 +0800 Message-Id: <20220307123305.79520-18-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220307123305.79520-1-jefflexu@linux.alibaba.com> References: <20220307123305.79520-1-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham 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 data from bootstrap blob file over fscache for inline layout. For the heading non-inline part, the data plane for non-inline layout is resued, while only the tail packing part needs special handling. Signed-off-by: Jeffle Xu --- fs/erofs/fscache.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index ff69698948ad..4da148cc4484 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -85,8 +85,9 @@ static int erofs_fscache_readpage_noinline(struct page *page, { struct fscache_cookie *cookie = fsmap->m_ctx->cookie; /* - * 1) For FLAT_PLAIN layout, the output map.m_la shall be equal to o_la, - * and the output map.m_pa is exactly the physical address of o_la. + * 1) For FLAT_PLAIN and FLAT_INLINE (the heading non tail packing part) + * layout, the output map.m_la shall be equal to o_la, and the output + * map.m_pa is exactly the physical address of o_la. * 2) For CHUNK_BASED layout, the output map.m_la is rounded down to the * nearest chunk boundary, and the output map.m_pa is actually the * physical address of this chunk boundary. So we need to recalculate @@ -97,6 +98,40 @@ static int erofs_fscache_readpage_noinline(struct page *page, return erofs_fscache_read_page(cookie, page, start); } +static int erofs_fscache_readpage_inline(struct page *page, + struct erofs_fscache_map *fsmap) +{ + struct inode *inode = page->mapping->host; + struct super_block *sb = inode->i_sb; + struct erofs_buf buf = __EROFS_BUF_INITIALIZER; + erofs_blk_t blknr; + size_t offset, len; + void *src, *dst; + + /* + * For inline (tail packing) layout, the offset may be non-zero, which + * can be calculated from corresponding physical address directly. + * Currently only flat layout supports inline (FLAT_INLINE), and the + * output map.m_pa is exactly the physical address of o_la in this case. + */ + offset = erofs_blkoff(fsmap->m_pa); + blknr = erofs_blknr(fsmap->m_pa); + len = fsmap->m_llen; + + src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP); + if (IS_ERR(src)) + return PTR_ERR(src); + + dst = kmap(page); + memcpy(dst, src + offset, len); + memset(dst + len, 0, PAGE_SIZE - len); + kunmap(page); + + erofs_put_metabuf(&buf); + + return 0; +} + static int erofs_fscache_do_readpage(struct page *page) { struct inode *inode = page->mapping->host; @@ -126,8 +161,12 @@ static int erofs_fscache_do_readpage(struct page *page) if (ret) return ret; + if (map.m_flags & EROFS_MAP_META) + return erofs_fscache_readpage_inline(page, &fsmap); + switch (vi->datalayout) { case EROFS_INODE_FLAT_PLAIN: + case EROFS_INODE_FLAT_INLINE: case EROFS_INODE_CHUNK_BASED: return erofs_fscache_readpage_noinline(page, &fsmap); default: -- 2.27.0