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); From patchwork Sat Dec 14 03:10:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908280 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 AB437E7716A for ; Sat, 14 Dec 2024 03:11:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 433276B0096; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EB0E6B009F; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE4C06B009E; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0A1CD6B0093 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A534B141689 for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892087082.23.D3DEE4E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf28.hostedemail.com (Postfix) with ESMTP id D274AC000B for ; Sat, 14 Dec 2024 03:10:29 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=y+Vot3PJ; spf=none (imf28.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=1734145840; 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=ly9Z0m8eTHU3wfdp35JFAoonrPj9YJ5xpu33d2EAXi4=; b=IkI5EWjrDdAxgauCRCzPJQXSrvAj2YpzYzYswq9FCD5GqOZx5Oq1lMS19g9jUuTuiSIVtN eF1n/CkT2utK/ZslJ2zxXY4+raiMGtFHadxR0xpbbBaY4F6lWt8DzHMhCSBMCpI7/IqwG4 su9hCu05ii/4iPjmgXJMLzNHdExPL/c= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=y+Vot3PJ; spf=none (imf28.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145840; a=rsa-sha256; cv=none; b=CVuFrNGVvzXKJyvYAsp0AMjYwsrSFE8g2N01cXFmSxCe6JkyTp41JockMrhgWFJGV41zxR 1eHp27jxYxMqzhXbCoiyCVAv+3lBIKs0PgZQaWAiKq3t+401iCKnupgiY0LZNnqXpaB1Mh moEtfdOrMGyxHHcV9OtabockHhFnOdA= 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=ly9Z0m8eTHU3wfdp35JFAoonrPj9YJ5xpu33d2EAXi4=; b=y+Vot3PJozFxtHqZ7Fp9JDbo4c jsrflL/YvKop7QmnivqVS3/9cSOrtdNg1NZt87O4y3Fo0P3YmFEh9/6/z11Ef8JQPkW11UbAml0SX dB33hD26ixC0mXy6W9q36zaEDrc+EuP2Gay4kESD2wcM+A4tuvYvCRryQz1gZrGPfX6i8p2pffDWZ DouswSptmAW/mI1zWobDfnT0kYB+yzVgSHn87hRfSub8MYVWaJdRL+WpipyflNXZIoh8fl/YQ4MMU hxiYm95uqF/bNOR2mx96TdbdT1NVHq4GImAWGKf8IHWbdAstSa0ejAnvTpz9mLIlOtxuybuU1h404 JfGexPMg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3Z-3ONS; 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 02/11] fs/buffer: add a for_each_bh() for block_read_full_folio() Date: Fri, 13 Dec 2024 19:10:40 -0800 Message-ID: <20241214031050.1337920-3-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-Rspam-User: X-Rspamd-Queue-Id: D274AC000B X-Rspamd-Server: rspam12 X-Stat-Signature: egc4jpzrudx3hcfzswknti6f1rg9uott X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145829-866680 X-HE-Meta: U2FsdGVkX1/CRE7YVDlsghunLDb1UJLhO0lGPT/O9zCPHLxMMA2jpY6f3l2d4W4PPAVWy+8zxluZOj0mnZ3qwxOsTg/izNVI3ID+/ZlzJ1ioHdUUopwJoYguIX/mi2lnF/AH95mz+USxgVvSPpW+NUHHrSopzzjnc90X1LUymmJIH4WuibpuaLrxLqD233hqYUTZpzqxyseSuG9EJ61ktVJQm1IoXkHYTfVFaAD+wdVuhlo084w9f8goRMsBL1ZGPmQ15rqtUALK2E4jXtV7uUp12uq5a5Pl2SsjMEFPNMHI4t6P0dSrvqZq5x2Ot3QejTrWHmZyLNv/TEC3cZ0TQTE301BMzpBrxartBXD4bUMZ+A+ie+DlHK0mkxflIw7DWMK9bYseRJyaPu93Dq8y3EOcr2qReeOpgWqgsnrHSRMN8F0Q3hd4ASI+Pup4gtytYjLjfkYANimYXTQZLwtaUlfD075lL7KnrMOjmXvWSGZOIF9+dCuqvcw0t70g691IfsLd1wsGkSYCaKlcYjxA0bYDjImMd+2B3v/w2pF1I1bGMVGm/S7wVRwOufCC0M7sJDIfk1ZwC4yiYIJVsSjSjdgWnkTyZ+aIJuCW4pcR7rFY5qrCYutNNz3osEIkn8C3+wHOCxuyKivxTo5c24CidpZQsAmJ2VX7J8fGOvPqUtBnx+H/5rLbgn/Wb6VJsE7laVAojV8K+rW7GfehUs55trw/cGJZXpNZlBnLcfatsmT1XTEHsOhT7y3i1A9G3wIEqiq6oizF0unX37xSZtEFAi36pXFFMOvpTI9OgIP9iJCa3mddKA2XG+gMDBYNF4RWD8j5YvX/qXRJlCopo1rnBzoA97n8nbUIfCYRXoJFI8fCelyxFl04rewXVurYPLhokqWpOYtit4zIFSb5c6ltKPxeWq3vWn0/nlRS4/+hqFpHydrv0dGDfu1qMdly/K1qgTGoz9rz1ImMK1h+f68 6hRAgRkS EgORhSH8UoEJc3rNM6++Zs6oIyhazskKA4byxYpYvqGK+xobac7KU1irLONqLlLn1pD9Q05r2L9mT59uleCIJaB+J6Am5kxJ0Lv+DzvWE214qHyaSuKSwFbQ+DGznzVeW6wi9Vq3inipo6sBklzcIPEV1dG1N1QiU+NsMPdq6QcZElLpyY6XnnvPfyqO4q15E7RWU3FjK82UT+LIy0ZZxHtBsXOaqgmOUoz2tvPrv9pAMU+/bwB0JmF7CTD/8U2DjDj5pAO9TLLJL02/LS8sT8HKyjhIjxSdje8daeRJIwMQtbzOcZoKwvLWUzXQwlyPrgRQheBTyusuVhVd00HDgT1VBpYwqgb/N0NaeH5HZhFcsKIIE+X5XlUT79VI6ybVEoihKkufaSo94QZlN5OqdFI4AkGrCvouVjYydgGNJpQt4OjgL01VZdQ8NB1ypoEOn5DNVziYNy0gu5nBLgSKy0rGrv2DdbdLZh8HTXUr/+iXWaSNEiwNPPoWlmmmOFIm3N1R58/nZNP6I9c15V1GcMFfwh/yR/laHQVfKzGrQJewauxk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.002869, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We want to be able to work through all buffer heads on a folio for an async read, but in the future we want to support the option to stop before we've processed all linked buffer heads. To make code easier to read and follow adopt a for_each_bh(tmp, head) loop instead of using a do { ... } while () to make the code easier to read and later be expanded in subsequent patches. This introduces no functional changes. Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke --- fs/buffer.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 580451337efa..108e1c36fc1a 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2392,6 +2392,17 @@ static void bh_read_batch_async(struct folio *folio, } } +#define bh_is_last(__bh, __head) ((__bh)->b_this_page == (__head)) + +#define bh_next(__bh, __head) \ + (bh_is_last(__bh, __head) ? NULL : (__bh)->b_this_page) + +/* Starts from the provided head */ +#define for_each_bh(__tmp, __head) \ + for ((__tmp) = (__head); \ + (__tmp); \ + (__tmp) = bh_next(__tmp, __head)) + /* * Generic "read_folio" function for block devices that have the normal * get_block functionality. This is most of the block device filesystems. @@ -2421,11 +2432,10 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) iblock = div_u64(folio_pos(folio), blocksize); lblock = div_u64(limit + blocksize - 1, blocksize); - bh = head; nr = 0; i = 0; - do { + for_each_bh(bh, head) { if (buffer_uptodate(bh)) continue; @@ -2454,7 +2464,9 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) continue; } arr[nr++] = bh; - } while (i++, iblock++, (bh = bh->b_this_page) != head); + i++; + iblock++; + } bh_read_batch_async(folio, nr, arr, fully_mapped, nr == 0, page_error); From patchwork Sat Dec 14 03:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908275 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 BD98BE7716A for ; Sat, 14 Dec 2024 03:11:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41F786B009C; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 386206B009B; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11DEA6B009A; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DAEB96B008C for ; Fri, 13 Dec 2024 22:11:01 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9D8A01C844F for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892087670.29.2AC07F6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf30.hostedemail.com (Postfix) with ESMTP id 1B53380006 for ; Sat, 14 Dec 2024 03:10:08 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VHdDK0Rw; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf30.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145847; a=rsa-sha256; cv=none; b=1grP4AJwQ2n7WVYV2Nbe9aH38QiYng+QiXzVKaCymhJ8R0UaPml3DtqdI+U913fEGpG4AN VUALdM7GDZxB5l48hSVvz9AcvIVnhJAuMDX5B7Uv2VZvkHtM39K8/Ohys0En5+dez2mY0a OMz4Culz6jukHuQ10Gt1wX5v98XU3xY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=VHdDK0Rw; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf30.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734145847; 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=17Q0gy/g/R6GF/kNACXWfTzKrmUaCrFTxm3DWtltqxI=; b=BQCw9Nozsy0CqMLj1RSkGLXfdaEEax4pWNK5+eLosE/MvU6BcfHlOtRdKBzazh2uUi1XVF 8uMCoSlLTbhV/9ql3EQDG/wWUOhf/hPSNNelDOJy+9kTTtzvsEvJwmTAsUragme4WqRVKG XkNu1fmcipHiDDw1z6D7XJLRirDjv9w= 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=17Q0gy/g/R6GF/kNACXWfTzKrmUaCrFTxm3DWtltqxI=; b=VHdDK0RwjffflcX0z4byIMeij+ aBC6gTkms+qYDlNfhyjSs4Iliz0FzPjXIe39juSBMwSojG8tpjFyDSN1F1sOdoq2Hbh9yXAmmtlOt usRJ2g2lmhXmusq/xZg+cKiTaGMTY+FQVlDo3OPNgLXemfBWpiTctwVZz8NZvXSWH9g8b9OeoGLXE 5H0355Vu+iAVkzf1E2XE6CSW/DqoZK/gq2UnpMD2T5zGEPbqz6W6d8F2PgzjrXvnaBVpXzpwxgwPW sLKjc5IS86MBxhWVC7oEkQMS+svl9Wx4GyxjP1KXnek3QBbi0tPj2ClewMr8FHSTRGQw/xqCPLI3r u9L99Mgg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3b-3W4y; 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 03/11] fs/buffer: add iteration support for block_read_full_folio() Date: Fri, 13 Dec 2024 19:10:41 -0800 Message-ID: <20241214031050.1337920-4-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: 1B53380006 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: udmkk5smitntzpd48grpd6sbkj3xxyfo X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145808-952775 X-HE-Meta: U2FsdGVkX1/5fpz0Tqrk7Kb2WPHs1Dv/DFcSVGimv2jhnf/ptB+p3UKyAbKmSddogiI2J7kV6QRR8LImoLjD3TfCe20GjH/EYYJqF13iZdr5C933DMTSYab/+848lSbknEziuSxD0gWhENBJmbj3VhdiW9Bajc0KaSZjcXlZIRivDyBLB4lA7jZPdDH0GdL0cdWIOQPKGoKlpmsj39ORbxU59av1mdqXa8gQlJfvtIzanJ7uxTZks7R+4/DLujJ5f0pCIBmGFjlrVi6+r8cS2/9vVW61AfPqZREswzE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9j2HvcO+unhu7MMKh9vLNC8RFf5nagjZ3n2LjR3MyQztcXDgniqI5bUjMjbBkDHfuxTm5wHo+qXM1WgfvhoAmuFvt8LKzOp+bhWp2FwHgM1YH/ZKFYS1kjYjRU6VruzipKBsqm6oFG2TvaEugKq93RV/TJz8cxXq87wYNlphOpLaBj+9yUVRM= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Provide a helper to iterate on buffer heads on a folio. We do this as a preliminary step so to make the subsequent changes easier to read. Right now we use an array on stack to loop over all buffer heads in a folio of size MAX_BUF_PER_PAGE, however on CPUs where the system page size is quite larger like Hexagon with 256 KiB page size support this can mean the kernel can end up spewing spews stack growth warnings. To be able to break this down into smaller array chunks add support for processing smaller array chunks of buffer heads at a time. The used array size is not changed yet, that will be done in a subsequent patch, this just adds the iterator support and logic. While at it clarify the booleans used on bh_read_batch_async() and how they are only valid in consideration when we've processed all buffer-heads of a folio, that is when we're on the last buffer head in a folio: * bh_folio_reads * unmapped Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke --- fs/buffer.c | 130 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 94 insertions(+), 36 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 108e1c36fc1a..f8e6a5454dbb 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2397,57 +2397,64 @@ static void bh_read_batch_async(struct folio *folio, #define bh_next(__bh, __head) \ (bh_is_last(__bh, __head) ? NULL : (__bh)->b_this_page) +/* Starts from a pivot which you initialize */ +#define for_each_bh_pivot(__pivot, __last, __head) \ + for ((__pivot) = __last = (__pivot); \ + (__pivot); \ + (__pivot) = bh_next(__pivot, __head), \ + (__last) = (__pivot) ? (__pivot) : (__last)) + /* Starts from the provided head */ #define for_each_bh(__tmp, __head) \ for ((__tmp) = (__head); \ (__tmp); \ (__tmp) = bh_next(__tmp, __head)) +struct bh_iter { + sector_t iblock; + get_block_t *get_block; + bool any_get_block_error; + int unmapped; + int bh_folio_reads; +}; + /* - * Generic "read_folio" function for block devices that have the normal - * get_block functionality. This is most of the block device filesystems. - * Reads the folio asynchronously --- the unlock_buffer() and - * set/clear_buffer_uptodate() functions propagate buffer state into the - * folio once IO has completed. + * Reads up to MAX_BUF_PER_PAGE buffer heads at a time on a folio on the given + * block range iblock to lblock and helps update the number of buffer-heads + * which were not uptodate or unmapped for which we issued an async read for + * on iter->bh_folio_reads for the full folio. Returns the last buffer-head we + * worked on. */ -int block_read_full_folio(struct folio *folio, get_block_t *get_block) -{ - struct inode *inode = folio->mapping->host; - sector_t iblock, lblock; - struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; - size_t blocksize; - int nr, i; - int fully_mapped = 1; - bool page_error = false; - loff_t limit = i_size_read(inode); - - /* This is needed for ext4. */ - if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) - limit = inode->i_sb->s_maxbytes; - - VM_BUG_ON_FOLIO(folio_test_large(folio), folio); - - head = folio_create_buffers(folio, inode, 0); - blocksize = head->b_size; +static struct buffer_head *bh_read_iter(struct folio *folio, + struct buffer_head *pivot, + struct buffer_head *head, + struct inode *inode, + struct bh_iter *iter, sector_t lblock) +{ + struct buffer_head *arr[MAX_BUF_PER_PAGE]; + struct buffer_head *bh = pivot, *last; + int nr = 0, i = 0; + size_t blocksize = head->b_size; + bool no_reads = false; + bool fully_mapped = false; + + /* collect buffers not uptodate and not mapped yet */ + for_each_bh_pivot(bh, last, head) { + BUG_ON(nr >= MAX_BUF_PER_PAGE); - iblock = div_u64(folio_pos(folio), blocksize); - lblock = div_u64(limit + blocksize - 1, blocksize); - nr = 0; - i = 0; - - for_each_bh(bh, head) { if (buffer_uptodate(bh)) continue; if (!buffer_mapped(bh)) { int err = 0; - fully_mapped = 0; - if (iblock < lblock) { + iter->unmapped++; + if (iter->iblock < lblock) { WARN_ON(bh->b_size != blocksize); - err = get_block(inode, iblock, bh, 0); + err = iter->get_block(inode, iter->iblock, + bh, 0); if (err) - page_error = true; + iter->any_get_block_error = true; } if (!buffer_mapped(bh)) { folio_zero_range(folio, i * blocksize, @@ -2465,10 +2472,61 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) } arr[nr++] = bh; i++; - iblock++; + iter->iblock++; + } + + iter->bh_folio_reads += nr; + + WARN_ON_ONCE(!bh_is_last(last, head)); + + if (bh_is_last(last, head)) { + if (!iter->bh_folio_reads) + no_reads = true; + if (!iter->unmapped) + fully_mapped = true; } - bh_read_batch_async(folio, nr, arr, fully_mapped, nr == 0, page_error); + bh_read_batch_async(folio, nr, arr, fully_mapped, no_reads, + iter->any_get_block_error); + + return last; +} + +/* + * Generic "read_folio" function for block devices that have the normal + * get_block functionality. This is most of the block device filesystems. + * Reads the folio asynchronously --- the unlock_buffer() and + * set/clear_buffer_uptodate() functions propagate buffer state into the + * folio once IO has completed. + */ +int block_read_full_folio(struct folio *folio, get_block_t *get_block) +{ + struct inode *inode = folio->mapping->host; + sector_t lblock; + size_t blocksize; + struct buffer_head *bh, *head; + struct bh_iter iter = { + .get_block = get_block, + .unmapped = 0, + .any_get_block_error = false, + .bh_folio_reads = 0, + }; + loff_t limit = i_size_read(inode); + + /* This is needed for ext4. */ + if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) + limit = inode->i_sb->s_maxbytes; + + VM_BUG_ON_FOLIO(folio_test_large(folio), folio); + + head = folio_create_buffers(folio, inode, 0); + blocksize = head->b_size; + + iter.iblock = div_u64(folio_pos(folio), blocksize); + lblock = div_u64(limit + blocksize - 1, blocksize); + + for_each_bh(bh, head) + bh = bh_read_iter(folio, bh, head, inode, &iter, lblock); return 0; } From patchwork Sat Dec 14 03:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908279 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 82CD0E77180 for ; Sat, 14 Dec 2024 03:11:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 157E66B0092; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1FBD6B0096; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F896B0098; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0AD1A6B0096 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A7E6F81525 for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892087166.22.D1FC7DF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf19.hostedemail.com (Postfix) with ESMTP id 81F751A0016 for ; Sat, 14 Dec 2024 03:10:31 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DUwsEwV0; spf=none (imf19.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145835; a=rsa-sha256; cv=none; b=fPn3yYZkyipR49ELQKz+8kwjtk0XuTPQOQNmwij6j36keMLHsA/zMbaqxwU752Ut6P0rSz dzVwSuTwCirBnIS9QsXJUV3jzBK9Y6PweCt0MuzMat7bDBUvBas5s0PHNYDgNvrWu+LRJX j0zSxxKvtEzWEEdVNHOg8HlenZUT2jc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=DUwsEwV0; spf=none (imf19.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=1734145835; 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=7VkY/OzBoZXEa2cuwiycPcKImztiWgLu3Zlcz14G1p4=; b=7REC52dKhYkghyS6qqCVDmch5uUaReUHjVsz/hO8TxPHIMbPfPA7cev7G1It4Gq7e3/X6Z W1AHS622E7/IMuQ+nZ6tiuR5qZdnvivUYENlduPqeU5g6eCJmlkaC3iA2OpXcbQs75VhfG gXGGgKRYML+euPItsSw/qxnRblkm4Wg= 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=7VkY/OzBoZXEa2cuwiycPcKImztiWgLu3Zlcz14G1p4=; b=DUwsEwV079VBpxwAvrs6U6I8Cu +yB5Af7X5dyJDHK+0BxH0M7EaxriNLYaJvIdNxNvPOrYxYSQH/jU6jB8GynWgvVdzNF+teFgMqOkz mjPRr02cXWTdhinHpXpBhT4dzbeSTZFB7pJuqYAnEpNKz8fKfY9zR9r1IIknCnCbVnL2MuibGND6h Zeje92OBV13LXKmVEQ6HFBf9qbrjM5QFgsqwfDPfPRBUdVSwCTMN+0mmrrEp5a7iPTJDQkb1vIBl1 IWJrME7NwGx/w9FAz1UoW5zrg8+kESNsILRCVqNAQZjRAt/wB6HzCQ9sloAPF0+rCThoEaLmed8nf eYOcYkpA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3d-3dl7; 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 04/11] fs/buffer: reduce stack usage on bh_read_iter() Date: Fri, 13 Dec 2024 19:10:42 -0800 Message-ID: <20241214031050.1337920-5-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: 81F751A0016 X-Stat-Signature: dd7uefncthrikobm6a779s96sigetf79 X-Rspam-User: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspamd-Server: rspam09 X-Rspam: Yes X-HE-Tag: 1734145831-291350 X-HE-Meta: U2FsdGVkX19MLWjYnImmrLpdopi3Cb2qrhT6Mc8t6kvYGgMOzVT1fJsWaRQb/OCg7nS5kr1u2sAdaUqYWcKku+7orDGoLQB31BT7iW1/pfuLWJRrfVVqHfqq8kyqlPgAl5AHY+ykSUZSzTywkLNHpxK7yYv3RTNTun2+HEfhB5ynVmO2oUQfrDgMJLHG1POGhE04DV6Zg66lPffxsTPaNyBsHI7R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wLyUTlBpvCm8zbsRxq8xqL7vEG3JH0nNMcYTlFPSDG7KJgNXcMOPYR4pQA7fz6nmab5e+kH3lO5PkV/DilW0PjQLgiqY6WlQ2IS5P7dxDHne8hz8NopTaP20PhnMlUpoJPki7Ge0AeTJxdM36/cPyVSFOVoUub2+OzVkXQ1CXkAM1k2JNeTcU8D+YXi/0mn/1UjnBdEP5cbQTkhn7Rq33B7mkth7p5MTiciOegz+d2jtVI4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that we can read asynchronously buffer heads from a folio in chunks, we can chop up bh_read_iter() with a smaller array size. Use an array of 8 to avoid stack growth warnings on systems with huge base page sizes. Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke --- fs/buffer.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index f8e6a5454dbb..b4994c48e6ee 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2410,7 +2410,10 @@ static void bh_read_batch_async(struct folio *folio, (__tmp); \ (__tmp) = bh_next(__tmp, __head)) +#define MAX_BUF_CHUNK 8 + struct bh_iter { + int chunk_number; sector_t iblock; get_block_t *get_block; bool any_get_block_error; @@ -2419,7 +2422,7 @@ struct bh_iter { }; /* - * Reads up to MAX_BUF_PER_PAGE buffer heads at a time on a folio on the given + * Reads up to MAX_BUF_CHUNK buffer heads at a time on a folio on the given * block range iblock to lblock and helps update the number of buffer-heads * which were not uptodate or unmapped for which we issued an async read for * on iter->bh_folio_reads for the full folio. Returns the last buffer-head we @@ -2431,16 +2434,18 @@ static struct buffer_head *bh_read_iter(struct folio *folio, struct inode *inode, struct bh_iter *iter, sector_t lblock) { - struct buffer_head *arr[MAX_BUF_PER_PAGE]; + struct buffer_head *arr[MAX_BUF_CHUNK]; struct buffer_head *bh = pivot, *last; int nr = 0, i = 0; size_t blocksize = head->b_size; + int chunk_idx = MAX_BUF_CHUNK * iter->chunk_number; bool no_reads = false; bool fully_mapped = false; /* collect buffers not uptodate and not mapped yet */ for_each_bh_pivot(bh, last, head) { - BUG_ON(nr >= MAX_BUF_PER_PAGE); + if (nr >= MAX_BUF_CHUNK) + break; if (buffer_uptodate(bh)) continue; @@ -2457,7 +2462,8 @@ static struct buffer_head *bh_read_iter(struct folio *folio, iter->any_get_block_error = true; } if (!buffer_mapped(bh)) { - folio_zero_range(folio, i * blocksize, + folio_zero_range(folio, + (i + chunk_idx) * blocksize, blocksize); if (!err) set_buffer_uptodate(bh); @@ -2476,8 +2482,7 @@ static struct buffer_head *bh_read_iter(struct folio *folio, } iter->bh_folio_reads += nr; - - WARN_ON_ONCE(!bh_is_last(last, head)); + iter->chunk_number++; if (bh_is_last(last, head)) { if (!iter->bh_folio_reads) @@ -2507,6 +2512,7 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) struct buffer_head *bh, *head; struct bh_iter iter = { .get_block = get_block, + .chunk_number = 0, .unmapped = 0, .any_get_block_error = false, .bh_folio_reads = 0, From patchwork Sat Dec 14 03:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908283 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 03E67E7716A for ; Sat, 14 Dec 2024 03:11:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B52F96B009A; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8895A6B0098; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D4D96B00A0; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D5F536B009B for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 919E61614FA for ; Sat, 14 Dec 2024 03:11:02 +0000 (UTC) X-FDA: 82892086914.25.4FA92B4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id 8A0941C0011 for ; Sat, 14 Dec 2024 03:10:10 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=KMN4gb6Z; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf21.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734145849; 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=aEpOv6XaftX3uxnh2wMZL90wJOkQQ8bIBff4iQiKj9w=; b=u0VJmpJ9/FwN7Nh5/ZDSQVArDHN4uW16qVebNRMCnmkgqDy3pSbpzRS/mbHaobEwsMvkLZ PrvnSiB86dQQ4o5QiTaJVYMmlt7AXIZ1o9oYhCH9DdmR+EAvyBHKvgxg7uT7mcfL0Ex2Yw 4BXCkrddYimyEm8BL6REbUCoWbOQprM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145849; a=rsa-sha256; cv=none; b=ZeFJw8/FHIOqEzR96C5F9d4EoUzkKVTySqdP8kGWg25OXMTzZmbG+pIVtpOiia7MOy1YID lY+Se3GVXGaGkS3TeSGoHOwrM2vhmhlhEz+3WP7ltI63a8nX+tnVvwkBuXvKNAVku5t5cJ Z2VimbUzAHvsYDH8T7DF9o4OoCIYphY= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=KMN4gb6Z; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf21.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org 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=aEpOv6XaftX3uxnh2wMZL90wJOkQQ8bIBff4iQiKj9w=; b=KMN4gb6ZeBQRXIMA2XWLrKJJTB pIrG5Ktc6U0DoQagUaj+ERQm4kWG6cF1ajtuJOl+EJiecSkCWL9GXyRhAqZ8ZxcVm5Ksv1I2pnswt r6gbCfon+8RrA6makCRyTq2s0qpzICufK3Qdj8xWAgQIDdTUDKoS4c33yXNnUZpXL4wCwSX9r/B9c hHzYuYWPTofuLhGoDbCXe3VE6cNZaovjbad0tLE8otQao0h9gB4kQjPsLXho3oceM3qHgMlt8Y4YJ mJCX7XB9nldEhu4yn8HzaTcJBc+Nt3SIbOIF0mF3fra3/ckrLLzox5hRBSOxXp+dSRHwWfcMvFi46 KK9ACr9A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3f-3maB; 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 05/11] fs/mpage: use blocks_per_folio instead of blocks_per_page Date: Fri, 13 Dec 2024 19:10:43 -0800 Message-ID: <20241214031050.1337920-6-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-Stat-Signature: bm7aqytbdccnm76rki1uzzdbsfo45wxc X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspamd-Queue-Id: 8A0941C0011 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspam: Yes X-HE-Tag: 1734145810-326647 X-HE-Meta: U2FsdGVkX19wQSBNpikhZAO9/0QM/O47abyvm2jIaUnGhh1Df1UQ1FMfpjxnvVa0s2Lhrkm/StcoVB+8UqU4RYhTrWOyBlukokoSZwVcc5GUOJbBd2zAKsGnymx9ho1Q6IfGhQn7INrv2eaT/R+hXMBFnSt3yDTZnfD0T+mfm/xkGHHsRZU91E3xe6xXg+zmT7LIDG+yQ1Q9quf3w5JndMXAwvU5BkJWe6hYC0JylTfdUhPTkiWjwIp0RXpbPhU+gzjPSVeqArou/j7ePFMaSCois8whZFi5FTcNCO3unL73Mn8kZD2iukH8PgApJU7s1DLsbmdEUjq2z2EhYoaYLc/vldl76U+tFClG2HRwmruna1+Cfp4o2XiSRBdAj4J/deJxqVsWzXgela9an0sQKvR561Uj1DEAWw34tM+an2DY1wyKQRS7xwJDAENwlZ+niZh10Qj9gOu09i6CKsB2Z3KxEFTnK3xrCglJM2QtzTUeRb5F4GSaytgJjz1gGujibW1mdvI8sIn34grkBep1FnnLfiu3P0keXPLPpf7CilgksMA026uBRVh0b5cRtElXOVA6Se+i/dDQoVJ4VRwPTvsPolQqGPwhyh9PPs9KqhBrhnsPyLhrpH8Ebu2DdMqj6NiiY+N25dijngDS4UUFU6qfB+LxOp1G/+NVEzz4FUtv938bnrBZMN+J4EVb7TzZwWqzR8WKXMBjah64Xnyi3oiDA7h18artgue3Vw5ayJrWOr5rao3coXYOSbcb5ulkm2xc4c2wdO4bpJMx5DWwuwfZCCjFZkgFVRhXdOw3Riag8l4s71dbP7/Z6HbWQwCcAOAWBLhgkCp+Y3qDm1rovpWo8a3qHoBhk07UmWWAwaIk1g8hshTWhyT6BvIWrHy2l3bEJG76e8Pw7LgDH635/op28wdDF9tQ6T0Q0l7fwHdoA2QFgW00IMs4GdGAExweAkDhwcJCS68kAla9ID8 8siBE0NJ JSDz7ml3ys5vOkSz8SSGDu2rJf7cJokfCpT9S3GhLhvVu7XqCQ047M2rH+AC8zl7Y1+1kigQbsxKkUI/BxjvolVsfH6j7WQSSqX5w875Wtx4P/oJeIlEOWIZouPBEqdhOnWnYdDKPdkBv9PCEwt8Nf6UlKL0Hq8vDDjU5/cWamheQ+cCwNoHgAq0KhZdO5tjhlpnJ8us33d7WwzQvFqTZAUffHLndrFEDnwo0jvx7vfBdGtBWEI4JE0sUA8qRtSbtBtN1pgzYVJyutFTmcAKSdyIWV5qLHQ6Gf8JyEi4WFJgkLBgsC8jYjuPxOCufeQ18LZtLJdOF9XRKpvkunEmE04oDTzZdbELy+mHh7FQqoklkdn458LjTD4cXRwtlNKEYLds/Wi+B++jsOiYiv8MMgThl7S/WJa0Ata4xhDDtDqsK4mBZmE2PyKN83oL9CwSycYApffwKIjZTR2cY2WxG/X6NqSc10ITqYqnkvnm9JLP0802Yj4pzaPAvq7xGMxnul8YcXoRB2gjDJbg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Hannes Reinecke Convert mpage to folios and associate the number of blocks with a folio and not a page. Signed-off-by: Hannes Reinecke --- fs/mpage.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index 82aecf372743..eb6fee7de529 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -107,7 +107,7 @@ static void map_buffer_to_folio(struct folio *folio, struct buffer_head *bh, * don't make any buffers if there is only one buffer on * the folio and the folio just needs to be set up to date */ - if (inode->i_blkbits == PAGE_SHIFT && + if (inode->i_blkbits == folio_shift(folio) && buffer_uptodate(bh)) { folio_mark_uptodate(folio); return; @@ -153,7 +153,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) struct folio *folio = args->folio; struct inode *inode = folio->mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_SIZE >> blkbits; + const unsigned blocks_per_folio = folio_size(folio) >> blkbits; const unsigned blocksize = 1 << blkbits; struct buffer_head *map_bh = &args->map_bh; sector_t block_in_file; @@ -161,7 +161,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) sector_t last_block_in_file; sector_t first_block; unsigned page_block; - unsigned first_hole = blocks_per_page; + unsigned first_hole = blocks_per_folio; struct block_device *bdev = NULL; int length; int fully_mapped = 1; @@ -182,7 +182,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) goto confused; block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); - last_block = block_in_file + args->nr_pages * blocks_per_page; + last_block = block_in_file + args->nr_pages * blocks_per_folio; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) last_block = last_block_in_file; @@ -204,7 +204,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) clear_buffer_mapped(map_bh); break; } - if (page_block == blocks_per_page) + if (page_block == blocks_per_folio) break; page_block++; block_in_file++; @@ -216,7 +216,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) * Then do more get_blocks calls until we are done with this folio. */ map_bh->b_folio = folio; - while (page_block < blocks_per_page) { + while (page_block < blocks_per_folio) { map_bh->b_state = 0; map_bh->b_size = 0; @@ -229,7 +229,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) if (!buffer_mapped(map_bh)) { fully_mapped = 0; - if (first_hole == blocks_per_page) + if (first_hole == blocks_per_folio) first_hole = page_block; page_block++; block_in_file++; @@ -247,7 +247,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) goto confused; } - if (first_hole != blocks_per_page) + if (first_hole != blocks_per_folio) goto confused; /* hole -> non-hole */ /* Contiguous blocks? */ @@ -260,7 +260,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) if (relative_block == nblocks) { clear_buffer_mapped(map_bh); break; - } else if (page_block == blocks_per_page) + } else if (page_block == blocks_per_folio) break; page_block++; block_in_file++; @@ -268,7 +268,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) bdev = map_bh->b_bdev; } - if (first_hole != blocks_per_page) { + if (first_hole != blocks_per_folio) { folio_zero_segment(folio, first_hole << blkbits, PAGE_SIZE); if (first_hole == 0) { folio_mark_uptodate(folio); @@ -303,10 +303,10 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) relative_block = block_in_file - args->first_logical_block; nblocks = map_bh->b_size >> blkbits; if ((buffer_boundary(map_bh) && relative_block == nblocks) || - (first_hole != blocks_per_page)) + (first_hole != blocks_per_folio)) args->bio = mpage_bio_submit_read(args->bio); else - args->last_block_in_bio = first_block + blocks_per_page - 1; + args->last_block_in_bio = first_block + blocks_per_folio - 1; out: return args->bio; @@ -385,7 +385,7 @@ int mpage_read_folio(struct folio *folio, get_block_t get_block) { struct mpage_readpage_args args = { .folio = folio, - .nr_pages = 1, + .nr_pages = folio_nr_pages(folio), .get_block = get_block, }; @@ -456,12 +456,12 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, struct address_space *mapping = folio->mapping; struct inode *inode = mapping->host; const unsigned blkbits = inode->i_blkbits; - const unsigned blocks_per_page = PAGE_SIZE >> blkbits; + const unsigned blocks_per_folio = folio_size(folio) >> blkbits; sector_t last_block; sector_t block_in_file; sector_t first_block; unsigned page_block; - unsigned first_unmapped = blocks_per_page; + unsigned first_unmapped = blocks_per_folio; struct block_device *bdev = NULL; int boundary = 0; sector_t boundary_block = 0; @@ -486,12 +486,12 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, */ if (buffer_dirty(bh)) goto confused; - if (first_unmapped == blocks_per_page) + if (first_unmapped == blocks_per_folio) first_unmapped = page_block; continue; } - if (first_unmapped != blocks_per_page) + if (first_unmapped != blocks_per_folio) goto confused; /* hole -> non-hole */ if (!buffer_dirty(bh) || !buffer_uptodate(bh)) @@ -536,7 +536,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, goto page_is_mapped; last_block = (i_size - 1) >> blkbits; map_bh.b_folio = folio; - for (page_block = 0; page_block < blocks_per_page; ) { + for (page_block = 0; page_block < blocks_per_folio; ) { map_bh.b_state = 0; map_bh.b_size = 1 << blkbits; @@ -618,14 +618,14 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, BUG_ON(folio_test_writeback(folio)); folio_start_writeback(folio); folio_unlock(folio); - if (boundary || (first_unmapped != blocks_per_page)) { + if (boundary || (first_unmapped != blocks_per_folio)) { bio = mpage_bio_submit_write(bio); if (boundary_block) { write_boundary_block(boundary_bdev, boundary_block, 1 << blkbits); } } else { - mpd->last_block_in_bio = first_block + blocks_per_page - 1; + mpd->last_block_in_bio = first_block + blocks_per_folio - 1; } goto out; From patchwork Sat Dec 14 03:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908277 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 9817DE77180 for ; Sat, 14 Dec 2024 03:11:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3C726B0095; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94CA16B009D; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706456B0095; Fri, 13 Dec 2024 22:11:02 -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 0C6D66B0099 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9C48412153B for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892086830.27.8419A31 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf13.hostedemail.com (Postfix) with ESMTP id B4B8320016 for ; Sat, 14 Dec 2024 03:10:33 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AaqLnJlB; spf=none (imf13.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=1734145831; 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=fu2uu1E/hdWYAQ+oUve2n/osalBR9KfPKW7YQSw9qoM=; b=cHd2d/Fq7RiMqnrwRwLbkDG4tckpRSZ/QmM33P4OtX0HDOtiq3JNhZwc7G5taAoHFH5Wof rNycJTpRw9BGfmQNvnl1We/3WHKwaauKIodm3yQ0SZQ5jqGflGMFJ9tQsqCnZtEHMa8mr2 VTGaGSYB37cvNe3IfkVoqKIO+zFjdgw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145831; a=rsa-sha256; cv=none; b=iUSTJCrB1IfBY334XEOIWyNbe6pWUFb3ZKVwTtr9kAAiVpIUGvRTDaZeisJZsiH7MN/+Lg GfIzmJWZ5D1xRzFrhRnlK/lRU9diglccJhbjIZcoruacLjUExOMX5MRfKOEYQAJ5ofZwDQ GGLPsu487YHi0GPSE2LtKFsoWwBcI8s= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=AaqLnJlB; spf=none (imf13.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=fu2uu1E/hdWYAQ+oUve2n/osalBR9KfPKW7YQSw9qoM=; b=AaqLnJlBZdgAEm5L97UO99Elg9 nSwRtJ5Oh3gR4SidRU6mFt90VVz+uswm/DRZRf273o490Dg0O6HfiZRMrUUTBIgcA6OuPe89DR+Vg vaQkWlNILmOXkYnVsWtisqS9qNdmSsIeFG8chQ5k17HhmQk8rCRVwKhiO9O1nCDo7QkMNiFt7Yh5J uPSFIk/Lz/RQS3axKLBxUkRTvMoMh+lSyCmjjB904f1VhaIBtKABlUHxaYW8D8E1rb5iszDDWVX1Y HPuyapGGhV0myArKMLDbpY+SLDfnwInKpoU2vRMF5hG0ZLB07t0T2nEWCJx2uFiVKZiqy6/VE3B2q 0Mw72q5Q==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3h-3us2; 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, Hannes Reinecke Subject: [RFC v2 06/11] fs/mpage: avoid negative shift for large blocksize Date: Fri, 13 Dec 2024 19:10:44 -0800 Message-ID: <20241214031050.1337920-7-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: B4B8320016 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: icrwifb6p3aabkwc49dyiewkswc4gsq1 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145833-996262 X-HE-Meta: U2FsdGVkX18xUCge+8LVUE5iyP3KCVFqXAh21Dw0NdnXbAWkjYWPVtN1S/TE0FB4tLiEa2bSu4jDCRkzMWTqAg+a/yFiLxLExqWr5HiFaQYHXmHHZAT2DecOBXWHvtmk624Z1DJ2Rku64qHKY2dyIcOeIsFBBrtifB5yB2VWELKcZgu2w4JaFdpKCjzmXOsDlvtiimBbs0ogaGYTsM80OA9iC3NKLMu3RgYMu0shGSr/z0SRr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rzlPx52Ls0dRCR67iVSOSuK2HlvsPq2faEtzgYOTdgI/ymvMxomQxRCmmhqIg7pN4DQGt4eeEFBUL6uPNFxwD2y2ahOJrJUkPf0HmxI8fPcF1nq0FbFSo2GMHUSLY7C38VX00QIiABIw4KaK0sbPWz9PjajHIRBA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000021, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Hannes Reinecke For large blocksizes the number of block bits is larger than PAGE_SHIFT, so use instead use folio_pos(folio) >> blkbits to calculate the sector number. With this in place we can now enable large folios on with buffer-heads. Signed-off-by: Hannes Reinecke --- fs/mpage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index eb6fee7de529..c6bb2a9706a1 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -181,7 +181,7 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) if (folio_buffers(folio)) goto confused; - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = folio_pos(folio) >> blkbits; last_block = block_in_file + args->nr_pages * blocks_per_folio; last_block_in_file = (i_size_read(inode) + blocksize - 1) >> blkbits; if (last_block > last_block_in_file) @@ -527,7 +527,7 @@ static int __mpage_writepage(struct folio *folio, struct writeback_control *wbc, * The page has no buffers: map it to disk */ BUG_ON(!folio_test_uptodate(folio)); - block_in_file = (sector_t)folio->index << (PAGE_SHIFT - blkbits); + block_in_file = folio_pos(folio) >> blkbits; /* * Whole page beyond EOF? Skip allocating blocks to avoid leaking * space. From patchwork Sat Dec 14 03:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908284 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 AC4DAE7716A for ; Sat, 14 Dec 2024 03:11:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D15226B0098; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD4F16B009F; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 701316B009A; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id E3BEC6B009A for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8FF0A141679 for ; Sat, 14 Dec 2024 03:11:02 +0000 (UTC) X-FDA: 82892087082.21.98D5A86 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 6D22F180006 for ; Sat, 14 Dec 2024 03:10:57 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QyQwMKci; 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=1734145840; 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=sbicKkEIU1GP8SA/RwQPAcQQ45CmcRGRebxtvNHMUlw=; b=Kk6Bz2Gy4BkOJI4JtoV0sH72nHeb2yU5QrVUH5zLh/oeZRHBPEwtkx8FIWKBEWqUhEIbXM 44uYP0k3VL77yalHJYjQQqaAdU3uCUH6Qw0zGzr+sMB6tZjbSuQb+CGmZ6mDF0EZIp5Mwd R5aC/JbillNnfKvvQr3wpt6pQzZH11E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=QyQwMKci; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145840; a=rsa-sha256; cv=none; b=M3C7CDD+XUWRIMIHpXeEhnMMpoDbgOI4TMz8+G13o98p+NrXw/GjveLJ4P3vGVXbM+viRX lMbzfumZMHJtfYSctMzJNhVugz9znHcjoBptuq4F5bNVmkEMhzc0T+VpXDvI5HY66FlCln JBKpP9E59NgBUWI5X+VggPWN2Ew6ow4= 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=sbicKkEIU1GP8SA/RwQPAcQQ45CmcRGRebxtvNHMUlw=; b=QyQwMKci1SqqFVKwrphSBzYf7/ Kpt9D/juXjczuPs656dIQuZkABPk6iOh6ydyQfGcB5HaXY2bllFf74fF0ENUyoB2UlRvo3XSz0KEz mxuqbJyUulQ5iwka2He1evk8XYb4OsjtZJXxyiBYzHqFBcLMrPHH3yi2xLBo3cR2aEmq+hISCQM91 dhM6+dSdz+2+MMZXeGS1uRFB+JO0vyRAwGA2jWCWZExWukPikTyRnjV38M32dXiAuPD/YxikEzEfQ ECcMOBlpHDPO9S7qSoYieXOOvRSx5o9fQ+doAZwsSFn7gbseriWxxJgXbzDRPGPhKQ+3fk4VzrNdi htcjBV+g==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3j-42bm; 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 07/11] fs/buffer fs/mpage: remove large folio restriction Date: Fri, 13 Dec 2024 19:10:45 -0800 Message-ID: <20241214031050.1337920-8-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-Rspam-User: X-Rspamd-Queue-Id: 6D22F180006 X-Rspamd-Server: rspam12 X-Stat-Signature: bbb6xa1s961zbhbkg4z3jqdqhqgk7dxi X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145857-995892 X-HE-Meta: U2FsdGVkX1/ECJKnkySaEJNyjXdfW7f/Gj8tfGpP6S0Lw7xEefZm2yDV5YmFd9Aw8FIyZ8cT0kshPh7esCB9wrnzoEARdeFBJCcWRaY/wXtuimmQmp4ptkivj0jf1Q8IRDEpG8a5RSqOsMfUUN9mLO/Rv9dRW37QEjpwtEGdJuIfQPmI4IVdpsrl6MbVOFGNon1qQWO0IDB3qmre6eNJeNVQqFWtQFbIZl0XHqK/VIBwTk5l+oYI0D/vkD4f9oR59JqUf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vzp7+mI2xYh7HEI9pkWLG7Ocg9JwuYteHmQZrTTcK5mnoHIOYGBVdLZre0VAnTL2/N/4325ovLGM3GfpSoGta3sgoGyzYMw+dz0wSzbSZTUNuTalPQQhgyn5e5WsCse0CSyyjVDoHZApnqfzLOH5A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000510, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Now that buffer-heads has been converted over to support large folios we can remove the built-in VM_BUG_ON_FOLIO() checks which prevents their use. Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain --- fs/buffer.c | 2 -- fs/mpage.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index b4994c48e6ee..4296bfb06fb1 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2523,8 +2523,6 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) if (IS_ENABLED(CONFIG_FS_VERITY) && IS_VERITY(inode)) limit = inode->i_sb->s_maxbytes; - VM_BUG_ON_FOLIO(folio_test_large(folio), folio); - head = folio_create_buffers(folio, inode, 0); blocksize = head->b_size; diff --git a/fs/mpage.c b/fs/mpage.c index c6bb2a9706a1..c1b85be8df64 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -170,9 +170,6 @@ static struct bio *do_mpage_readpage(struct mpage_readpage_args *args) unsigned relative_block; gfp_t gfp = mapping_gfp_constraint(folio->mapping, GFP_KERNEL); - /* MAX_BUF_PER_PAGE, for example */ - VM_BUG_ON_FOLIO(folio_test_large(folio), folio); - if (args->is_readahead) { opf |= REQ_RAHEAD; gfp |= __GFP_NORETRY | __GFP_NOWARN; From patchwork Sat Dec 14 03:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908310 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 7E5CEE7716A for ; Sat, 14 Dec 2024 04:19:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB5716B007B; Fri, 13 Dec 2024 23:19:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C667F6B0083; Fri, 13 Dec 2024 23:19:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B53506B0085; Fri, 13 Dec 2024 23:19:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 97D506B007B for ; Fri, 13 Dec 2024 23:19:29 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0370A817FF for ; Sat, 14 Dec 2024 04:19:28 +0000 (UTC) X-FDA: 82892259198.03.A90EA3B Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id 4B5E7180004 for ; Sat, 14 Dec 2024 04:19:00 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="rBgMS/ly"; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf16.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734149955; 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=rV5AoYJPlny/7wnGoBOtLs3pAmaEJ9e3y3MRINCsK0A=; b=2hL6nEtJL7FLwG3rCrb8mHqO6qAlloXL4ZTlnZQQCj/inIRER39JVw6Pys9OfRRF1biIOe WpXr+REFqXKJe4W4qy+LLoqH9NM7fJppatakr51dhYMN+mztcTSyaRdQgJqmZrcRBozTz3 zNPmks7gY7QUVtB/Iz/D+1HXo0qiGZ0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734149955; a=rsa-sha256; cv=none; b=OLpPnGClUDwlhduwk7xvyOVbuQ7SJTck7WDJcke48qw2KQ5Zv9hZtLWkqYV6IGxG3gdxLO HZnoCs/nzJDGMuD+3bX3aOjSrp5n6M8COq1OxE1AAQ44ubD+oDcUG6nB1vkYzGJWGnqGcC Bv/YVVrcKiLzFRmNIKjNebZX9kiTocI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="rBgMS/ly"; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf16.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org 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=rV5AoYJPlny/7wnGoBOtLs3pAmaEJ9e3y3MRINCsK0A=; b=rBgMS/lyjy3Ti+VMrwe1JNxiA8 eR0POwBQ7F9I7u0BreYHGzLgGHYo5au1bZKC4A+0HUDXIRpEPtKNdKPl/hg3NYWSWTTwsbxN1CFmk u4en09SHB4VOE44Qb3533cdPHpRkd9NUC5ozc6o1GJdedziqFC57uH9xNYHFqkHE3dHjwfOGvIIeK 7nV7Nug+EBDp5bnSB4J2mRCG6dhkXiUkNic0zADTIySpUwYdJqcqKKaesr25P1UGq21cts4hwc9ib mtMiz46VjuC3+q9iEz0GBO8iSLgOZcuy4HAHH1DYHuDv32yDA8/NKuGE2fj3/LwlDnmWlwrJ8d5SA fNZXHcCg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYN-00000005c3n-4A6d; 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 08/11] block/bdev: enable large folio support for large logical block sizes Date: Fri, 13 Dec 2024 19:10:46 -0800 Message-ID: <20241214031050.1337920-9-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-Stat-Signature: m4t9y5sqxddodqjdh8fkx94y5r3koejb X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspamd-Queue-Id: 4B5E7180004 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspam: Yes X-HE-Tag: 1734149940-767348 X-HE-Meta: U2FsdGVkX18ak5MEzUcm7uIwsoDROb2OtgpaCh3GS7q6BH1ypranmocLP3Y6MRrj/9e5XWksagr12bV0o71n9k9xuXz+j8sYCxVT1qCCUxQSxliMykcNtFH0Z28qOjcvVk9bEigP1aaU+MNV11YD+BWPUW7WfeX9kkIiap7nd+4avuLRdzlaA8WgMhVgAcuAYJLAVkpKW+OGg7K7/BGOf1DdkRWuQGkFqNytTZun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FnmJPVfT+ytI9sKmS1XCusnEoCTfUfckwbBhs7cAXT5lsDV9+f595+NOla8o32zF1oyG63P+pzrag6MLiF7UUizVbjq2vv37QnQ/MZKl9zHTKFarHNSJiKwO+a54TT0v9VdiW0fNQ+RVEpgUXKzmt+1A1uz6pkXRWLjkaMDS/7e X-Bogosity: Ham, tests=bogofilter, spamicity=0.001423, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Hannes Reinecke Call mapping_set_folio_min_order() when modifying the logical block size to ensure folios are allocated with the correct size. Signed-off-by: Hannes Reinecke --- block/bdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/bdev.c b/block/bdev.c index 738e3c8457e7..167d82b46781 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -148,6 +148,8 @@ static void set_init_blocksize(struct block_device *bdev) bsize <<= 1; } BD_INODE(bdev)->i_blkbits = blksize_bits(bsize); + mapping_set_folio_min_order(BD_INODE(bdev)->i_mapping, + get_order(bsize)); } int set_blocksize(struct file *file, int size) @@ -170,6 +172,7 @@ int set_blocksize(struct file *file, int size) if (inode->i_blkbits != blksize_bits(size)) { sync_blockdev(bdev); inode->i_blkbits = blksize_bits(size); + mapping_set_folio_min_order(inode->i_mapping, get_order(size)); kill_bdev(bdev); } return 0; From patchwork Sat Dec 14 03:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908276 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 48E2BE77183 for ; Sat, 14 Dec 2024 03:11:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 709676B0099; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61E8C6B009E; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41CD96B0095; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 090266B0092 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AE8351A14AD for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892086704.19.12ED45C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id EC329160009 for ; Sat, 14 Dec 2024 03:10:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qL6vJdTy; spf=none (imf08.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=1734145842; 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=nLfCbW88XZtUGGKLjWBTHyDCe42vAPNXKRBtJR7DxnY=; b=mrIS6++Ar6Ude0wEmFP5BbF/uExXJoWqOdRFvV8EOvLCSDfNWFDcVy+AkhOirXDjg2l8aw Dl7NQS1eHItUoTDi74ilw+BzZE/w5xGa9rDHnp3w07C102OI3kFjlFMdSilzMIdT2Sww+j caNjuSkkMTjebNI5PzAZ6Dksjp8TFUo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145842; a=rsa-sha256; cv=none; b=pykjFh182UJy4dLujQEQPZJ9OLqwxua8wH4FPB2HqKWIOKieA7zEchZRZroBZq5HMtH7md R++P2lPx92CH8gGza+qtUn1oKBBJiPx0CI6RQ4W7CkjaoX2kS7oQDyQGQTM3DxVJrsdS/q rYTPREKfvWrIKFrtq8uct/+drbJeCqE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qL6vJdTy; spf=none (imf08.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=nLfCbW88XZtUGGKLjWBTHyDCe42vAPNXKRBtJR7DxnY=; b=qL6vJdTyzDGrY9BTzxUAOzoxWR GmyxjXs/ypIzQ4OBwJwjxzVHxTYl5WowwA8PlpzdvxsYCfAWKCxVKGzklNbFg+j9lyRrusBf2H2bo GLkVMnOTVZV/lpZd85GFZ1MVi81ANkvcUeR+JJE+WC+Wr3Z0gWG3fCONYfibpZ6l3jyduDgskVKBw zGXlDz4JQevtASwNKCWNnNAOsApI5OkuvhXNNNIaNtVIY0GOanrmRiewmyM4XTWoW+VYaF9Ch6GO/ jAb+ekAcuFvILM50r3oh8PDu2OVvOax56B8d0fV1YdR3Auj0Fd26/gnSmPf68M1AcX68Sws/msj8r Mx/t0qRA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYO-00000005c3p-05r5; Sat, 14 Dec 2024 03:10:52 +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 09/11] block/bdev: lift block size restrictions and use common definition Date: Fri, 13 Dec 2024 19:10:47 -0800 Message-ID: <20241214031050.1337920-10-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EC329160009 X-Stat-Signature: af355pqz5f7t7f77o1ibkimz4hqt3px3 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145841-888339 X-HE-Meta: U2FsdGVkX1+t0neoIkcS/5LW6XpWe+xjdAzQ6joHAOT7d29d76sFvn13uB6l7qojXy4m3o/9aRKmSVKMrUzUb4ZGgNqav7/orTpwh3lhxlzauUgkuwU/k27XKgLrlg0RUjBvglzHTx3TmG2vh5/XwUr/M42igH8MLoob9MG75WvgfwWSROa6u6/M7To3LZHpKgA9A4CvoPtKazdkx6v5u3rFvKZsYpVFEeaRt6mRMgesRATiaCw+gIVqtASDiML5AnbQfnMedlwZ8fPqulinhLV+IOSU9QYXaLTWRJ/dx9fI9jlIR3P1GjlqDbGoiTSzzIBk5QYmkuhUr3uiEgtZXsXMFDdzWNwlOU9RFc4eZ/hJ2CH/O+ueUaNmV5hmIAjHuJSuBT1AmMRDpRS7j4kH42dSJ3+cJUugahlTGo9k9ODSgH4rlFgddZL6rS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ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We now can support blocksizes larger than PAGE_SIZE, so lift the restriction up to the max supported page cache order and just bake this into a common helper used by the block layer. We bound ourselves to 64k as a sensible limit. The hard limit, however is 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER). Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Reviewed-by: John Garry --- block/bdev.c | 5 ++--- include/linux/blkdev.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 167d82b46781..b57dc4bff81b 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -157,8 +157,7 @@ int set_blocksize(struct file *file, int size) struct inode *inode = file->f_mapping->host; struct block_device *bdev = I_BDEV(inode); - /* Size must be a power of two, and between 512 and PAGE_SIZE */ - if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size)) + if (blk_validate_block_size(size)) return -EINVAL; /* Size cannot be smaller than the size supported by the device */ @@ -185,7 +184,7 @@ int sb_set_blocksize(struct super_block *sb, int size) if (set_blocksize(sb->s_bdev_file, size)) return 0; /* If we get here, we know size is power of two - * and it's value is between 512 and PAGE_SIZE */ + * and its value is larger than 512 */ sb->s_blocksize = size; sb->s_blocksize_bits = blksize_bits(size); return sb->s_blocksize; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 08a727b40816..a7303a55ed2a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -269,10 +269,19 @@ static inline dev_t disk_devt(struct gendisk *disk) return MKDEV(disk->major, disk->first_minor); } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* + * The hard limit is (1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER). + */ +#define BLK_MAX_BLOCK_SIZE (SZ_64K) +#else +#define BLK_MAX_BLOCK_SIZE (PAGE_SIZE) +#endif + /* blk_validate_limits() validates bsize, so drivers don't usually need to */ static inline int blk_validate_block_size(unsigned long bsize) { - if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) + if (bsize < 512 || bsize > BLK_MAX_BLOCK_SIZE || !is_power_of_2(bsize)) return -EINVAL; return 0; From patchwork Sat Dec 14 03:10:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908282 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 A1E18E77180 for ; Sat, 14 Dec 2024 03:11:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 904FA6B009D; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 83CA96B009B; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 186026B0093; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 596E16B0092 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 14D9FB0484 for ; Sat, 14 Dec 2024 03:11:02 +0000 (UTC) X-FDA: 82892087082.21.E1EE563 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP id 65B041C000C for ; Sat, 14 Dec 2024 03:10:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1EBbiPVm; spf=none (imf18.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=1734145848; 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=SC13mhGE1TKS2Lk87NYZVfEBxxs49zvhyYsSfa79OZk=; b=CrzkNHWXBND718zWVuufoLFOL2Y9DQ9CUzO157uFSMFhJdkMW2K6BBesnR5W3cv5/3RuwK Ytld1PKYpS2uVtrGUhiTJYwL8U8hdOjdeg7+U9I2qhsoCDfLLxcP6i8A5PZyLp41EtCWtq cxunspH3rcyg+l1rJV6AkPH9zmbsI34= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1EBbiPVm; spf=none (imf18.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145848; a=rsa-sha256; cv=none; b=gemD6kPmNIlBoidYjjhOEQ8Ll6WTgpwf+79W3ywnX8r4LXxUyGvMgFQMTxn2FRk0CdAtme xkDzUWaQdxRtsL1pb7l2dZKX24MhiXEp7li5KvBYlntA2bnGMfFnOiiYaLPKVeAl/9EINM yN+Z+1fNp4PpU7tGiePAj4k203Kwi8k= 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=SC13mhGE1TKS2Lk87NYZVfEBxxs49zvhyYsSfa79OZk=; b=1EBbiPVmmO/i62EdqjkG8nBcyi k/algK3tiiXr1Br1Uk9Qt9p/uY5q0O43rcQZuE5e6kuBKV2SWOEt/KqsMaIQY8aN1wO/D2NHKMlEJ 2+BNxHzVQUme6o6AFjNh5P1B87JL3yLWk9CzE9EYwujJ7MO+6hQx0giICBsCV8eymOQsYUKIy/d8m NYsfTm4ZQ1Hs/vrfv18SZK9QPKW+R5YpL1pEDfUKo1BRlZUL1vdwtlvgETaVFB4OUYozDByc6viYJ Q+1N9a4ZD2iUqPcfZdrG2s1dHK9WAdLBpCkOVJcGl4BLCn+tts5iT/ZXrC6R+O9AOQrOKZ7DuAaKS rE/RqCUw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYO-00000005c3r-0E3S; Sat, 14 Dec 2024 03:10:52 +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 10/11] nvme: remove superfluous block size check Date: Fri, 13 Dec 2024 19:10:48 -0800 Message-ID: <20241214031050.1337920-11-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: 65B041C000C X-Stat-Signature: 61r5omj9aecoahc79dgjou5qymeutbpw X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam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lk0kqMk7XPDCT8f5UfLaYB4qVtKo433+XqLnZaR+2kSiROVzbSrsbIEokqx6i859LqAyOxuZAxsUl3lUW+rMMMGP0xiR4FwcQ1YLNXckqLHozT+U+psVuQoDNS8Jk7TRsVGVZ0k2VBM1UCkNWRdlgAxnzJ6CdIPyiy3jj9dU3i4JGfA6B2BQ0eEmm7HWl9yosyZn0lWMNWp5RGoooQmwzxbR6AKnzEGU8RmP2APOa2AfNmHf53HCkHz9Y96bNGgtJZHmNs5dqrKYN9dfDORHkBdTkl+SQjJwiG1kdpt6WEhVnbOOBBNL7RPEi2+5QVig818TsuuGc0CUTaKB4hd9H3HfpUvXTL0LI7VlgOHD90DcbtZAa7PvV2k1IuCO8+sCdsjwcGM8M2RrDyd6fFAeFKeiNoNw2tzYVrH6MN7c7DYsqntx8vmJpY7jYajeiI5yocq1GnIOK9Nndww== X-Bogosity: Ham, tests=bogofilter, spamicity=0.006238, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The block layer already validates proper block sizes with blk_validate_block_size() for us so we can remove this now superfluous check. Reviewed-by: Hannes Reinecke Signed-off-by: Luis Chamberlain --- drivers/nvme/host/core.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d169a30eb935..bbb5e9d2415c 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2029,16 +2029,6 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id, u32 atomic_bs, phys_bs, io_opt = 0; bool valid = true; - /* - * The block layer can't support LBA sizes larger than the page size - * or smaller than a sector size yet, so catch this early and don't - * allow block I/O. - */ - if (head->lba_shift > PAGE_SHIFT || head->lba_shift < SECTOR_SHIFT) { - bs = (1 << 9); - valid = false; - } - atomic_bs = phys_bs = bs; if (id->nabo == 0) { /* From patchwork Sat Dec 14 03:10:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908281 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 209DDE7716A for ; Sat, 14 Dec 2024 03:11:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 690666B0093; Fri, 13 Dec 2024 22:11:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F8D66B009E; Fri, 13 Dec 2024 22:11:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE1DE6B0098; Fri, 13 Dec 2024 22:11:02 -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 32CA56B008C for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E7B0214166E for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892086914.07.A34E8F5 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 09D1340003 for ; Sat, 14 Dec 2024 03:10:26 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=rqjr9k1z; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734145848; 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=QwW6+QbJTlSFLC3FzzKGoyGuJ59VODNiRzXn4st2nlY=; b=CW6hDPvul6EkiGtF2cYCTdG7YkNk3b5YDfEr60J4/cpA4k8KIUDjf+nDWc5W4v3H5Wnwfl cvLmyigF/60ybBUix2I2m4sVKzBJLVwpuixg5I5bowJZRFnXt3iIWi1PeEYUgujAMGi2t3 R9TGlYwSz6Q3wLjhILsOtSlbsF7YRoM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145848; a=rsa-sha256; cv=none; b=T66tQVp8UYHIqJyH/wGmowo7+iApp6ySb05UuTPF9Z236WMbnTR1a8kz+iOTffS2Ru26kN h4ein6Ktn2g3UuB4alhhviRlmI82iw284yHtr5Y1GIeSZlYh5EepiWbfTBg5IU/cbClM+N SVrjlZlUClsHdWjp81gge4XFKwrpN6k= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=rqjr9k1z; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org 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=QwW6+QbJTlSFLC3FzzKGoyGuJ59VODNiRzXn4st2nlY=; b=rqjr9k1z6khTpfp/RfwgO2EvnD k52jL8QOpAlYrZREH8RLqgl823+evliu61hP3EYJT2SyxbKDjFF6QIbCTLEXl6zNtz7rtY9ibW1XX 9G53kXlos5RYGUGI0eTPtAixrTTPmMTWq9gMwJOIXzq27iu+8EcpEKpwuV4Y5e5HX8Iu0HoNtW9Hh 3suyN6IBf1BSA7JSl8RBtjp2PWaw+GXqawh3KLsERTN1DmlWP7edWp622G5Pif3PYfCeqLljzTire 7wzDzx+BFmYz7jXqjtZF0ZogUuuKCv57HOKzkkML/yQwXYfR4DRqneo5wBLssOM58W7xyPgGpl+eg 8Qvtpm0A==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYO-00000005c3t-0MSX; Sat, 14 Dec 2024 03:10:52 +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 11/11] bdev: use bdev_io_min() for statx block size Date: Fri, 13 Dec 2024 19:10:49 -0800 Message-ID: <20241214031050.1337920-12-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-Stat-Signature: 45ub1ibsw8ppzf3gn7r8zxfqt1pawnu5 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspamd-Queue-Id: 09D1340003 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspam: Yes X-HE-Tag: 1734145826-883460 X-HE-Meta: U2FsdGVkX1/0urwOhep3VLxySccmlzQ/bsDwyaasfFmOBqEb4CddxKS88N27FzVEZApr3ptmJKo0y57qSFCK594za7H/RYX15OX7Y4PYD2BA38Q5c9JMse555veKGAgNbtjDMlSvygp28TV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HNNuUn5jLP7ZlqklNkSxW1WP74qARbT+UZT+jsMyI24kPC2ZULzMLQik5/O1WG639LUP9I9DCMou9LW8ZuGYmd4Omw2Du9+asxB8UAbc/zohbo/e2wQdu+qAp90QU7PjeiFErjCo+Q2GCwlE76206BmTG5K23aD0qf5qpFMcwtIsl5YC5RLe7CB04gbmxqcTDSeS+uCouU6O+qOEoXzFRvcmegJy/JUAyJRthfnDxNKrNZMdlPuw3h/fUlgXWC4kxt1Lln15QFmqlU6YldJpqYhxmRZM0ZSajZsOZs6QlhfWtrwlk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000350, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: You can use lsblk to query for a block device block device block size: lsblk -o MIN-IO /dev/nvme0n1 MIN-IO 4096 The min-io is the minimum IO the block device prefers for optimal performance. In turn we map this to the block device block size. The current block size exposed even for block devices with an LBA format of 16k is 4k. Likewise devices which support 4k LBA format but have a larger Indirection Unit of 16k have an exposed block size of 4k. This incurs read-modify-writes on direct IO against devices with a min-io larger than the page size. To fix this, use the block device min io, which is the minimal optimal IO the device prefers. With this we now get: lsblk -o MIN-IO /dev/nvme0n1 MIN-IO 16384 And so userspace gets the appropriate information it needs for optimal performance. This is verified with blkalgn against mkfs against a device with LBA format of 4k but an NPWG of 16k (min io size) mkfs.xfs -f -b size=16k /dev/nvme3n1 blkalgn -d nvme3n1 --ops Write Block size : count distribution 0 -> 1 : 0 | | 2 -> 3 : 0 | | 4 -> 7 : 0 | | 8 -> 15 : 0 | | 16 -> 31 : 0 | | 32 -> 63 : 0 | | 64 -> 127 : 0 | | 128 -> 255 : 0 | | 256 -> 511 : 0 | | 512 -> 1023 : 0 | | 1024 -> 2047 : 0 | | 2048 -> 4095 : 0 | | 4096 -> 8191 : 0 | | 8192 -> 16383 : 0 | | 16384 -> 32767 : 66 |****************************************| 32768 -> 65535 : 0 | | 65536 -> 131071 : 0 | | 131072 -> 262143 : 2 |* | Block size: 14 - 66 Block size: 17 - 2 Algn size : count distribution 0 -> 1 : 0 | | 2 -> 3 : 0 | | 4 -> 7 : 0 | | 8 -> 15 : 0 | | 16 -> 31 : 0 | | 32 -> 63 : 0 | | 64 -> 127 : 0 | | 128 -> 255 : 0 | | 256 -> 511 : 0 | | 512 -> 1023 : 0 | | 1024 -> 2047 : 0 | | 2048 -> 4095 : 0 | | 4096 -> 8191 : 0 | | 8192 -> 16383 : 0 | | 16384 -> 32767 : 66 |****************************************| 32768 -> 65535 : 0 | | 65536 -> 131071 : 0 | | 131072 -> 262143 : 2 |* | Algn size: 14 - 66 Algn size: 17 - 2 Signed-off-by: Luis Chamberlain --- block/bdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index b57dc4bff81b..b1be720bd485 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1277,9 +1277,6 @@ void bdev_statx(struct path *path, struct kstat *stat, struct inode *backing_inode; struct block_device *bdev; - if (!(request_mask & (STATX_DIOALIGN | STATX_WRITE_ATOMIC))) - return; - backing_inode = d_backing_inode(path->dentry); /* @@ -1306,6 +1303,8 @@ void bdev_statx(struct path *path, struct kstat *stat, queue_atomic_write_unit_max_bytes(bd_queue)); } + stat->blksize = bdev_io_min(bdev); + blkdev_put_no_open(bdev); }