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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 669D0C636C8 for ; Fri, 16 Jul 2021 03:12:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 03784601FA for ; Fri, 16 Jul 2021 03:12:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 03784601FA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 597878D00F4; Thu, 15 Jul 2021 23:12:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 547BC8D00EC; Thu, 15 Jul 2021 23:12:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 410078D00F4; Thu, 15 Jul 2021 23:12:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id 1DFB18D00EC for ; Thu, 15 Jul 2021 23:12:43 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E2435824556B for ; Fri, 16 Jul 2021 03:12:41 +0000 (UTC) X-FDA: 78366978522.18.89B8879 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 71A25E0019BB for ; Fri, 16 Jul 2021 03:12:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=TRDya8wHWkJxj5dWxTTzT73+dIkTaai0safBwEJTM+0=; b=MwzLcqHYbmp3Z0BhM8fXff+86l k2Lkime2zcBMJsOr6pG++QI9XGFLoWMwdot/nq5BMizLvsKhnhG2J2LrkWjI/4ouZ6pCkg1FD5A6a wpUv/moDpYyoRAB5EIoKy1zZhc07/0qXFDwTYEF01LlF7dbGOY2DTNgLuV5cBNnb738mxNUncogxY uqMjDCavSPsUSKbva4hdobjPZpXKbTTWPMZoSiE71V6c3T/mly+Y8ujoGM8gOhWq67dvuLeVm470W 9PzxCxuX5ofo6UMb10Xh0R95dHa7FnDT6K5tiFBhi60MGwdcknp8Ag9RgjFGm+BE/xZwZ3DE8MY6r suGyIuFw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1m4EGN-0045sr-7Q; Fri, 16 Jul 2021 03:11:53 +0000 Date: Fri, 16 Jul 2021 04:11:43 +0100 From: Matthew Wilcox To: "Darrick J. Wong" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v14 102/138] iomap: Convert iomap_write_begin and iomap_write_end to folios Message-ID: References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-103-willy@infradead.org> <20210715215105.GM22357@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715215105.GM22357@magnolia> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 71A25E0019BB X-Stat-Signature: 7uws6p84qx1mfran84jp3f4expiqzdt5 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MwzLcqHY; spf=none (imf30.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1626405161-676789 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 Thu, Jul 15, 2021 at 02:51:05PM -0700, Darrick J. Wong wrote: > On Thu, Jul 15, 2021 at 04:36:28AM +0100, Matthew Wilcox (Oracle) wrote: > > +static int iomap_write_begin(struct inode *inode, loff_t pos, size_t len, > > + unsigned flags, struct folio **foliop, struct iomap *iomap, > > + struct iomap *srcmap) > > { > > const struct iomap_page_ops *page_ops = iomap->page_ops; > > + struct folio *folio; > > struct page *page; > > + unsigned fgp = FGP_LOCK | FGP_WRITE | FGP_CREAT | FGP_STABLE | FGP_NOFS; > > int status = 0; > > > > BUG_ON(pos + len > iomap->offset + iomap->length); > > @@ -604,30 +605,31 @@ iomap_write_begin(struct inode *inode, loff_t pos, unsigned len, unsigned flags, > > return status; > > } > > > > - page = grab_cache_page_write_begin(inode->i_mapping, pos >> PAGE_SHIFT, > > - AOP_FLAG_NOFS); > > - if (!page) { > > + folio = __filemap_get_folio(inode->i_mapping, pos >> PAGE_SHIFT, fgp, > > Ah, ok, so we're moving the file_get_pages flags up to iomap now. Right, saves us having a folio equivalent of grab_cache_page_write_begin(). And lets us get rid of AOP_FLAG_NOFS eventually (although that really should be obsoleted by scoped allocations, but one windmill at a time). > > + struct page *page = folio_file_page(folio, pos / PAGE_SIZE); > > pos >> PAGE_SHIFT ? mmm. We're inconsistent: willy@pepe:~/kernel/folio$ git grep '/ PAGE_SIZE' mm/ fs/ |wc 92 720 6475 willy@pepe:~/kernel/folio$ git grep '>> PAGE_SHIFT' mm/ fs/ |wc 635 4582 39394 That said, there's a clear preference. It's just that we had a bug the other day where somebody shifted by PAGE_SHIFT in the wrong direction ... But again, this is your code, so I'll change to the shift.