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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 B9B80C2D0A3 for ; Tue, 3 Nov 2020 15:29:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1FE3322226 for ; Tue, 3 Nov 2020 15:29:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE3322226 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9057D6B0068; Tue, 3 Nov 2020 10:29:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B4D86B006C; Tue, 3 Nov 2020 10:29:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A5606B0072; Tue, 3 Nov 2020 10:29:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 498686B0068 for ; Tue, 3 Nov 2020 10:29:52 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 9F014362D for ; Tue, 3 Nov 2020 15:29:51 +0000 (UTC) X-FDA: 77443492182.12.tin49_560252f272b9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 7D66518008A1D for ; Tue, 3 Nov 2020 15:29:51 +0000 (UTC) X-HE-Tag: tin49_560252f272b9 X-Filterd-Recvd-Size: 2982 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Tue, 3 Nov 2020 15:29:50 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 73C136736F; Tue, 3 Nov 2020 16:29:47 +0100 (CET) Date: Tue, 3 Nov 2020 16:29:47 +0100 From: Christoph Hellwig To: Matthew Wilcox Cc: Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, kent.overstreet@gmail.com Subject: Re: [PATCH 14/17] mm/filemap: Restructure filemap_get_pages Message-ID: <20201103152947.GB10928@lst.de> References: <20201102184312.25926-1-willy@infradead.org> <20201102184312.25926-15-willy@infradead.org> <20201103075736.GM8389@lst.de> <20201103144619.GW27442@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201103144619.GW27442@casper.infradead.org> User-Agent: Mutt/1.5.17 (2007-11-01) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 03, 2020 at 02:46:19PM +0000, Matthew Wilcox wrote: > On Tue, Nov 03, 2020 at 08:57:36AM +0100, Christoph Hellwig wrote: > > On Mon, Nov 02, 2020 at 06:43:09PM +0000, Matthew Wilcox (Oracle) wrote: > > > Avoid a goto, and by the time we get to calling filemap_update_page(), > > > we definitely have at least one page. > > > > I find the error handling flow hard to follow and the existing but > > heavily touched naming of the nr_got variable and the find_pages label > > not helpful. I'd do the following on top of this patch: > > I've removed nr_got entirely in my current tree ... Even better. The pagevec usage looks pretty nice! > +static void mapping_get_read_thps(struct address_space *mapping, Maybe call this pagevec_get_read_thps? > + pgoff_t maxindex = DIV_ROUND_UP(iocb->ki_pos + iter->count, PAGE_SIZE); > struct page *page; > + int err = 0; > > find_page: > if (fatal_signal_pending(current)) > return -EINTR; > > + pagevec_init(pvec); > + mapping_get_read_thps(mapping, index, maxindex, pvec); > + if (!pagevec_count(pvec)) { > if (iocb->ki_flags & IOCB_NOIO) > return -EAGAIN; > page_cache_sync_readahead(mapping, ra, filp, index, > + maxindex - index); > + mapping_get_read_thps(mapping, index, maxindex, pvec); > } > + if (!pagevec_count(pvec)) { > if (iocb->ki_flags & (IOCB_NOWAIT | IOCB_WAITQ)) > return -EAGAIN; > + page = filemap_create_page(filp, mapping, > iocb->ki_pos >> PAGE_SHIFT); > + if (!page) > goto find_page; > + if (IS_ERR(page)) > + return PTR_ERR(page); > + pagevec_add(pvec, page); > + return 0; I'd pass the pagevec to filemap_create_page and just return an errno, which should be a little easier to follow. > - page = pages[nr_got - 1]; > + page = pvec->pages[pagevec_count(pvec) - 1]; I wonder if a pagevec_last_page() helper would be neat for things like this? (might be a bit of over engineering..)