Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp731100pxv; Thu, 15 Jul 2021 14:43:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt2wKBiIXBImKQhxwVunlkXI8tfiG3ZK8HvRwQgfsIFsvyyFl1NJu9oQ0uyOMcdKtiipLp X-Received: by 2002:a92:2a0a:: with SMTP id r10mr4109961ile.274.1626385387671; Thu, 15 Jul 2021 14:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626385387; cv=none; d=google.com; s=arc-20160816; b=DB77nlAtYLnTahBQqI6Z1p5YD65qM5vVyfkows+N1n5B6nZm6ahi922hVNAq6qJ+az HlRS869O2Th1g9NG2ShuINQBt8MDsagN+Z21KhqXxwVK/0l5qHoMmmcZyDm41n+kdLqX KWBB8fRONpVRgv7N/h92Dxuk/vhnerKSPN6Rkx2PIblh2Mexo8I1n98pXOAMg02ttZgQ FHrYU6qF0KS9RnZ3Ms68ZRyJIYi8na3ydmgozHWx4NT2RRYAPsjikcOsxfIBhJRevwNW SCqYzJoA3RPyKxQ/6/8W74Cr8F/CW91W4gIejf6s9R/RDQX7JACOsJsnbT1KlM54Z01h hcjg== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=KN/zi7VLu6VqpD2uPp1ib8jqP7j72A8C9Tn1o7dj0Mc=; b=w4e1JFcoHlrKFHZ529Y8ri94/mckkJ51iHf7k62ol97DTAKDnTpS/Jk1VTugAeB59G 0tYm3j/kJBrOlNNlqWEOUqDcNmVM4U2AhxkAh4UIuC0ghBArgicYxL9hwHcknM+wpzoZ 3iduncT/ggrQQTaBhOdHKIH11gnoqz1djOryyymm4evNobc1enbuK8rKm5jfIKPGp4b5 xdBaih/rDx8raNxaWU/PGl3FqIQVdK9dd2eAWTQes9cXkNCyGWKe5m/tqmTCBXcPLnjx STBVAxqpIn/P35bCaZ3xM5ybrDrWKrn2tau8UZBVxp7ycA2cDjz19WGD8EkAKHdOR9MH k59g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJqjvZ4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x1si8922103jan.58.2021.07.15.14.42.55; Thu, 15 Jul 2021 14:43:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OJqjvZ4q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbhGOVoB (ORCPT + 99 others); Thu, 15 Jul 2021 17:44:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:43374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbhGOVoA (ORCPT ); Thu, 15 Jul 2021 17:44:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E15A9613C4; Thu, 15 Jul 2021 21:41:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626385267; bh=boeoRdAwNjY3dPChiEWxtb28FAMFJvybc2RVJmTuJ+4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OJqjvZ4qBb7X9gAyHeWJ58uumLKgqEEE7n0okAC0XG1em4DEqagD3RG7V7jUtyylG ZTr2gF11LZeIjK2bYO1sdgEz8aEYHG9S3/ahbXJUB/9PTlaNYL7kncOpQBQr3ssGzV zbVfus+wHhYi0w7loKcaPkIuL3wId/szIqvVaZxpCOxrpxNDEak9HR0gVOuPsV52EK 5k6Umk3h7mLoKT+WlEb2hi15BSRDy1nptxF8o56xuDIbiTcFvMzRd0JFPaWhkDNjAU 78DCO7gxENzzHiDVpr+OXHlq7hWJ5xxueMecA+oqBmqNGAg8T/ySuBuIXFu+k/2b+H htcpJsmXXgE/A== Date: Thu, 15 Jul 2021 14:41:06 -0700 From: "Darrick J. Wong" To: "Matthew Wilcox (Oracle)" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v14 101/138] iomap: Convert iomap_page_mkwrite to use a folio Message-ID: <20210715214106.GL22357@magnolia> References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-102-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715033704.692967-102-willy@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 15, 2021 at 04:36:27AM +0100, Matthew Wilcox (Oracle) wrote: > If we write to any page in a folio, we have to mark the entire > folio as dirty, and potentially COW the entire folio, because it'll > all get written back as one unit. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > fs/iomap/buffered-io.c | 42 +++++++++++++++++++++--------------------- > 1 file changed, 21 insertions(+), 21 deletions(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 7c702d6c2f64..a3fe0d36c739 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -951,23 +951,23 @@ iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, > } > EXPORT_SYMBOL_GPL(iomap_truncate_page); > > -static loff_t > -iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, > - void *data, struct iomap *iomap, struct iomap *srcmap) > +static loff_t iomap_folio_mkwrite_actor(struct inode *inode, loff_t pos, > + loff_t length, void *data, struct iomap *iomap, > + struct iomap *srcmap) > { > - struct page *page = data; > - struct folio *folio = page_folio(page); > + struct folio *folio = data; > int ret; > > if (iomap->flags & IOMAP_F_BUFFER_HEAD) { > - ret = __block_write_begin_int(page, pos, length, NULL, iomap); > + ret = __block_write_begin_int(&folio->page, pos, length, NULL, > + iomap); > if (ret) > return ret; > - block_commit_write(page, 0, length); > + block_commit_write(&folio->page, 0, length); > } else { > - WARN_ON_ONCE(!PageUptodate(page)); > + WARN_ON_ONCE(!folio_test_uptodate(folio)); > iomap_page_create(inode, folio); > - set_page_dirty(page); > + folio_mark_dirty(folio); > } > > return length; > @@ -975,33 +975,33 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, > > vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) > { > - struct page *page = vmf->page; > + struct folio *folio = page_folio(vmf->page); If before the page fault the folio was a compound 2M page, will the memory manager will have split it into 4k pages before passing it to us? That's a roundabout way of asking if we should expect folio_mkwrite at some point. ;) The conversion looks pretty straightforward though. Reviewed-by: Darrick J. Wong --D > struct inode *inode = file_inode(vmf->vma->vm_file); > - unsigned long length; > - loff_t offset; > + size_t length; > + loff_t pos; > ssize_t ret; > > - lock_page(page); > - ret = page_mkwrite_check_truncate(page, inode); > + folio_lock(folio); > + ret = folio_mkwrite_check_truncate(folio, inode); > if (ret < 0) > goto out_unlock; > length = ret; > > - offset = page_offset(page); > + pos = folio_pos(folio); > while (length > 0) { > - ret = iomap_apply(inode, offset, length, > - IOMAP_WRITE | IOMAP_FAULT, ops, page, > - iomap_page_mkwrite_actor); > + ret = iomap_apply(inode, pos, length, > + IOMAP_WRITE | IOMAP_FAULT, ops, folio, > + iomap_folio_mkwrite_actor); > if (unlikely(ret <= 0)) > goto out_unlock; > - offset += ret; > + pos += ret; > length -= ret; > } > > - wait_for_stable_page(page); > + folio_wait_stable(folio); > return VM_FAULT_LOCKED; > out_unlock: > - unlock_page(page); > + folio_unlock(folio); > return block_page_mkwrite_return(ret); > } > EXPORT_SYMBOL_GPL(iomap_page_mkwrite); > -- > 2.30.2 >