Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp581432pxb; Thu, 31 Mar 2022 12:07:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydFA+2FJAI7O7J3/B/+VRLSw7XGw+m7c256VV/F/8tBi84G9EfJ+xD8Umcqh/LwvO3RACo X-Received: by 2002:a05:6402:27d2:b0:419:1a3d:442b with SMTP id c18-20020a05640227d200b004191a3d442bmr17305661ede.409.1648753644430; Thu, 31 Mar 2022 12:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648753644; cv=none; d=google.com; s=arc-20160816; b=CLjehbubfqeBZAsfucPirUggvroV7j1u5HXk3cKa+cF8XXoONAQ8cyOvF87ErBJjSG udLBVx2X/S96ct9tjjlFfWbvsLlA1ig2Ea/RrtawQyF5N7zPUUruwriOUWmlNeyvihg0 J6cUSeQ6MPnRxF6Y1vXCxnDM7lG2rQYlEZMpZcpcslB4TzQZ3gcysKPGSOp+tN2yPENO OIUU/ABNBhbyac8UptoSig0PjZNV4cEuVY2KWFzt3RG6nbsM3Iuk3aLye5aE131NXogD P93sEXDinBqv+sVo2HKh01vR4kCsmtq7CCBKulmXJVMB+UyCIVa0s68Ebb04WSMd7U8f SxIg== 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=qasm8vXJ5SgdZACey9Hq5raXuPyBsqBo7fZ0lY/20Xk=; b=ee4TdfBmPlBahpYp2ZVComhUghJT6TD+R7SnfD9d483aW3t+XjGIQgifNnjPZr29AO rmij0CWNcIkcIEl/mjdU5xN3vp/uRSG1z7QUfbVEF6XodHaSzdsExAFwvUwUeQx9hDfz LCQZEVNRPDu1ZKvWON1OfvNaALBPBq4cp+WLqg0b64MNi2O/pu9LYC7/8mHiaynGWZCV +yY4WlWCzGF7BWWLSS10bPhzKA4UimwdzMdmVGii20ZhzPkrOHAGytaq7zMhQRlQJQH3 2gDUjf+XQpJ3FT3bbqoFb53BJIm4ev/nmoCB7kDfksWFZ11bp/J6LNwwFBDAS/NjVi0/ e0wQ== 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 p12-20020a170906a00c00b006df76385c4asi264143ejy.234.2022.03.31.12.06.58; Thu, 31 Mar 2022 12:07:24 -0700 (PDT) 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 S235226AbiCaMBM (ORCPT + 99 others); Thu, 31 Mar 2022 08:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235527AbiCaMA1 (ORCPT ); Thu, 31 Mar 2022 08:00:27 -0400 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43910DFDE; Thu, 31 Mar 2022 04:58:24 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V8j1pAE_1648727899; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V8j1pAE_1648727899) by smtp.aliyun-inc.com(127.0.0.1); Thu, 31 Mar 2022 19:58:20 +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 v7 17/19] erofs: implement fscache-based data read for inline layout Date: Thu, 31 Mar 2022 19:57:51 +0800 Message-Id: <20220331115753.89431-18-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220331115753.89431-1-jefflexu@linux.alibaba.com> References: <20220331115753.89431-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 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 --- fs/erofs/fscache.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 65de1c754e80..d32cb5840c6d 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -60,6 +60,40 @@ 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 inode *inode = folio_file_mapping(folio)->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. + */ + 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); + + DBG_BUGON(folio_size(folio) != PAGE_SIZE); + + dst = kmap(folio_page(folio, 0)); + memcpy(dst, src + offset, len); + memset(dst + len, 0, PAGE_SIZE - len); + kunmap(folio_page(folio, 0)); + + erofs_put_metabuf(&buf); + + return 0; +} + static int erofs_fscache_readpage(struct file *file, struct page *page) { struct folio *folio = page_folio(page); @@ -85,6 +119,12 @@ static int erofs_fscache_readpage(struct file *file, struct page *page) goto out_uptodate; } + /* inline readpage */ + if (map.m_flags & EROFS_MAP_META) { + ret = erofs_fscache_readpage_inline(folio, &map); + goto out_uptodate; + } + /* no-inline readpage */ mdev = (struct erofs_map_dev) { .m_deviceid = map.m_deviceid, -- 2.27.0