Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp44589pxh; Thu, 7 Apr 2022 13:29:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx64n5L4CLw+C9lljozPkCLJq28oCVPUBWIOMV5aEWPXPXNNYYHP+iYoP5TsEHa2hO5Vvwx X-Received: by 2002:a17:90a:5412:b0:1cb:f72:f2ff with SMTP id z18-20020a17090a541200b001cb0f72f2ffmr6057467pjh.57.1649363342757; Thu, 07 Apr 2022 13:29:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363342; cv=none; d=google.com; s=arc-20160816; b=Oram34jA3var9zrDJ7TSN65EgVwubDWUz5DhigidAQ83DBxGa6fAALj6S6Ip1ASMDa 0MqrG6OTxjSxZ4vJmnAwAUS5PQINf744Oop5QttEnVme4YFFqikbR0kJKIWZxsTCsHfB KW2KG/08wrU36Iab+PmJjzf4tfYY3q/bVVZm7hg/jwp6t4C4n4poigPl4ZpGH82g6znX ds9ueSU2+5UHQsRX5VvCYgKeVUGol/rClcOABNXPUorQ/4jY6Bg8x+MzpAXB9RYqNV89 oARwma/mWMnsrc2ieWc1aohImV/6tKJuQxZDldk0nMNx9S/2XYHAVCjQjcEslc1wtzbx AmPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=pbDNomxJDGQ6n5kt0nmzKlkTCOiIg2BXbTID64Vuo5M=; b=iB7B//HLvKzj61UaGd/klTXVlAAKq4w+1h3p0WS6E4QRkeNqe0EyW+Ty7S4rG5r8LH IhjpuIcVu/4/8EBBKzlJR+uTg7N4hbLSyLNxABhTps4ZolK+dTtq997Azs44jm4+lGf5 6xhUI/O1EV2FFydOAWmatDdvHOUBOFOuKq2/rsUj4XDoKGycTn6altLT9sk+QZN4HdWF nW5J2qmchcxaxKge0WdK8cWIUmZ6U/Wu5tNc1dUFKLC+d227UAvuvJXblUu3V8BNHwIZ qs8I/o+/OBpAGMGZ6r6nACjMq5ivO9TCSYrfQqDzeIXuEvmpeRfSD47XvIcz/8NByyA1 n3ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y6HvBPLW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c16-20020aa78e10000000b004fa3a8e0057si6650071pfr.270.2022.04.07.13.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:29:02 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y6HvBPLW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 15D4136AE59; Thu, 7 Apr 2022 12:43:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343818AbiDGOIG (ORCPT + 99 others); Thu, 7 Apr 2022 10:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343828AbiDGOHj (ORCPT ); Thu, 7 Apr 2022 10:07:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DEBCE0AEF; Thu, 7 Apr 2022 07:05:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 96B7FB82777; Thu, 7 Apr 2022 14:05:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EAE5C385A7; Thu, 7 Apr 2022 14:05:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649340336; bh=h/ekb5QtQwdaE1nuKp1Ak9uQSLC0j8BMRSRfXRUcEK0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y6HvBPLWrJ06i4vlOTF8BnZ3iqItHqw/nsH/nNnEwo+N32fsRbK0SKgF5EwQsMH+9 nvPFZqZ7FMctoEz4BWfpfOwdcQGV/g66hr+wb+2qpXqSeo5pU2cJGRZYxCHMNEfndq UEG9V0T3FTni5dw/r0Jd55uxSPQIfnPqxSx60c+bSgkaxtA8yILAntPnPoAS5tvbSM uOSoGF+r+t/Lzp7Y/LuPML8bXRgjF+voyEegUOCTM4Ku8YeS0zqz18A7fwukVcOZ69 Z4TNP76n/xxzt9umz8R5oYeVg/FxuVoELTWeU1AKtq222UQfTpr+II4qi1xvboJoHF lCyCEDNDgga8g== Date: Thu, 7 Apr 2022 22:05:26 +0800 From: Gao Xiang To: Jeffle Xu Cc: dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, 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: Re: [PATCH v8 13/20] erofs: add erofs_fscache_read_folios() helper Message-ID: Mail-Followup-To: Jeffle Xu , dhowells@redhat.com, linux-cachefs@redhat.com, xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org, 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 References: <20220406075612.60298-1-jefflexu@linux.alibaba.com> <20220406075612.60298-14-jefflexu@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220406075612.60298-14-jefflexu@linux.alibaba.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Wed, Apr 06, 2022 at 03:56:05PM +0800, Jeffle Xu wrote: > 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 Reviewed-by: Gao Xiang Thanks, Gao Xiang > --- > 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 >