Received: by 2002:a19:651b:0:0:0:0:0 with SMTP id z27csp3762232lfb; Mon, 9 May 2022 03:30:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcq9EbWEwVHCgiZ42SlQrxru5FE47kApllREj7ZN0cHDt2Fy3I4a0Hwn7/KzFNu3cnAknz X-Received: by 2002:a63:455e:0:b0:3c6:270f:cec4 with SMTP id u30-20020a63455e000000b003c6270fcec4mr12558844pgk.417.1652092230505; Mon, 09 May 2022 03:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652092230; cv=none; d=google.com; s=arc-20160816; b=qIoYzRJikdoVdwc/IzB1JKcM67yAzhQKqQ/FSAXhFqCak0Sqs11Cb8wqSoLhVtmGnm CBax3jSFeRpJDu+oDFYEy88pS/EUGSnb0z7YZAfDZb6//UZ+tV3VXXXXnKtJXRGQXrLT Nf9p9Ki3iQUPSczoq2L6g6mNzFiFK/ui39GhKVR7eFaCwelYRFhsDwUY4mtZnKEdtmBB Yp1aKdtR5tbV+ShqfrZmpHg6zKN1XiT/TlijXSgET1A89Pv4JIb+aWPcVo3yvAX/j4j4 55N65mcg/5Xux1UmdyR/bseblI8mqw0idYdP/34qVK33SjVhjCBpvDpsDp6smmKTHcp3 AR5g== 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=/58VS6thC34YOsAi4LCq2gyNHFcsCCVyvwTFB3t5NiM=; b=xdLdfGZjaexRQfQ/XaVs1zic9AnyG0/tck/CEXSDLJnAOEqKIWu7nhQB1+/sNL3EOI fQipCQb6Zv8ZK9dVGRqs6x/RXtC4DRg3SuXBiYiDMQ6kX/CHsuhAcKq4JqWV5TUZrHV4 8fTkyEz52sCLOjKXQgzWTVWIY3Mu59aIRNOekNQGE2YSmqo83D9/zA+fR9N7UxMzxaNa L87gpdB3qaToMPz7aKuJMKIwacEWVxgIL+Bffd2q0ubu95WTfW6xIYMaMUTjkxQZ70ac 8zdS+jRrajXHbxp50gAIDSE6Gt+rCROCs1elNTn0TMT4B3xICySj16rcbK4InBL7nvi6 4U5w== 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 16-20020a630710000000b003c28293e086si13579669pgh.622.2022.05.09.03.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 03:30:30 -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 A9B7F4EDC8; Mon, 9 May 2022 03:01:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236628AbiEIHxU (ORCPT + 99 others); Mon, 9 May 2022 03:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235822AbiEIHpB (ORCPT ); Mon, 9 May 2022 03:45:01 -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 AC32C167C5; Mon, 9 May 2022 00:41:05 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R711e4;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=20;SR=0;TI=SMTPD_---0VCfUcRK_1652082058; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VCfUcRK_1652082058) by smtp.aliyun-inc.com(127.0.0.1); Mon, 09 May 2022 15:40:59 +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, yinxin.x@bytedance.com, zhangjiachen.jaycee@bytedance.com, zhujia.zj@bytedance.com Subject: [PATCH v11 19/22] erofs: implement fscache-based data read for inline layout Date: Mon, 9 May 2022 15:40:25 +0800 Message-Id: <20220509074028.74954-20-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220509074028.74954-1-jefflexu@linux.alibaba.com> References: <20220509074028.74954-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 Implement the data plane of reading data from data blobs over fscache for inline layout. For the heading non-inline part, the data plane for non-inline layout is reused, while only the tail packing part needs special handling. Signed-off-by: Jeffle Xu Reviewed-by: Gao Xiang --- fs/erofs/fscache.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index b3af72af7c88..5b779812a5ee 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -83,6 +83,33 @@ static int erofs_fscache_meta_readpage(struct file *data, struct page *page) return ret; } +static int erofs_fscache_readpage_inline(struct folio *folio, + struct erofs_map_blocks *map) +{ + struct super_block *sb = folio_mapping(folio)->host->i_sb; + struct erofs_buf buf = __EROFS_BUF_INITIALIZER; + erofs_blk_t blknr; + size_t offset, len; + void *src, *dst; + + /* For tail packing layout, the offset may be non-zero. */ + offset = erofs_blkoff(map->m_pa); + blknr = erofs_blknr(map->m_pa); + len = map->m_llen; + + src = erofs_read_metabuf(&buf, sb, blknr, EROFS_KMAP); + if (IS_ERR(src)) + return PTR_ERR(src); + + dst = kmap_local_folio(folio, 0); + memcpy(dst, src + offset, len); + memset(dst + len, 0, PAGE_SIZE - len); + kunmap_local(dst); + + erofs_put_metabuf(&buf); + return 0; +} + static int erofs_fscache_readpage(struct file *file, struct page *page) { struct folio *folio = page_folio(page); @@ -108,6 +135,11 @@ static int erofs_fscache_readpage(struct file *file, struct page *page) goto out_uptodate; } + if (map.m_flags & EROFS_MAP_META) { + ret = erofs_fscache_readpage_inline(folio, &map); + goto out_uptodate; + } + mdev = (struct erofs_map_dev) { .m_deviceid = map.m_deviceid, .m_pa = map.m_pa, -- 2.27.0