From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_DBL_ABUSE_MALW autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 787F8C33CB3 for ; Thu, 30 Jan 2020 08:09:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4ED40206F0 for ; Thu, 30 Jan 2020 08:09:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="MnynihUM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726996AbgA3IJl (ORCPT ); Thu, 30 Jan 2020 03:09:41 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:46098 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726397AbgA3IJk (ORCPT ); Thu, 30 Jan 2020 03:09:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=M5ZbHKICi2HCHWPo7NcspAReloIi1S4smHry3HeNIS8=; b=MnynihUMvJ8e6EA2HC9AKocUl WVMvKhATL/XZ9Aww/Q732xxEVkzWLDQlpsmOTBzwTlxTp0IFVTE5BDpPrBjs6VPkEWkS4g+aOzCYo 0uL1VN5Z81VKhK0ZCYdiwLhp5kmIvTzjaGjOkNMShhDmj32fjcHUz5AdhAuCFJNZHtnBvdw9KZ2B0 sGXdDNFdF7W50VYSfMQPILAIsW+yQie96s1KJIUAmfE2gForcKDPGSmFqu3DvUeoylEsA0CFv9lNC Bo78SV7g99Jgj4PYFJZKWsCCQ7co68TDK+bGs6NiQNGxwW1xijeFKW6PtRAFonVFigDFDY/sPFNSV 1eHjOQ14w==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix4tQ-0007cd-0v; Thu, 30 Jan 2020 08:09:40 +0000 Date: Thu, 30 Jan 2020 00:09:39 -0800 From: Matthew Wilcox To: Dave Chinner Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: Re: [PATCH 06/12] btrfs: Convert from readpages to readahead Message-ID: <20200130080939.GL6615@bombadil.infradead.org> References: <20200125013553.24899-1-willy@infradead.org> <20200125013553.24899-7-willy@infradead.org> <20200129004609.GI18610@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200129004609.GI18610@dread.disaster.area> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 29, 2020 at 11:46:09AM +1100, Dave Chinner wrote: > On Fri, Jan 24, 2020 at 05:35:47PM -0800, Matthew Wilcox wrote: > > From: "Matthew Wilcox (Oracle)" > > > > Use the new readahead operation in btrfs > > > > Signed-off-by: Matthew Wilcox (Oracle) > > Cc: linux-btrfs@vger.kernel.org > > --- > > fs/btrfs/extent_io.c | 15 ++++----------- > > fs/btrfs/extent_io.h | 2 +- > > fs/btrfs/inode.c | 18 +++++++++--------- > > 3 files changed, 14 insertions(+), 21 deletions(-) > > > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > > index 2f4802f405a2..b1e2acbec165 100644 > > --- a/fs/btrfs/extent_io.c > > +++ b/fs/btrfs/extent_io.c > > @@ -4283,7 +4283,7 @@ int extent_writepages(struct address_space *mapping, > > return ret; > > } > > > > -int extent_readpages(struct address_space *mapping, struct list_head *pages, > > +unsigned extent_readahead(struct address_space *mapping, pgoff_t start, > > unsigned nr_pages) > > { > > struct bio *bio = NULL; > > @@ -4294,20 +4294,13 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages, > > int nr = 0; > > u64 prev_em_start = (u64)-1; > > > > - while (!list_empty(pages)) { > > + while (nr_pages) { > > u64 contig_end = 0; > > > > - for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) { > > - struct page *page = lru_to_page(pages); > > + for (nr = 0; nr < ARRAY_SIZE(pagepool) && nr_pages--;) { > > What is stopping nr_pages from going negative here, and then looping > forever on the outer nr_pages loop? Perhaps "while(nr_pages > 0) {" > would be better there? Ugh, nr_pages is unsigned, so that's no good. Maybe make this a more conventional loop ... while (nr_pages) { u64 contig_end = 0; for (nr = 0; nr < ARRAY_SIZE(pagepool); nr++) { struct page *page = readahead_page(mapping, start++); prefetchw(&page->flags); pagepool[nr] = page; contig_end = page_offset(page) + PAGE_SIZE - 1; if (--nr_pages == 0) break; }