Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1050345pxb; Wed, 6 Apr 2022 07:33:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfAIQEoiVdcsPfSD9UhaL3lr5BaW6Y1m1n+Nxjd7rwn1bIESY+yvv0Xqa4S7DhCei5bfM9 X-Received: by 2002:a63:d456:0:b0:399:4c5a:2682 with SMTP id i22-20020a63d456000000b003994c5a2682mr7234069pgj.573.1649255621448; Wed, 06 Apr 2022 07:33:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255621; cv=none; d=google.com; s=arc-20160816; b=cjobtkOo1R3u1z9ZU/ADcE+4yAf8cYUKTxT8FSC8+EWElXiyK1nsMrhgTeYbeu1b0X 6l+9NhCBczYSiG4jw0/ZXUgACEu7BPykn9TUNNtptOaNAJ5z/0FQbKEjioRZ1p4k/tnJ 8+YM3Jj3GyvY99I0d6hrUFCTebKwweIWWzYpHoR2yiHA12fXXuNyGM6zvLVENzOyWAic LVles282c0zYyC1n1h4yDtNhzif4OUNekbv9Y8+WC9B9aR2b50Wp08XdLHqGCkzF5Vra 0MWH9VfB9YWGWUU/r0LT7Rr831sRBmn/mTOr/9cddVRoSwnUM9qE4ImXH/Htyq4dpQnp nV3Q== 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=afjnaWYEU5GbluNM/OQcijzhGqDsAQeaWxaAApMZcckq/26z5GnmlqyTyMzDFzrqM2 GmTaYSK3P9XJRZVRbycu4yoXAUQlIf8HJisgIXGg0YlnKQPgLI4St1ov1h8uCVWmNiHj KoUn44OPADcTpAJryJ44prQ4/ByJGLTbkEbMvyf62HRT0yHnuyh7xrxHigYJ8ChTHTd3 bjwJfCes0XfJnU5tIJw6o5ALI2tBsmIK1FJDfbGAackMAIGKpgdXQsug6WONFdP+Ohb8 Tc1jEJ/J0vV9iE8oIX6VzRKL2Rb4hnOMtMsuRchDnURDVQCIFmaoUS+vD82VR6sioFDY bu0Q== 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 m15-20020a170902db0f00b00156a181ddb9si10917955plx.399.2022.04.06.07.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:33:41 -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 3CF9C517A76; Wed, 6 Apr 2022 05:15:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232515AbiDFMQF (ORCPT + 99 others); Wed, 6 Apr 2022 08:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiDFMOi (ORCPT ); Wed, 6 Apr 2022 08:14:38 -0400 Received: from out30-42.freemail.mail.aliyun.com (out30-42.freemail.mail.aliyun.com [115.124.30.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C666C43370A; Wed, 6 Apr 2022 00:56:45 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R611e4;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_---0V9L3PF9_1649231800; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V9L3PF9_1649231800) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Apr 2022 15:56:41 +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 18/20] erofs: implement fscache-based data read for inline layout Date: Wed, 6 Apr 2022 15:56:10 +0800 Message-Id: <20220406075612.60298-19-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 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