Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2034628pxp; Fri, 18 Mar 2022 01:19:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz03BeAmo94ewL8g2E5toWxBQaadEEfKIglwEWfdERZWgOZi2r2aS0/FLyLld0795UXfsv0 X-Received: by 2002:a17:907:7205:b0:6df:b8c9:e68e with SMTP id dr5-20020a170907720500b006dfb8c9e68emr1280695ejc.507.1647591587517; Fri, 18 Mar 2022 01:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647591587; cv=none; d=google.com; s=arc-20160816; b=s4i1hdpDEP5QzaCb1Pkq3wgJYxBICvfjndKowErV2diz8zjplbwxK0/c8bTqEe+fsA Buvv6kYNWwgAB27oNjxvYrahfIqpWZun1Uh3Y5WbtK+y8vhssM0RLKhhgKXgb6cONm6z PcgB86KuHkU1qHRVdZ581/ZSFTz7b2okiG74BOD5zIFRTDMYUWpjDAAqoFRFNDqFMO2w JnsXHy0PMgbfRJqmlY/DtHM5ph8klk7tTaxf4GB0VJPXnBgQggt+RDCIyStcdUITB8I4 27F4Cv/Znx35+qMGHpe1vwYDSUDGFuZnX70S+iKKle8Xul3YYlKO5NFMpo1/s/wQkqBK gwng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=TRzbLoQe9pHDkjChqmB/XkfU0Y/sXeeeV+fb64OVShI=; b=j4qka9B5upi8Dye4842CqmWhYYhVF54MdeToeQKkqdTbZkKrLLh4aQXl3cwLf5+cdx QCpf7nsiS/sVjzlRK+LRXtl88lXnCENHd3uLZQfOamuPuOdz1OQzjLYiyfUyh9d44S1n PK5YjAklEzgjhyjjzXMB9xjE3gCX9C2HvaOy+haeHx63Wl3yF8xfJti33cEK/+/fwEEc So6f/KUFJBq8csMacWN2ODhl/TrIyEN+OjNS+7SBIiC6hsEDU+HEvmc6GrM8r7zVYg1o /mJE54EuKFLgmZ40b+iurO7dLtrk3l5LVFZU511WlqOAZitnjH9AD0Aj6RiAMHAVUdcj Rgrw== 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 n12-20020a17090673cc00b006dfb1125e28si885183ejl.283.2022.03.18.01.19.21; Fri, 18 Mar 2022 01:19:47 -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 S232549AbiCRFn1 (ORCPT + 99 others); Fri, 18 Mar 2022 01:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbiCRFnZ (ORCPT ); Fri, 18 Mar 2022 01:43:25 -0400 Received: from out199-11.us.a.mail.aliyun.com (out199-11.us.a.mail.aliyun.com [47.90.199.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E6032CCA08; Thu, 17 Mar 2022 22:42:05 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R261e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0V7V4qT._1647582119; Received: from 30.225.24.52(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0V7V4qT._1647582119) by smtp.aliyun-inc.com(127.0.0.1); Fri, 18 Mar 2022 13:42:00 +0800 Message-ID: Date: Fri, 18 Mar 2022 13:41:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v5 21/22] erofs: implement fscache-based data readahead Content-Language: en-US To: 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 References: <20220316131723.111553-1-jefflexu@linux.alibaba.com> <20220316131723.111553-22-jefflexu@linux.alibaba.com> From: JeffleXu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,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 On 3/17/22 1:22 PM, Gao Xiang wrote: > On Wed, Mar 16, 2022 at 09:17:22PM +0800, Jeffle Xu wrote: >> This patch implements fscache-based data readahead. Also registers an >> individual bdi for each erofs instance to enable readahead. >> >> Signed-off-by: Jeffle Xu >> --- >> fs/erofs/fscache.c | 153 +++++++++++++++++++++++++++++++++++++++++++++ >> fs/erofs/super.c | 4 ++ >> 2 files changed, 157 insertions(+) >> >> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c >> index 82c52b6e077e..913ca891deb9 100644 >> --- a/fs/erofs/fscache.c >> +++ b/fs/erofs/fscache.c >> @@ -10,6 +10,13 @@ struct erofs_fscache_map { >> u64 m_llen; >> }; >> >> +struct erofs_fscahce_ra_ctx { > > typo, should be `erofs_fscache_ra_ctx' Oops. Thanks. > >> + struct readahead_control *rac; >> + struct address_space *mapping; >> + loff_t start; >> + size_t len, done; >> +}; >> + >> static struct fscache_volume *volume; >> >> /* >> @@ -199,12 +206,158 @@ static int erofs_fscache_readpage(struct file *file, struct page *page) >> return ret; >> } >> >> +static inline size_t erofs_fscache_calc_len(struct erofs_fscahce_ra_ctx *ractx, >> + struct erofs_fscache_map *fsmap) >> +{ >> + /* >> + * 1) For CHUNK_BASED layout, the output m_la is rounded down to the >> + * nearest chunk boundary, and the output m_llen actually starts from >> + * the start of the containing chunk. >> + * 2) For other cases, the output m_la is equal to o_la. >> + */ >> + size_t len = fsmap->m_llen - (fsmap->o_la - fsmap->m_la); >> + >> + return min_t(size_t, len, ractx->len - ractx->done); >> +} >> + >> +static inline void erofs_fscache_unlock_pages(struct readahead_control *rac, >> + size_t len) > > Can we convert them into folios in advance? it seems much > straight-forward to convert these... > > Or I have to convert them later, and it seems unnecessary... OK I will try to use folio API in the next version. > > >> +{ >> + while (len) { >> + struct page *page = readahead_page(rac); >> + >> + SetPageUptodate(page); >> + unlock_page(page); >> + put_page(page); >> + >> + len -= PAGE_SIZE; >> + } >> +} >> + >> +static int erofs_fscache_ra_hole(struct erofs_fscahce_ra_ctx *ractx, >> + struct erofs_fscache_map *fsmap) >> +{ >> + struct iov_iter iter; >> + loff_t start = ractx->start + ractx->done; >> + size_t length = erofs_fscache_calc_len(ractx, fsmap); >> + >> + iov_iter_xarray(&iter, READ, &ractx->mapping->i_pages, start, length); >> + iov_iter_zero(length, &iter); >> + >> + erofs_fscache_unlock_pages(ractx->rac, length); >> + return length; >> +} >> + >> +static int erofs_fscache_ra_noinline(struct erofs_fscahce_ra_ctx *ractx, >> + struct erofs_fscache_map *fsmap) >> +{ >> + struct fscache_cookie *cookie = fsmap->m_ctx->cookie; >> + loff_t start = ractx->start + ractx->done; >> + size_t length = erofs_fscache_calc_len(ractx, fsmap); >> + loff_t pstart = fsmap->m_pa + (fsmap->o_la - fsmap->m_la); >> + int ret; >> + >> + ret = erofs_fscache_read_pages(cookie, ractx->mapping, >> + start, length, pstart); >> + if (!ret) { >> + erofs_fscache_unlock_pages(ractx->rac, length); >> + ret = length; >> + } >> + >> + return ret; >> +} >> + >> +static int erofs_fscache_ra_inline(struct erofs_fscahce_ra_ctx *ractx, >> + struct erofs_fscache_map *fsmap) >> +{ > > We could fold in this, since it has the only user. OK, and "struct erofs_fscahce_ra_ctx" is not needed then. -- Thanks, Jeffle