Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp980195pxb; Fri, 15 Apr 2022 17:17:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDF7NoffqTkpw1SmVfOe2x6eVvyCSO2zelSrtoUDlP5R+maWYJJ0qC7vrsBavZVOLIv9zZ X-Received: by 2002:a17:902:ee13:b0:158:a3ca:3def with SMTP id z19-20020a170902ee1300b00158a3ca3defmr1206106plb.97.1650068220118; Fri, 15 Apr 2022 17:17:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650068220; cv=none; d=google.com; s=arc-20160816; b=DLedpg1GV3Vi8/qYHE+ibjodgtpTc3UZFIyKxFIs/Ut5irs/E6xo2BZfyS7QVtAgnf Amqcvh/jQDQfgFGHN92RPuFEjddDFIohfJ8X4Bow19VYVO+SqfPExXim/9nbe4X3D/dD ahVh/kN3dp74yDrpw4R9JrVijsEBWSo3P5kULuB2KwjxwDy8GDGaR7iZzJTATcsnUUeM twp4XPT8CO69ms841eLkWV7U2D46JUFkBGLaxg8XpfooFz+ivtwKyuWIlT/101HTZvb7 9IJhNoFV8uAlEIVusq1Qb2v25vQxL1s6CbjxyKPJZcC0Dsw+6nz9ELdBcylq2H/LZPzZ cTsQ== 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=rDf/IdHdyoxanRlyQkZ8ej9j10FMTVazsoCMUXnBusA=; b=xoRNGmjQazPtGadoQzvtb3Q7/Sv8jG/a6o96hAJeTRdOTG/SNsHDl2dkH2LRmuSJ2d ebQGNfA+11bKVRR58obTQxBzMu61mNgtMs36V2djmP6aAjP6X8hshXRV3xuvQcl/1lc9 FQ8pZBaQ2wd4QAuEoG2KG/feo5SPOhNX+8n5AzdFEQhW/vYMHU2xNmltgie+BTi8EDJ6 gynqjnXeZ4bbX7DeQ94YQQk3J7/1YZ47vcxMEYz76RRXcb5oFXxTl+E4srJIxHcjQpf6 5C2Hx9/CZm5RWS+lqvmF7Uun6S4gw5DKEYHULrB4vYlKHu3c4PlgklMMoo/nX4XYCfJy nzxA== 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 c10-20020a630d0a000000b00398b2fc793dsi2547184pgl.795.2022.04.15.17.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:17:00 -0700 (PDT) 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 164DDD0819; Fri, 15 Apr 2022 17:16:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353838AbiDOMkq (ORCPT + 99 others); Fri, 15 Apr 2022 08:40:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353724AbiDOMja (ORCPT ); Fri, 15 Apr 2022 08:39:30 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0FDFC8BF1; Fri, 15 Apr 2022 05:36:50 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0VA7DLWw_1650026205; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VA7DLWw_1650026205) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Apr 2022 20:36:46 +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, zhangjiachen.jaycee@bytedance.com Subject: [PATCH v9 19/21] erofs: implement fscache-based data read for inline layout Date: Fri, 15 Apr 2022 20:36:12 +0800 Message-Id: <20220415123614.54024-20-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220415123614.54024-1-jefflexu@linux.alibaba.com> References: <20220415123614.54024-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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index b799b0fe1b67..08849c15500f 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -84,6 +84,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); @@ -109,6 +136,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