Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1048190pxb; Wed, 6 Apr 2022 07:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnIefsKQAA2echJoPmS6v6e3D+fVQASieHZnBYwxps8Eed9zH7yWQ+xP/w7GxdDQ1YPv3t X-Received: by 2002:a17:902:f789:b0:156:5f56:ddff with SMTP id q9-20020a170902f78900b001565f56ddffmr9098884pln.116.1649255439340; Wed, 06 Apr 2022 07:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649255439; cv=none; d=google.com; s=arc-20160816; b=bAa/hbrqbKd1pY0HnpioNUPz/pVE/NpkX1ry5qcoFIzBsaKZ+rhZx7UGYbN/4AkhIN 4v9ZEi64j3eFCUhLeMnpDq/PUxQTPFAg/GKvZyBj9AJN3u9THvJKaNVYMfPD8UrFiYOO tqSuA2d2ZMdV2Mcu2hXqv0uUSQU7iv56nb+OkLgV5aXF0rLgj3gyE2aX/ROBseufV+Az tJOjRxbo/KX5oNcwMNmVg88zhncAsqea4LjkaizhRHvum3HBwEO2i9cHvmxGffvjoUoi uPJciTHsR3PWUsBGQ353JLsXCgaPA+Vzew5PfBu9c7l/zm5jUzJUG45hA9lL6DUWoLu0 vdyg== 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=ViCSv7HmaDbGJ6X8QCMDO66ql8wNajHjXlyFgMxDJQI=; b=nUp+BF8FVgqn13y77q+aoC/9jvT6OVDW3ii7ail9zY13y+8zKSA4jZjPVo+VbCzG0Z KNN4tq5D/+/q+4UTIS0cqW8G1cZTAB/QkXftRK+fPkxJwfy5OVJFLCPpmPJbnSatYRig R4cKxarv2wlHmWyzewaY9sUEE5omikC1eCCu30ABYCkRWlbqk8Oug3786edr3yZq/m/B IFZrTfzDf5mAuPeAbGV/c8LiEu/gVxyB9conxqUOEQ7sQsKlzkjNncHaO4OZ+M9Uriiu tqta9nM7I6bOUa/jTuy+9oBq87X7IzXBfAGxwFYibrTo0jod4WE5137hGRvhlLGb/jAp iSGw== 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 a18-20020a170902ecd200b00156999258cdsi11189707plh.9.2022.04.06.07.30.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 07:30:39 -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 724ED508EE4; Wed, 6 Apr 2022 05:11:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231508AbiDFMMI (ORCPT + 99 others); Wed, 6 Apr 2022 08:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230015AbiDFMLw (ORCPT ); Wed, 6 Apr 2022 08:11:52 -0400 Received: from out30-56.freemail.mail.aliyun.com (out30-56.freemail.mail.aliyun.com [115.124.30.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED063425E30; Wed, 6 Apr 2022 00:56:38 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R591e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=18;SR=0;TI=SMTPD_---0V9Ko7Vp_1649231793; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V9Ko7Vp_1649231793) by smtp.aliyun-inc.com(127.0.0.1); Wed, 06 Apr 2022 15:56:34 +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 13/20] erofs: add erofs_fscache_read_folios() helper Date: Wed, 6 Apr 2022 15:56:05 +0800 Message-Id: <20220406075612.60298-14-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 Add erofs_fscache_read_folios() helper reading from fscache. It supports on-demand read semantics. That is, it will make the backend prepare for the data when cache miss. Once data ready, it will reinitiate a read from the cache. This helper can then be used to implement .readpage()/.readahead() of on-demand read semantics. Signed-off-by: Jeffle Xu --- fs/erofs/fscache.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c index 1c88614203d2..d38a6efc8e50 100644 --- a/fs/erofs/fscache.c +++ b/fs/erofs/fscache.c @@ -5,6 +5,35 @@ #include #include "internal.h" +/* + * Read data from fscache and fill the read data into page cache described by + * @start/len, which shall be both aligned with PAGE_SIZE. @pstart describes + * the start physical address in the cache file. + */ +static int erofs_fscache_read_folios(struct fscache_cookie *cookie, + struct address_space *mapping, + loff_t start, size_t len, + loff_t pstart) +{ + struct netfs_cache_resources cres; + struct iov_iter iter; + int ret; + + memset(&cres, 0, sizeof(cres)); + + ret = fscache_begin_read_operation(&cres, cookie); + if (ret) + return ret; + + iov_iter_xarray(&iter, READ, &mapping->i_pages, start, len); + + ret = fscache_read(&cres, pstart, &iter, + NETFS_READ_HOLE_ONDEMAND, NULL, NULL); + + fscache_end_operation(&cres); + return ret; +} + static const struct address_space_operations erofs_fscache_meta_aops = { }; -- 2.27.0