Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp725622pxv; Thu, 15 Jul 2021 14:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0t9k4DKjmaum5pEu1sRn3ZgyBACVz/NX3URBRi5bb2rc5ZCUQLEo1kk5550rJ5l5Bawhz X-Received: by 2002:a17:907:d89:: with SMTP id go9mr5458688ejc.393.1626384819009; Thu, 15 Jul 2021 14:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626384819; cv=none; d=google.com; s=arc-20160816; b=I8+CTtSgGQNOEHpMWlRqNyIWuoYQsE3Ami4xN6PkR1f9DOZm776SLf3Jkjelya4Vbe OehW72CQVjv7kKsS4mJq0e9XzRI3ff2DR+JRHr7NcDxfZc937MttP4SwBfn+ym55rJWw jon0jqf+/yyA3N7ZC52KbOrS34IfUUL3105vKiDg3egDua+4cq7bE8E20bnY3PMqQYJX gEzmIUjWjyMyY/xIVPM0rMzHpxNzEyAfchfH8vJeuafdYGrPcP5ClMMsycINAKAfVJT9 uNeonWMuRlJa3j2Irm7NjUDm2e3NaPBFfD92toboKa3FNz/KrcEzj1DE7KNtai3SdOIM mLxQ== 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=cpko34fXcQWsaFI6k9Qms6eSnrCCOZNHX/KXQg7JopY=; b=VUfdbibxDo6JEXjCEwqp93F3M8JiizFy85yZh54VTgv4ifdc9DLH+6oDCCitDDZTWy kKO+1jsH6zWdnzjWJq2GXlv+mEhyEZ2ihj0Z77BfgZn6Zg4JZ9VNEpUz7A7zdvlRFBW3 /yjxsu7PyITCEqfVfd7/8BsHad5Ti7WC7dMCzNhrowhXhotPuHDFUU7eWUv3Gej+MTfJ SLcDrHp4qAg4ot9WrhlA070Qy90VRPL4DJmhk6wNeQBIEXdQ32qnbESp7gIUAbzUpkUr 90qngXVPLNwM97YiL9x8iq0oZK8dZQkBeWKjiYZDKIYrfbFOP7nAffLww99A/zZYqmzW XmpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZUhEnZIw; 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 d15si8964676ejc.258.2021.07.15.14.33.15; Thu, 15 Jul 2021 14:33:38 -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=ZUhEnZIw; 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 S230339AbhGOVc5 (ORCPT + 99 others); Thu, 15 Jul 2021 17:32:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:41576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229591AbhGOVc4 (ORCPT ); Thu, 15 Jul 2021 17:32:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A2B43611F1; Thu, 15 Jul 2021 21:30:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626384602; bh=D3QDdLM89cxBk7tfEwcimk2qfKuQ6CQwajjunO6VrTo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZUhEnZIwp986F3rBuWYAaDd4TiNr5DR8eh2sxjLi/w42J398gXfMwbgAEmi4ywjUr ifqr5c/KxRc880gZ4KZStYXI9dgotUfWRN1rSigbaNGqqrdhnSSp2M0CSSCTXMNoWP SlovpvnTmKi2iI6IuhXCBA1X8h1+nMWGXFUeD57MwvN9Q/jCsxrAM9zg22IuxSaLaC MlorCXh99D1IScq7On/UVWNUu2+gVd6nARD2JwP9eLBQQXfqPquaZHsuCVR1AlghPQ q78ogM224/iOjcQ5munLr/tODl12zY/6nUlW3E7BNNTdxc7uvFuak1UHYmxiuHTPSB SVz1E8koAPtRw== Date: Thu, 15 Jul 2021 14:30:02 -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 099/138] iomap: Convert bio completions to use folios Message-ID: <20210715213002.GJ22357@magnolia> References: <20210715033704.692967-1-willy@infradead.org> <20210715033704.692967-100-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210715033704.692967-100-willy@infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 15, 2021 at 04:36:25AM +0100, Matthew Wilcox (Oracle) wrote: > Use bio_for_each_folio() to iterate over each folio in the bio > instead of iterating over each page. > > Signed-off-by: Matthew Wilcox (Oracle) Neat conversion, Reviewed-by: Darrick J. Wong --D > --- > fs/iomap/buffered-io.c | 46 +++++++++++++++++------------------------- > 1 file changed, 18 insertions(+), 28 deletions(-) > > diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c > index 707a96e36651..4732298f74e1 100644 > --- a/fs/iomap/buffered-io.c > +++ b/fs/iomap/buffered-io.c > @@ -161,36 +161,29 @@ static void iomap_set_range_uptodate(struct folio *folio, > folio_mark_uptodate(folio); > } > > -static void > -iomap_read_page_end_io(struct bio_vec *bvec, int error) > +static void iomap_finish_folio_read(struct folio *folio, size_t offset, > + size_t len, int error) > { > - struct page *page = bvec->bv_page; > - struct folio *folio = page_folio(page); > struct iomap_page *iop = to_iomap_page(folio); > > if (unlikely(error)) { > folio_clear_uptodate(folio); > folio_set_error(folio); > } else { > - size_t off = (page - &folio->page) * PAGE_SIZE + > - bvec->bv_offset; > - > - iomap_set_range_uptodate(folio, iop, off, bvec->bv_len); > + iomap_set_range_uptodate(folio, iop, offset, len); > } > > - if (!iop || atomic_sub_and_test(bvec->bv_len, &iop->read_bytes_pending)) > + if (!iop || atomic_sub_and_test(len, &iop->read_bytes_pending)) > folio_unlock(folio); > } > > -static void > -iomap_read_end_io(struct bio *bio) > +static void iomap_read_end_io(struct bio *bio) > { > int error = blk_status_to_errno(bio->bi_status); > - struct bio_vec *bvec; > - struct bvec_iter_all iter_all; > + struct folio_iter fi; > > - bio_for_each_segment_all(bvec, bio, iter_all) > - iomap_read_page_end_io(bvec, error); > + bio_for_each_folio_all(fi, bio) > + iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error); > bio_put(bio); > } > > @@ -1014,23 +1007,21 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) > } > EXPORT_SYMBOL_GPL(iomap_page_mkwrite); > > -static void > -iomap_finish_page_writeback(struct inode *inode, struct page *page, > - int error, unsigned int len) > +static void iomap_finish_folio_write(struct inode *inode, struct folio *folio, > + size_t len, int error) > { > - struct folio *folio = page_folio(page); > struct iomap_page *iop = to_iomap_page(folio); > > if (error) { > - SetPageError(page); > + folio_set_error(folio); > mapping_set_error(inode->i_mapping, -EIO); > } > > - WARN_ON_ONCE(i_blocks_per_page(inode, page) > 1 && !iop); > + WARN_ON_ONCE(i_blocks_per_folio(inode, folio) > 1 && !iop); > WARN_ON_ONCE(iop && atomic_read(&iop->write_bytes_pending) <= 0); > > if (!iop || atomic_sub_and_test(len, &iop->write_bytes_pending)) > - end_page_writeback(page); > + folio_end_writeback(folio); > } > > /* > @@ -1049,8 +1040,7 @@ iomap_finish_ioend(struct iomap_ioend *ioend, int error) > bool quiet = bio_flagged(bio, BIO_QUIET); > > for (bio = &ioend->io_inline_bio; bio; bio = next) { > - struct bio_vec *bv; > - struct bvec_iter_all iter_all; > + struct folio_iter fi; > > /* > * For the last bio, bi_private points to the ioend, so we > @@ -1061,10 +1051,10 @@ iomap_finish_ioend(struct iomap_ioend *ioend, int error) > else > next = bio->bi_private; > > - /* walk each page on bio, ending page IO on them */ > - bio_for_each_segment_all(bv, bio, iter_all) > - iomap_finish_page_writeback(inode, bv->bv_page, error, > - bv->bv_len); > + /* walk all folios in bio, ending page IO on them */ > + bio_for_each_folio_all(fi, bio) > + iomap_finish_folio_write(inode, fi.folio, fi.length, > + error); > bio_put(bio); > } > /* The ioend has been freed by bio_put() */ > -- > 2.30.2 >