From patchwork Sat Dec 14 03:10:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D746E7716A for ; Sat, 14 Dec 2024 05:20:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB6C56B007B; Sat, 14 Dec 2024 00:20:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3F7D6B0083; Sat, 14 Dec 2024 00:20:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B9846B0085; Sat, 14 Dec 2024 00:20:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6A1396B007B for ; Sat, 14 Dec 2024 00:20:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 09E8244595 for ; Sat, 14 Dec 2024 05:20:52 +0000 (UTC) X-FDA: 82892414346.23.837B75A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id A2DFE180004 for ; Sat, 14 Dec 2024 05:20:47 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=q6vmcgeK; spf=none (imf24.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734153622; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XGC/Uaj6ejX3COzNjOnUbs+G/8tqYkyreK9oJdjYOIk=; b=IlKeQNw/9+ettSPBq/8iAmkB2evAUN6DtWBYz6FMdOsjUBe/OKK4yaK6Kj52tMee7Mnjz8 wmzLv0zP4BORvGG4FiPQgI6VYYbqCsbitn/eEr8KiJaOSCqko0lPVzlusswsa9xMSF+91F k1Oe6jXrGat8DngCzz+P/W+q7OrgZkg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734153622; a=rsa-sha256; cv=none; b=pEwZ2vKj5/fmfC6WGYYLsOPi4PZ+XIOKORDdh4l9rqLWyVTZSTi5UHBPFz6Ph+3EHIJBfq dgWu8uTqLQKvHdo9TbtnY+1QTJfEJ829K1RHMWpAEhpCpCxCim8ehdDrOj8+jPa60yikot q6A8mbgIC6OraGuUVlgrlaji24nYVTg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=q6vmcgeK; spf=none (imf24.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=XGC/Uaj6ejX3COzNjOnUbs+G/8tqYkyreK9oJdjYOIk=; b=q6vmcgeKRQGC9VxZzw/i1K7IM4 UNJ2yA++QL819qBrpBG/20R6ObuMeDwxlObsUy00dcyHx3CICTjepQNTTG+/gL1M5fpux2bmxw6n6 7t4UhgYo+OzeILY+IrXH2oI0Cahn8DBNp7WgjELSFjhfoWfs9IVGP/VhY7NY+jDs5EmPPaa9Y+kIz NARAxIxF7SjifSqhF6aI+7Zoi2gPZvlxQYTqJpAlmHGOzy9CjN/G+WQlyLRdP/1UGnYKCEbmo6Bxg ZKoyOC8tlp2vZxwmgJINhJlX7cYH+oDp2luJRSXAjsInk1TVs1QoqSD2+d58oT8EvC6nAam8H+IEZ urGCzVIw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3X-3GCO; Sat, 14 Dec 2024 03:10:51 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, dave@stgolabs.net, david@fromorbit.com, djwong@kernel.org Cc: john.g.garry@oracle.com, ritesh.list@gmail.com, kbusch@kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, kernel@pankajraghav.com, mcgrof@kernel.org Subject: [RFC v2 01/11] fs/buffer: move async batch read code into a helper Date: Fri, 13 Dec 2024 19:10:39 -0800 Message-ID: <20241214031050.1337920-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241214031050.1337920-1-mcgrof@kernel.org> References: <20241214031050.1337920-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A2DFE180004 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: xb5n1mxmfrbe4fojb9xs37d3tr94w4cz X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734153647-626713 X-HE-Meta: U2FsdGVkX1+7eTc35uAMdCF1d21thrOYFPH/qc0R8FaujuNCMp/IuVTL+i70zM6kzYOXydkn+gLoWZSMdbQuzCekcvw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aYmcQqAyvQ9ahr4XB5YTzDpRW6vw+fkcldEJCVD5i+5sH7BZZy3xgmrpm0ERVteQdqythqGuxjlhIPBjl9m7uKs/gjDnfOOy9+B1l5QrLnPWlFpQWKw1Nivu+ZdNs4tLJNe9OH4DP5j5Xm4t05K9U46qQsMJfeTtPm2kN8jbLqg3qjdH6wlVLgtgmz4NrE3jLohe0CtDdFtcxmPcL9RDXzlkKlF1vKiq4gdA35uNvcTDEpsYDsoZWcBcUypaf6I43ngpgwA+ve2NeC48WEc10ODLIPwLFINEea6R8vNpol1/pg5dqfqMACILUP2h1hxs2f6h7egWv1AWQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000083, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Move the code from block_read_full_folio() which does a batch of async reads into a helper. No functional changes. Signed-off-by: Luis Chamberlain --- fs/buffer.c | 73 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index cc8452f60251..580451337efa 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2350,6 +2350,48 @@ bool block_is_partially_uptodate(struct folio *folio, size_t from, size_t count) } EXPORT_SYMBOL(block_is_partially_uptodate); +static void bh_read_batch_async(struct folio *folio, + int nr, struct buffer_head *arr[], + bool fully_mapped, bool no_reads, + bool any_get_block_error) +{ + int i; + struct buffer_head *bh; + + if (fully_mapped) + folio_set_mappedtodisk(folio); + + if (no_reads) { + /* + * All buffers are uptodate or get_block() returned an + * error when trying to map them *all* buffers we can + * finish the read. + */ + folio_end_read(folio, !any_get_block_error); + return; + } + + /* Stage one: lock the buffers */ + for (i = 0; i < nr; i++) { + bh = arr[i]; + lock_buffer(bh); + mark_buffer_async_read(bh); + } + + /* + * Stage 2: start the IO. Check for uptodateness + * inside the buffer lock in case another process reading + * the underlying blockdev brought it uptodate (the sct fix). + */ + for (i = 0; i < nr; i++) { + bh = arr[i]; + if (buffer_uptodate(bh)) + end_buffer_async_read(bh, 1); + else + submit_bh(REQ_OP_READ, bh); + } +} + /* * Generic "read_folio" function for block devices that have the normal * get_block functionality. This is most of the block device filesystems. @@ -2414,37 +2456,8 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) arr[nr++] = bh; } while (i++, iblock++, (bh = bh->b_this_page) != head); - if (fully_mapped) - folio_set_mappedtodisk(folio); - - if (!nr) { - /* - * All buffers are uptodate or get_block() returned an - * error when trying to map them - we can finish the read. - */ - folio_end_read(folio, !page_error); - return 0; - } - - /* Stage two: lock the buffers */ - for (i = 0; i < nr; i++) { - bh = arr[i]; - lock_buffer(bh); - mark_buffer_async_read(bh); - } + bh_read_batch_async(folio, nr, arr, fully_mapped, nr == 0, page_error); - /* - * Stage 3: start the IO. Check for uptodateness - * inside the buffer lock in case another process reading - * the underlying blockdev brought it uptodate (the sct fix). - */ - for (i = 0; i < nr; i++) { - bh = arr[i]; - if (buffer_uptodate(bh)) - end_buffer_async_read(bh, 1); - else - submit_bh(REQ_OP_READ, bh); - } return 0; } EXPORT_SYMBOL(block_read_full_folio);