Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3445516pxb; Mon, 1 Nov 2021 14:00:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq8chJTiUEEFvsGENQ+c5NtkteJ7DZ95rzzS+TmKaxkUWYXbP1IJJc9su3agO/N2WjdjbL X-Received: by 2002:a05:6e02:1526:: with SMTP id i6mr20601481ilu.299.1635800450828; Mon, 01 Nov 2021 14:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635800450; cv=none; d=google.com; s=arc-20160816; b=lY3pWdpYUS9BjfqaYh/PIuR6bvA4ecYp3QXjloQUoZ2rLej6DZneVcXJIDXyLKk8F6 vWUViWyc0rrxa8tYKC0WRvD49xYMClA6PVqznda9cIApqYXW7mw7uCmYnKWCyiQKcHE8 f2jiUWuAInA5141NwS8JyG/JtPbbmZSmkUkBakPJU/CaLBr9PypfdapvsFpS54/tuzk7 DvU2t1m82u4CHbTA+GUtSMlwYcZxxI2cGy3wOwQ7T1aZ8lQiOW8R4aVjmyFw0clMTdCL CGAjtcti+ypJD/uCLNiMpDLXDzRF2Wir05Fu8Mj/9LQk8AhObFATCO5dl7fY9oiI9xgx izog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KpKuieDJWGlrDMm/5TIu3ao1+3ZG4gz9rmtUvNJ68HA=; b=Js8pMhEroSP7PIGSmAk5ELoD0Evoaw9peCLoDruzQ5KVD/e2wix1yvb3pHdEUAnkb9 sRCRirEtUbgr1LqUGoDpSoPkHUoviM3I5O0EiVScCJ+I52DhEijQq0du3m7qnu76YCce 4Xm8pLVquMxMxujWUBmrY7askUxFPMgO8JGsKlD0rlGaGH+STutuBnNwInu2e1CLGOBx 70+0KYnkI0v++15lytd78wDrAXaoMlXveNPq8DGBTu2Ro0uaMZT02hl3O8QRMfK5ZKND M3m0rvcMP9p7C/CK2WlCrbb9yM4sLn8khX6yrAzxHpBoAi/56+cZ/z8dFuzMU1V4Lpsg eW3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=YWWcuhAS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si6483215ill.97.2021.11.01.14.00.38; Mon, 01 Nov 2021 14:00:50 -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=@infradead.org header.s=casper.20170209 header.b=YWWcuhAS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbhKAVCV (ORCPT + 99 others); Mon, 1 Nov 2021 17:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbhKAVCU (ORCPT ); Mon, 1 Nov 2021 17:02:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9FBC061714; Mon, 1 Nov 2021 13:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KpKuieDJWGlrDMm/5TIu3ao1+3ZG4gz9rmtUvNJ68HA=; b=YWWcuhAS3ktByIW8b7Esnpk+dk XTPmOmVxUQBjJUUywaePjs3fDyn+p+fauk90Dkx+2cPRcf4i/xfjIXLOeugaKp4K7R/aNFHbfOgcX ckeIYC6DioUoCN0J/YQM6QjzgaRfeHhumGuZNuSIQYzUTJUNXuC6JAfQgJ41WwIlqSnvooRMv9CE2 /WGJ9xvHnZKy+E2WLKoym/rF3Gzj93sAyT/FNtRkJtAfJDQPGK6/ki4LPUAJrfUBkB20LtwvkjObQ TmDzx7K7nD4dkRdhTeGffxJJ+AYZFhD54z4bxoPONIMuZWicPPLSUdWnPIxNmnNBJBx/H8UwD8Yod waynVqhQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mheMA-0040xK-B0; Mon, 01 Nov 2021 20:56:58 +0000 From: "Matthew Wilcox (Oracle)" To: "Darrick J. Wong" Cc: "Matthew Wilcox (Oracle)" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig Subject: [PATCH 10/21] iomap: Convert bio completions to use folios Date: Mon, 1 Nov 2021 20:39:18 +0000 Message-Id: <20211101203929.954622-11-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211101203929.954622-1-willy@infradead.org> References: <20211101203929.954622-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 50 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index e171eb2ebc5d..d519972a11f1 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -161,34 +161,29 @@ static void iomap_set_range_uptodate(struct page *page, SetPageUptodate(page); } -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)) { - ClearPageUptodate(page); - SetPageError(page); + folio_clear_uptodate(folio); + folio_set_error(folio); } else { - iomap_set_range_uptodate(page, iop, bvec->bv_offset, - bvec->bv_len); + iomap_set_range_uptodate(&folio->page, iop, offset, len); } - if (!iop || atomic_sub_and_test(bvec->bv_len, &iop->read_bytes_pending)) - unlock_page(page); + 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); } @@ -1010,23 +1005,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, error); } - 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); } /* @@ -1045,8 +1038,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 @@ -1057,10 +1049,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.33.0