From patchwork Tue Jul 20 08:43:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12387847 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 6C909C07E95 for ; Tue, 20 Jul 2021 08:53:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EC466121E for ; Tue, 20 Jul 2021 08:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234899AbhGTIL2 (ORCPT ); Tue, 20 Jul 2021 04:11:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbhGTIDd (ORCPT ); Tue, 20 Jul 2021 04:03:33 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11CCAC061762; Tue, 20 Jul 2021 01:44:12 -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: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=hDxhkvl1GckRp/8tfsdTt+oLETLQj3SGmuyOppemisU=; b=E6h+j2IZrkz9vX8wE5cJUT8w04 9KtLcZOxgDU94wJyotd/+LL5TwYUkVYvbHqemHTQ5viqk0NARaAtKk6e6fb1m2rU4Bk/McE30JN4Q mg8ObHnq//pWwN31Jnrltp/ajHtgB8SBe3HysdkX9dXUjOM1/y6aP+QraZg8RWqhyxAJfb4oVwLa4 ymjZWtjE5aDcJrj/qMbtku7Yr4m2UvM6Ay9TSq5EpO3j+SaQkAQ7mf1UPoDjFbUJVuLjynsXz5LCR LUoZ/0hcsoBamxirxbZU+XROMOHrr+V3pQaWTE32cDxeRwqDcXhdg6X42vctbW6RlVRLuPtKBT8CC FW7ztdHA==; Received: from [2001:4bb8:193:7660:5612:5e3c:ba3d:2b3c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lLW-007vLn-SG; Tue, 20 Jul 2021 08:43:33 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, willy@infradead.org Subject: [PATCH 1/2] iomap: simplify iomap_readpage_actor Date: Tue, 20 Jul 2021 10:43:19 +0200 Message-Id: <20210720084320.184877-1-hch@lst.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Now that the outstanding reads are counted in bytes, there is no need to use the low-level __bio_try_merge_page API, we can switch back to always using bio_add_page and simply iomap_readpage_actor again. Signed-off-by: Christoph Hellwig Signed-off-by: Christoph Hellwig Reviewed-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 87ccb3438becd9..4eaadbd265fcfa 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -241,7 +241,6 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, struct iomap_readpage_ctx *ctx = data; struct page *page = ctx->cur_page; struct iomap_page *iop; - bool same_page = false, is_contig = false; loff_t orig_pos = pos; unsigned poff, plen; sector_t sector; @@ -268,16 +267,10 @@ iomap_readpage_actor(struct inode *inode, loff_t pos, loff_t length, void *data, if (iop) atomic_add(plen, &iop->read_bytes_pending); - /* Try to merge into a previous segment if we can */ sector = iomap_sector(iomap, pos); - if (ctx->bio && bio_end_sector(ctx->bio) == sector) { - if (__bio_try_merge_page(ctx->bio, page, plen, poff, - &same_page)) - goto done; - is_contig = true; - } - - if (!is_contig || bio_full(ctx->bio, plen)) { + if (!ctx->bio || + bio_full(ctx->bio, plen) || + bio_end_sector(ctx->bio) != sector) { gfp_t gfp = mapping_gfp_constraint(page->mapping, GFP_KERNEL); gfp_t orig_gfp = gfp; unsigned int nr_vecs = DIV_ROUND_UP(length, PAGE_SIZE); From patchwork Tue Jul 20 08:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12387849 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 A5ACFC07E95 for ; Tue, 20 Jul 2021 08:57:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 94AC261263 for ; Tue, 20 Jul 2021 08:57:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232017AbhGTIQq (ORCPT ); Tue, 20 Jul 2021 04:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235091AbhGTINR (ORCPT ); Tue, 20 Jul 2021 04:13:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A837C061574; Tue, 20 Jul 2021 01:44:45 -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=0dYGDVY2JB7ti9Ncuy52QnlE4rdjiptmasEfVI80if0=; b=r2i6ADHMQDU76EvTeAFOz7Lzfo gkEgxPGEXDhQ0c1Br6TdK3Mci2u8L+8jRpSKIwgB9vtMJSGkNvbMx3hFK8L3F1wfkUTrAng1JP2gI /RgV8fg2tcPMeMJAdu2vc2xE7IoUGtyLeO98IQmOO3vFc7WHLufH1pi+mrfqUTrSmy0KxEE4yg3rk gxmaoTk6sTfn0O6QOBMSixowowbU+84g+emzHweK7VHsog5px79z/J31tvOhJ1AOf3q3qD2LgYCKK tH5pKrxAmWbhOibAdwv30iAIpxxEg/GojpRxBZbpVUj9vFn4U2y7pfGFhx2Rs0Xnk1UjKZmgqz4Yu U0FB0kRw==; Received: from [2001:4bb8:193:7660:5612:5e3c:ba3d:2b3c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5lM4-007vNH-F1; Tue, 20 Jul 2021 08:44:05 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, willy@infradead.org Subject: [PATCH 2/2] iomap: simplify iomap_add_to_ioend Date: Tue, 20 Jul 2021 10:43:20 +0200 Message-Id: <20210720084320.184877-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210720084320.184877-1-hch@lst.de> References: <20210720084320.184877-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org Now that the outstanding writes are counted in bytes, there is no need to use the low-level __bio_try_merge_page API, we can switch back to always using bio_add_page and simply iomap_add_to_ioend again. Signed-off-by: Christoph Hellwig Signed-off-by: Matthew Wilcox (Oracle) --- fs/iomap/buffered-io.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 4eaadbd265fcfa..b5f355f3f8ee51 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1252,7 +1252,6 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page, sector_t sector = iomap_sector(&wpc->iomap, offset); unsigned len = i_blocksize(inode); unsigned poff = offset & (PAGE_SIZE - 1); - bool merged, same_page = false; if (!wpc->ioend || !iomap_can_add_to_ioend(wpc, offset, sector)) { if (wpc->ioend) @@ -1260,19 +1259,13 @@ iomap_add_to_ioend(struct inode *inode, loff_t offset, struct page *page, wpc->ioend = iomap_alloc_ioend(inode, wpc, offset, sector, wbc); } - merged = __bio_try_merge_page(wpc->ioend->io_bio, page, len, poff, - &same_page); - if (iop) - atomic_add(len, &iop->write_bytes_pending); - - if (!merged) { - if (bio_full(wpc->ioend->io_bio, len)) { - wpc->ioend->io_bio = - iomap_chain_bio(wpc->ioend->io_bio); - } - bio_add_page(wpc->ioend->io_bio, page, len, poff); + if (bio_add_page(wpc->ioend->io_bio, page, len, poff) != len) { + wpc->ioend->io_bio = iomap_chain_bio(wpc->ioend->io_bio); + __bio_add_page(wpc->ioend->io_bio, page, len, poff); } + if (iop) + atomic_add(len, &iop->write_bytes_pending); wpc->ioend->io_size += len; wbc_account_cgroup_owner(wbc, page, len); }