From patchwork Wed Nov 13 09:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895567 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 60960E7716D for ; Thu, 5 Dec 2024 15:27:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9AB106B00EC; Thu, 5 Dec 2024 10:19:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 72C9F6B00DC; Thu, 5 Dec 2024 10:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61A386B00DA; Thu, 5 Dec 2024 10:19:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CF6E66B00C7 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 858E116093A for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780592160.09.9A8F29C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP id 94F77C000F for ; Wed, 13 Nov 2024 09:47:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="4DDs/JDa"; spf=none (imf10.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=1731491020; 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=ns/7m4rN3Pzx9FwaAtcwSt3EF1rHNhns2eROAPx84Uw=; b=1GHPzV8FTLvuZ7r4MsvmaNJIJbE8PzmxdkpKIzewm3APXOtL2He7qOwAz8mzBWKo+CaRcP DF494TQQfEzOQoSibcbiYJ3g3JCY3Z2BnxRWibgopmcTpV9sYKHyQZpnPSv268+cI0UdZT vkIlkqZibKFGzVoxrU0Hhkg8HlATHi4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="4DDs/JDa"; spf=none (imf10.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=1731491020; a=rsa-sha256; cv=none; b=2qz3C//fGXqDC9s2GeanW0N496SxusgilKspzum7Lvq0wl/WzNyjqTS5bg1MxjaxUgTIt9 RPf0Q5T4iR8V8V1Z5gpAOQwBwOSuP3A82WHtAjaQdYr9cCKwobRxtgnL6Z0kmbm6ClKvzr OCZTzX1VvgH2bAJwF6wmW9vboaG5yKg= 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=ns/7m4rN3Pzx9FwaAtcwSt3EF1rHNhns2eROAPx84Uw=; b=4DDs/JDaSOGto5fCjDTWI+nVjP bhTdPEcjrovcFCCUG1DjV0x1blqchw5Z2Y6joGv4tEMV0M6J5mNB3sXZWi4gcwtGbbOtroBBibJc8 GnHPf3L+e+blGHbME6PNZvXH7yQYl8Y7vMwDalxQ8Lf0SBT9W5xYaMIcaEEPPTIl5LFQVVvD0GuOe zYX5SCVyQ6CzJGMHuCXSZIkkrMiRwoohXUhIO/4tjsrDxN+8ZxV+MNtikafpHD1r0aCyge+SVAwoc S5ct3gcAq2eDLY3j58Us7EOQf4mAwyYU1MNF+Bh45qYnIR4lNZHmTV2gFrwgIA4szdPWM7/wIf05B D1RL9rpQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yC-00000006Hcz-3lX4; Wed, 13 Nov 2024 09:47:28 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 1/8] fs/mpage: use blocks_per_folio instead of blocks_per_page Date: Wed, 13 Nov 2024 01:47:20 -0800 Message-ID: <20241113094727.1497722-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 94F77C000F X-Stat-Signature: 85skokwxcor61e4amrk4thtdzfngwk1n X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1731491235-635019 X-HE-Meta: U2FsdGVkX1+VhEtupqxKH6/v93pid4hAIkSSAIwYR8jO7EPaLNRnofB3WJzxxRgeJAdXtEsJJv8G6ERgu7N1gcegO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vJgVlyIpNtKFVxjWsis6bgoqQquPPIyTwiQi9dRQyoJmw4tNMJbOKodgjzt+1hPreSBwfOAhW/ny0L15q/3afzXx/WMTDBxyvum5YRatBKebUqJ31JnltnRpj6/70MXYi7XWMvh2wGtOqpllItjWEWuq5XG96gH09atoEyeP4f/4IvthmEAVODN1pwwE/nVQAHRYuXgiYfsXdfv8cJBvY3/x3hkA/qqdYeIGtl41RZSZ5nlNs3pdML0pgtDbOPElzKP4fO3qrhVl4Y9t/JtGn18O/+W1hpi96mEoiasSFA6FhcanIiS+pOMAcFQDEpuYjHZYlxav6EPWh51JIi7krjbQcEmxuKX0cw1YI= 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 b5b5ddf9d513..5b5989c7c2a0 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 Wed Nov 13 09:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895559 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 AFAA4E7716D for ; Thu, 5 Dec 2024 15:25:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EC036B00DA; Thu, 5 Dec 2024 10:19:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 420E46B0122; Thu, 5 Dec 2024 10:19:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29CC16B00E3; Thu, 5 Dec 2024 10:19:13 -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 CD31D6B00C5 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6F548AB107 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593210.23.B3CBF6A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf29.hostedemail.com (Postfix) with ESMTP id 8D370120022 for ; Wed, 13 Nov 2024 09:46:36 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MrW0mugs; spf=none (imf29.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=1731491080; 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=7+8+iZm+tjxOB43GQOsTAsoBbae92Ry/J8rdhLVaHLE=; b=qvvH8Ar18nI2eq5dQB4l/FfD/qY8HgneiTChD9uI0QpUB4TVEbmtyK52o0u8FYiUG7LB29 EnO0XIXAQ0in/q+O1tuegkOhJ4NIHv/d++JCLBThrk083F91Kiu42uoYP8YWZTdMUnSwq9 wigwLSwa65DVvGZ2UIXFDunYTBjsD68= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=MrW0mugs; spf=none (imf29.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=1731491080; a=rsa-sha256; cv=none; b=Pm0LdxXSOJjJV27zDa0gl3GxTGOmtkk4zbxUn1HHvJhGv9mzLPp2Mfkeg0FrsyQ5N2Kdaj qtELmibhhiM68i62wO/9OU+Sqar6RL24QoF9Gh3TVH3EiIisVAR6E1VJQZtcEtNv2tBFWI 61kyhz7Veh2DMM39RnZR5+0OjUal8Jc= 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=7+8+iZm+tjxOB43GQOsTAsoBbae92Ry/J8rdhLVaHLE=; b=MrW0mugsJonnAulp8nZ/Goql0i dlieZ5TByws+pcxXO9uzei7XrUnTJIaPGtXcmT7M28XbIRQNf8WfjJyrEBMnLUb18awyz5G+zOp3o zasJqs8/WFw10/x/u9WEXX8tgHRVMwegKqXwPlbK0yGoR10GXWRzKSH8YzezgZ1p6SyBdZmc0f1+d zvkmwdLq4VgNTo8RnuoLrYc1EMhcJZRZ+vfG5n0WOPSGNTGK4zwf4CKDI426pbHRYyeJnPc3SuWqG i+VtckgYCCV1qo5rIAcAcGq0g5Y5cgCEP9SSSI7Q9MEPDLApZpyGJGXy+WfxgWOsPRkqxVneAc5ET J4oaxmZQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yC-00000006Hd2-44oO; Wed, 13 Nov 2024 09:47:28 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 2/8] fs/mpage: avoid negative shift for large blocksize Date: Wed, 13 Nov 2024 01:47:21 -0800 Message-ID: <20241113094727.1497722-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8D370120022 X-Stat-Signature: c8o7k9f7et18o5bypy1yhejntts6sa61 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspam: Yes X-HE-Tag: 1731491196-938129 X-HE-Meta: U2FsdGVkX18LmiWTinfFigXCU3UTosW2rtyvuvhENLV23e/uwvaPiwf/1AMrSosN8+mV7GzVyEQZHiiSe5VkSPtRWjm3jdSanFSH/GfAjZSuMAY/pjS3rDTmUcPLoLYXxkiob1Br0jhmpmEi+g+1BydlUkaFeYd/Q+nrEkLi+sPyzpZBPs1dtjlyXfnw0rH1S99bniBJfoODefqrvOPN2sRzfwLgOrXpBAsRtZPEiJuF5noxqqStzaZYCvW9ULdHMcnkcB+DMkoVDd81V5ESS4XgVaeoEcwHRHa6oxACK23mrdgPNxxKoF7ia9LSa6Hb4/QTullQiqJXYrGqikfRfGtGMMIwP/MozjkhWg7/2VG2XxsbUxUMzsGiOJ42yQz/t3H+a30I0Q2860+THoqvrN0FF0ZWDtHRCazb7Yhe2+AXF6fdPqk0r83Fytq0N2NhfOA6966Ib14WVt+YZ/loN4H864FX2bzbw98VLdGIUcxcYkXWjh6l/wh1GAL03WfBKZoV7IWhe2KeoSaYWY1VN8JD7bwATXSX3w26LwMheTZRPmCGhc4zkdOU+FSKZHIWelLB50WYtAubSSFTNefNe8MXJcTgT8vpRVK3ymtJCbEvw+S3avVAM2+Gv2jArlzm1+/PMfKQHCOtDQd9tumP9K/lRfgrFMfub7vfrxLnjNRzYEnNmbD9Tpo/a1h0jmpC5onhMTDG0HVPrKvYDNdL9Tx8I6KuXNwAMsw9vgy2aYHB3pUD3xT4+YG8I8N76TBP40QOZVdx2/zyVSlV/DWrlMzCGf58ZYezJZPTAmKM9EvCJB1usT/A5Y9m9tFM4AmO/AgBCxEcXkYWwkL4sq9+nM5kcLGq2HtU2kEapsInFG2Tdw39y5IWWQVY5CiOuD/wmUHTbm7RdTcXtqQXWKK2z7zqO/4U2pregPEizwiYPXYtht5UVh3zV6edC/9OFrH0gaPTSnWDXMMPhF2WBFg 4wpME/Uw HEAaySV8txs9OmGWGoTIxoJeN72latCTukGg455QKK93X1pVV16M9Q8ppd7HJgTAvcd/GJuJKbMg21c7xo86RSlqN/Id/+cx9wUw5/V2Z6v07iMkFKIrbnhQE/halU/I4xNIRPrqlvL73+rPxZO0kyFpfOZRBz8S1z5qwS9dATzzjHi6TiSgtQqA+NF6dDOe5bwHWNGo5k9tOagF4P2i/dBsImzcph+P9t28crIklzv+B6K1Y9SBrXdrVTyRiPc8S6dWFXZFg2Ge7gNvaRDKLl0svTj2rREtpguzwWPH2TmyoIvFH1gD+MiLeDEqBIeQOqeSmqATOyrx0e/aXeuhk1mmx/uXwiQb4aQf0nLxm98Iofkbvr1cYNW2A6eK18uMvSmFTW1kIkXNUc75Yuqx1Tu9tihQ5Y7kRUvFyH7zWHhoCjiYA38uZGVvRvgog0ez0PjBIr7i7K8wNuGhwoBVsWGnxjD9DQ3uIY3WimLXd9ehzIX85n9vyIKI1Hg== 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 For large blocksizes the number of block bits is larger than PAGE_SHIFT, so use shift to calculate the sector number from the page cache index. 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 5b5989c7c2a0..ff76600380ca 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 = (sector_t)(((loff_t)folio->index << PAGE_SHIFT) >> 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 = (sector_t)(((loff_t)folio->index << PAGE_SHIFT) >> blkbits); /* * Whole page beyond EOF? Skip allocating blocks to avoid leaking * space. From patchwork Wed Nov 13 09:47:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895563 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 59397E7716D for ; Thu, 5 Dec 2024 15:26:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C9926B00DD; Thu, 5 Dec 2024 10:19:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1E016B00A9; Thu, 5 Dec 2024 10:19:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 530FB6B00C2; Thu, 5 Dec 2024 10:19:13 -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 CE19D6B00C6 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 6DA7A140984 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593252.22.3E4E22A Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf23.hostedemail.com (Postfix) with ESMTP id 30FED140007 for ; Wed, 13 Nov 2024 09:47:06 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Gu2MfyO+; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf23.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=1731491167; 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=EeFsYhvb/Fdit2R4hCFUp0b7VKyDdbX2dUmYXd00mGc=; b=VvSrDIx/7igiYfbTVcZ38RVJoSVEGRSPLqL1p/5dYOTTevloYYY7mkdcwhN54M+X/LVXFx SJII9BVM5agrCCCpMdw7B+vX55PAKLu5Gon9u8H0HsDwMm/oTd2YKuoNA/IwvrO9IG4hkr EGstKtr/AZbJV8S5Z8y/4PK8ZXzafWA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Gu2MfyO+; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf23.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=1731491167; a=rsa-sha256; cv=none; b=0VgwoKqULUjxSrkkmMsESO+q5RvjCV8+4odT/i/eKP5zlXNTb1faQY3QYb6TXidvC5y7uk fSywmGsiMDuXuPIvqcgcRjYB/7urX9NsVVdsp+3xdzyU3Vi3A1QlHt2397cj3zsg9bD7vH Ae2AXsAGihbcV5Hy0e143mk7qXX5AAQ= 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=EeFsYhvb/Fdit2R4hCFUp0b7VKyDdbX2dUmYXd00mGc=; b=Gu2MfyO+KOMeF2SXnrD9P/+Yok ZDkackaAAZcM922Q2kci3CL8PuXVDU3ipL5W/i0JARN0Ecf4AMl+R9WYIZ4MjG6rBTVsRiX2s23jf Y1SGKls98aedAJVN5zJ9MrapGIkNeCebbvf00Jc772ox6gByfWwqFTITY4Ol/QR08T4fH18Dpz4X9 xMSuviowVOdca3AC9xrghQxbXYXHK+HOc/fBo+zng9q/nKrY9zyh0E/Vs1XrHK+p4z0yxx9Z7ClTP P6umpagaAJMQvQ7chWp66JmdoBso0jnn0hL2GBNLLFILfTKQ0UK0jD+5ZjDQZOzqPD00xXj/1t9TZ h6oYqmxg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006Hd6-0Cj0; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 3/8] fs/buffer: restart block_read_full_folio() to avoid array overflow Date: Wed, 13 Nov 2024 01:47:22 -0800 Message-ID: <20241113094727.1497722-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 30FED140007 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: td8zdx3obk75aonf316zdokgsdmaa7wx X-Rspam: Yes X-HE-Tag: 1731491226-510022 X-HE-Meta: U2FsdGVkX1+if4f5iP5n79ULFSlIW4M3GscwPybENI7gaEJyXBpfGiXyRasCMa4FuuCRGC5/a7c63AmwmVPN5CYYaSBLRTpxmPQIjZPoRmY/0AhTfCUvbH091JX+V6Kv/vIJQdRxXGK5JwkGFCjY49v2wQUiqzxH+hpggHhe8F+DaZMoHgXVR696ysLl9EAfNNHqCKW+dCZ9YYtQOwd15irsS7tQ87AiVIGuWAT3MO/6MN24823/gdR2QT3GNBMOlx0oL2OSEcmsePC7SgQ80vpDkvdU2+4Qfi92Spspzp2qz4jgywG2gXQFocXpY2pSv7hPFjoACByeKJcJRe6ejtQV4hApLvt585AacyUT3p7a/nUXQsMBwpREilcz0/qgGT7yUMPkS4mLS0UH4Hn0ypWRhtHcMCiJQZr8Y7P0Az/9f7kSaIOFZTsVTX9IiwPB5gU0fF+i4twe6M/xMAk0RyvyPkl5SoFQsXFP42FvrG/oPCRH6Q8i4kUVp5W4FJECCDXA+BgnPwiLflWwShmwq+7r6HrUA7Mqm7dIXXnY6+2ymGKJwkVYsos35TVJgMYbzFesT39f0yjvWEg0GJ7DxJXeZMjwwylO5Ex3wh8nFwPdpjZqABAYI7cZGC1lHxgnsx/dE+j1upI1QronCWxcv76zJD0AZXdAl5sLVhuQ4N19hxHcp5BCaAxwwWmVRkGTzPSzAR1U0zIi4qcBFsLiJvKeWYXWpF5MLO+dD2S6aXOHwJppBsChPK005gH4nMCkF4WtmefCTeHP3bEictkLgB4Yps4Y8SyR9QhYEQg2gYkVnPqJSnEW4DW1o+GTA0GJFyy9PW6w+jY5ieBtU6ieWHMIA+WMH84It36c/X2LL1UwaRp+PFLvJ6LchwUbsw4uOnjFdrfpcHGFh70tpC7l4f6JrecVXbyuAWA8rCR86VI+yHeOq4Ya+kxA8JJnKU2zDEmKyGNcwInXF7TUIWD rdrjoGD/ pDY3A7JVXAgkviRFyFWxlWAaL3QR9DPh9GoBsbXlrA5snQ6MwfoZhBM4V28HOQFlvKT5l5lxiMJoCZuDUX9b3w0om1M+baCVXc0DNe4WtMYOttoXghs9cwSllxJib7+Ah8Oek8+etkkKKaYQ57vFiTgo1SV2vP4Ei1ayyLJ0oJPi+M/Rnk9BByuSxPmxorZ+aZb2eadzMW32RXrrwN9J8DSS3XBZXSFhdbQKOb71VcN3RCpoT5lS9KToeql8k/Sj5BLdCoi5ztvN5l5BUfyEfuSyp0aCLtGRRi4LC6q7c6J6slkfsfQFPo/ZvMdkR3/vz/z02WuLKha9ucsdigw9nG0nPfhIKQOG++TjB8YReuJxsfwWOp6+62PxMcrEpNLU32W+hgkZ6yU7C0p2337swNYIp8y9JyqJT3Oc22EFz7499YT/raxNhm7MbUhFr3t41Tl/OEQx6j/q2h9SeGtEevNNH7WBs+vzHi26Jw/N+TtTUniv6VMb+izaBTBOPDQ8g3iHkDkW4hW1XW/0= X-Bogosity: 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: From: Hannes Reinecke block_read_full_folio() uses an on-stack array to hold any buffer_heads which should be updated. The array is sized for the number of buffer_heads per PAGE_SIZE, which of course will overflow for large folios. So instead of increasing the size of the array (and thereby incurring a possible stack overflow for really large folios) stop the iteration when the array is filled up, submit these buffer_heads, and restart the iteration with the remaining buffer_heads. Signed-off-by: Hannes Reinecke --- fs/buffer.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index 1fc9a50def0b..818c9c5840fe 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2366,7 +2366,7 @@ 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]; + struct buffer_head *bh, *head, *restart_bh = NULL, *arr[MAX_BUF_PER_PAGE]; size_t blocksize; int nr, i; int fully_mapped = 1; @@ -2385,6 +2385,7 @@ 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; +restart: nr = 0; i = 0; @@ -2417,7 +2418,12 @@ 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); + } while (i++, iblock++, (bh = bh->b_this_page) != head && nr < MAX_BUF_PER_PAGE); + + if (nr == MAX_BUF_PER_PAGE && bh != head) + restart_bh = bh; + else + restart_bh = NULL; if (fully_mapped) folio_set_mappedtodisk(folio); @@ -2450,6 +2456,15 @@ int block_read_full_folio(struct folio *folio, get_block_t *get_block) else submit_bh(REQ_OP_READ, bh); } + + /* + * Found more buffers than 'arr' could hold, + * restart to submit the remaining ones. + */ + if (restart_bh) { + bh = restart_bh; + goto restart; + } return 0; } EXPORT_SYMBOL(block_read_full_folio); From patchwork Wed Nov 13 09:47:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895554 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 EF555E7716D for ; Thu, 5 Dec 2024 15:23:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05DF46B0130; Thu, 5 Dec 2024 10:19:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A8726B0134; Thu, 5 Dec 2024 10:19:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2731D6B00F1; Thu, 5 Dec 2024 10:19:13 -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 DC5076B00C9 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 86B1940948 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593168.10.0ECE5F1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 73F2E18000E for ; Wed, 13 Nov 2024 09:47:04 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=YSX0EDzr; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf06.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=1731491167; 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=v1hn7jTllJt027wi2EuYKy1M6kMpA7RumaYFxoUC1HI=; b=a0jCqGehBpDbvNl9I8RoiqiF2zRB3q8dd6E0szzl5thmM8rvNWb9CwsRJxMnw4KrqnShor RndPuN5i/ZOnG42bTrTJLujd6bBFw+XzO7NljRZOSVJVcfSfTAtYqsEKWNQhm488koTwKB O6D7gWMUKtfJ+6/G87WVHjG1ZY7T/LM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=YSX0EDzr; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf06.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=1731491167; a=rsa-sha256; cv=none; b=srEB87xYNuiasONImGmeyfaA/YmZTDn14hQtQFmrwJ0k0MkQvLC8syC6+KeBjF79fXKF5/ oR2Rr70XTm3SLFSM5xBWDJTAIAEMVQPSuxWyAh6wNDqwPSIK1FYW0+x6viucrxU9NIQznH zL+JVMZzURDIApNQgs12nGZjKqbfwNc= 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=v1hn7jTllJt027wi2EuYKy1M6kMpA7RumaYFxoUC1HI=; b=YSX0EDzrzBi3K2/pJrtGXF24rp j5lTJasVr/P+LgtwWwKhkLU3mFJWGb5hV/WXVdYOUwsLgkXNwyLSdVgvVO4wqyBeloxb+0bvEsNCb Eu77MWXLhodY7x6GMPFW/SWXeg7lLivHqER9vaEW3oxTzjyTCp6H+QjoFBttZ2DQQkRARJAc3YN4s 5HCgwoq3AzrQSx3auSaBCAY87O/ctCESb9Cyc3bpqH5LFKPlJ9qVhk4ct8rPZ2+w+YYoknajjiQLW 5zroffNYSZLnWg5waH9jvnppvowXI7VxdoQPuEHaRLHJKDdKNtJUXvgQ3OjTm3owb639om+aPIJCv Zg+yBSZw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006Hd9-0Sue; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 4/8] fs/buffer fs/mpage: remove large folio restriction Date: Wed, 13 Nov 2024 01:47:23 -0800 Message-ID: <20241113094727.1497722-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 73F2E18000E X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: wj9qwe4o39ux4jaxu7izj7u94dezjcjw X-Rspam: Yes X-HE-Tag: 1731491224-595463 X-HE-Meta: U2FsdGVkX19GGkQ2p+LJMZEivfcE9neA4jMxl1V/xbu35pomWHwz3bFbE9YTUY2RJcsYbj9XaUddawdwVXB2hMNmzZHdATVCsO3ykDJxPITHIk/W2CdmB7v+4cocWJ+6HU0v9zDGLP2QQTnliZS7zite+7MzQM66mOuizzwHykh+eAEpgv2qKUxOJRKbwJtePHli6hV7s1WdAVGARewlYeAsZPhp1MnilerTGGYhjS2LDTeMpUBdtogeEm5Xjx1Nq0pjuSjRVFtRIP+4fQmjqiCoU9khlQBCm92rgxwHo9ULNHlmCVmNhIguA/2+6ZBkimETnKP4nRAchSPXuWLIb98FCMvq+/WSzqvE8gsbRtTT0FaTnmc4IUDbWnqEtoZVc3oK7TdoXR1k5H1gZiIQJodJ2VyLr0jIBaNc+Ppg1jGpuBKitJqW5E3gJxuI/dI6TbfqF5nsn5tVffcVRUcEa3or3xcX4MKu/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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. 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 818c9c5840fe..85471d2c0df9 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2377,8 +2377,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 ff76600380ca..a71a4a0b34f4 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 Wed Nov 13 09:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895555 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 3974DE7716C for ; Thu, 5 Dec 2024 15:23:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22CBF6B0134; Thu, 5 Dec 2024 10:19:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C0786B0126; Thu, 5 Dec 2024 10:19:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E33BB6B00C6; Thu, 5 Dec 2024 10:19:13 -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 E44D36B00CA for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 83C7B8095C for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593294.12.35A184F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id F0E44160018 for ; Wed, 13 Nov 2024 09:47:05 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LfjqClc8; 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=1731491199; 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=r4o/ER58UnXxBPanGIAFJAudGHMZcltAouBykZy81OnHfG9TUdi7F4gW5fmj6YMF3hKVgK CM5wqc4GhTCl1s3fGpw1zm5sr1I66Rou6kArb2HJMxF7KuhmiKDoS4TBknZn98evlbFZ9s CX8xLjmAVZR5MXPD8ydKdiOwQo5PpVc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731491199; a=rsa-sha256; cv=none; b=lrTsZEGS1GA3RUmXKSw2AIhyu5tSAJAyMlRyUgUA5pr7OdbvdcA2ufv7aG4evv00YE3O5m DA+t8qxYLRPPyYoEMzk+KazWW0FQJJ88AfHkXXU2nIPWlMj5jlv+nsEqllBwv4m4D68NFv D04VvaQhmwdJHlMRWDtfevcFIQK1HSw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=LfjqClc8; 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=rV5AoYJPlny/7wnGoBOtLs3pAmaEJ9e3y3MRINCsK0A=; b=LfjqClc8gfoI1goRIcRzOCl8nx xMnODzqL5tTVLpi+FvD7+C5W+4VSWGyWxc3O+VSWQZQAFTpyXCMMObOBJng3DiVAWzZqWif6ybCFj 1O1EBmG6ZyQqRd7CWreGNvgE2bM6bDPeON3eWYpp/4tFR3VOGoX0DFrJqQzJ7C6ny88TS5jTT7n1X yTUGmwZ3qBkBY2FU9WcxTHWk0AbZ9o2XGr7dAUgRXdjhPETrSapitHz1jEMeQiNIgVshgBIZn2Sgx Qr15Lt8fMF2tYztfz6bjVjeNmc1SCe1W0+wSBLZl6BK/QX4jkKp9xyyHWp6S4SE3bG7wcsx39c4Cy /3lmBZRg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006HdB-1F85; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 5/8] block/bdev: enable large folio support for large logical block sizes Date: Wed, 13 Nov 2024 01:47:24 -0800 Message-ID: <20241113094727.1497722-6-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: r8ypun3xozk5zsyktp5m4swyjizc8uzi X-Rspam-User: X-Rspamd-Queue-Id: F0E44160018 X-Rspamd-Server: rspam02 X-Rspam: Yes X-HE-Tag: 1731491225-827898 X-HE-Meta: U2FsdGVkX18YEBKAo4WbHJnj8KD/fGyAuTxW2PNx0VcZsYvEWxdkO1NHiEOWHZnSFCz3MuDfY5oe4rLhkLOai5xhrN3Nfn2YTz6hU0Li6buV9XMXZzOm0zqb5GgCHj1L1LMw4rHXV6qfEzoDVdgwvovpVtixw4ksOKWF5ttiP2n447IISXA4rj7iRKjV7u0iO8yhaZtgcEnyqyDDuhkS5bsVQMy9BZhytqReQFgWUY2iYQUXgV1wnKQhu88ZpOdVY1fH1uPxgRBVvf5UU7yi8b5GUc6gMCHyQXaNe1rIngrX1neMU6RsKzRYQY67vasU8yDFKOSU4U2RqL/D2zZoBDRiWY9wIh8ObYf5PGFUj9JP2L71M/WgpSHavHorrYDkL0xFv4BXrkyC40IdQFQuAoePlTlDRsouoC2y8zqwTcQcsmjHYa0SERY+6+PEfMfT4UwgyXYaFT2ho9LpJoqAjU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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 Wed Nov 13 09:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895572 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 C815FE7716C for ; Thu, 5 Dec 2024 15:28:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EDC06B00B7; Thu, 5 Dec 2024 10:19:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D350C6B0124; Thu, 5 Dec 2024 10:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 704866B00BB; Thu, 5 Dec 2024 10:19:12 -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 C6ACA6B00C3 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7F4DE140986 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780592874.06.86A4464 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 4424A40018 for ; Wed, 13 Nov 2024 09:46:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=nnsxL9il; 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=1731491167; 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=SXlfkrrZjaYgmSwcVorAtVLJKuW9IZECB9TbzjdaaSk=; b=DEw3edBo0MrkD5xPhEZcX3b0PWT+I+NcA8xyvuWrLURsZACi2IIqILUsE0Cb1Gi5fRmwfx B0BWq2H42+ypS7qyy1OA8I4e4pB5NHmxknB5SPWvWYrPtvutNAYP+ZMkjAdGsNIFueZZap beMeMLqg9XYQKEHqv2BqNZVZx6rV9Ss= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=nnsxL9il; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731491167; a=rsa-sha256; cv=none; b=GXrh0UIcJtRZHXnZnN0Cz2eMor3cJAreiISJGnWBADphbr3ASKABgoLVj0DE8ZvH3rM9D6 njraFIAR/8AnQgA72ZxKyfJMZshLsLWwul1Weex439G+P3NFube9njKjaWadywjxd4qHmX 0D/1qJ1eUayxjWPlepsfJGtdHJ6bTAs= 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=SXlfkrrZjaYgmSwcVorAtVLJKuW9IZECB9TbzjdaaSk=; b=nnsxL9ilFCNXXb8XhHktNx4MtI eueIODYT+h0QJCHVLB/jX6H7i8oYtPkebZmAJMrKGkCXeLfajcxwviwkIyd9FN/O6mcx+ei3jsMGL lLYSwGU07XuWI+g3iLP7d3UgjI/GLqQO5FhGaTKXyBny+WsdZmcUANr/lu9+td6m7vbxgo+er/c71 m1qm8UVQjWYDifOi1BPw8cxpnWRkEGhaQ/6hn7WDAMT7LXbczwkuLlVFnKOGtIEPK/HkTXT1SJtR4 Ln6zqu8vEI41CkdlDsnYzuTIs5RCI+Dvxy9LXbDxbN7izHu9D2k5p6f4GjegeLd5QXtVzuf05p6JJ 4GE6mnkw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006HdK-1w0j; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 6/8] block/bdev: lift block size restrictions and use common definition Date: Wed, 13 Nov 2024 01:47:25 -0800 Message-ID: <20241113094727.1497722-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4424A40018 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: pjofen7g94wqi33xzzkh1o531qtyb6py X-Rspam: Yes X-HE-Tag: 1731491194-144060 X-HE-Meta: U2FsdGVkX1+gc6FPslRY0zKfGm8EGePzEnsGp/br1hN+fpt2Gs1cH7rWz5HWRcKIfnjHL1WslneyT/Up9WP9VawLbSGXzDk38C9J2epD4Q6DBmzoijfUldElNtZc/wpXxT0qtVuYMvWMI9l9kcf1ZetvR8Cv2D2+EewLiupDzR1fV/hBMc+sBVS2q36Onz6WZ8OVjtkaW19cF1Mz9jKBJVnWeiMrbV8oUk9iAmRZzIkZ2vjFJJVC0mGbo1/CaGdmV7N0zzzEdckhDoBCVBPkyXQOSsyDpcDAqWH5IWe2iRD2KFs0yv/JxgOD2VR12O7uYVCf440qkyP77uLf+8qUU4LWaEEHoki+3qy6CUSeklFtC2JOz54Wi+dmMh9Bp6blRuqJo/w/XkDFFI4Kta4rJ0o9G6CdcI+TZZjFORj76m/f67pP8xT4bp4riYD+VP54NhulzGqq6Hn5wa+2j/vqYxo2nXcsBsYVTnCb0Z1rI3bD75m2NEW53K4DPb4OmpDxh4RoRN7XQn5R/MOQawbsXOo7r3+QViRHM9g8ZHs/0E/EmG4Sex5a9vgYo0iwV4q2tGOe/mdxL2XnfkCcxZJgo7WvRDtn6VrlHskaZRbDsDv7tuzC0E19qgqGszVPQhdHQ8Jg0ai3u3+wPKOif58vpX/OfmB1jl/cezKvy1Zp94YrOzoWcqjCuiocqtM0fw0lZuw2N/pclMioQh099BiBd3YycbS96N21ntW9xl6OqNNq4CUaIbcLHkb1aJHHfduHfniWOQz5eANV7Bx3qcorpNmDcHspnSx85Nlo9b96W/I1ea+5jNCtqQ1nFSFJ994R6ZItW6G5KL21CqNqS5cCuHnhc4UCn8JCc1hPM1wJfbvVU3h9PyqzcY43BriJgpJgZabGBZk5RX9qlcTkAqHx9qbWsJKLshyrpUOp8fRbvGPhvZAE4oS1uBKFB3iB8KTYqKpQhc5paI9yV/6zsFi LiaptTTi c4jsG1LE68K9gpGHBgCFKp5DYEkSYvZtjI2PoAV/YxThfsDX+ysKoggrLcAhethRdpuTILwjkJPZk1MYdUsMJYGqzOM8ICPEZnGNyj23o8pF2ki1CZNgz7gtSB/RaSWhPDvJ2J7V9kmv6mMzeLfWsMC6tESGqx8KaVpoStJ+tY1OofIdeOHjsUuQ8y7YVIoh7iv6V+ouOjM933HKnGWQK75fZElffgIgAsMH0sQy+7exEq1oUgDorsHtpKJeJH04fGrEH2LY9WCA3B7hIWcP2Hvrco+7ZXThC1X+S9kOSuTPw5SN1FGHCC2VWTbLsazmTLGotAeZO3+/ezcCs0o0FO24noUXSiC2BHYWZesGRYm2Q091Eg0V8bzBhpUZfHpTEdg4snhGi/K4MeLtENp2w8yFv1xBRWz7kLMwJoimvJ8J3mYvGp2PMepijRW9Tj6onfNB4LoRyo8NNYGbFfaScHi2j5jE5t2BClLDq6Lp7v2g6q/q3I1dQCmEUaw== 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: 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, because beyond that we need more testing. Signed-off-by: Luis Chamberlain --- block/bdev.c | 5 ++--- include/linux/blkdev.h | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 167d82b46781..3a5fd65f6c8e 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 it's 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 50c3b959da28..cc9fca1fceaa 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -25,6 +25,7 @@ #include #include #include +#include struct module; struct request_queue; @@ -268,10 +269,13 @@ static inline dev_t disk_devt(struct gendisk *disk) return MKDEV(disk->major, disk->first_minor); } +/* We should strive for 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER) */ +#define BLK_MAX_BLOCK_SIZE (SZ_64K) + /* 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 Wed Nov 13 09:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895566 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 5FBDFE7716D for ; Thu, 5 Dec 2024 15:27:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B1F26B0109; Thu, 5 Dec 2024 10:19:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3821B6B00DE; Thu, 5 Dec 2024 10:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8649E6B010A; Thu, 5 Dec 2024 10:19:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 07FE26B00CB for ; Wed, 13 Nov 2024 04:47:37 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BE5944094C for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780593252.22.32D51E4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf24.hostedemail.com (Postfix) with ESMTP id 7760C18000D for ; Wed, 13 Nov 2024 09:47:29 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="z+/DD2ks"; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731491192; a=rsa-sha256; cv=none; b=Gbz348o/B+mKIIz4EtUj//RwubA8aKC8OCnLtp3Nel+TGosJx2miZa6FqgCrR9a7fyIO3r xq7K6p93QzVXj+DfghRz8sKSj5YfTMO0LcVWbel4vcK7NySqPJ7rbtcvjGGr9a1yGUzbRW xRfilACr1sIJgBUUUss+4/nELNpICIk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="z+/DD2ks"; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731491192; 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=mZYiYHdxBbyR/19PnV0dX82l4+th0pXaG9WcUHT6G/o=; b=jqBibk8MGdawaREoytsWtMgQlfFiHWKGfVVSt9YZCbwDRfpLGvA8CZLRQfQvxJzE1xO+m7 wBnG9ADUpWq0wKldfEAEpPphAMr8FJjE5oIbBEKOiHEhJu7KUQ6UO0fxxFlw/cqN3sSRac USNVG3LOGTYH0iGLqRjZx+mnrNAvjk0= 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=mZYiYHdxBbyR/19PnV0dX82l4+th0pXaG9WcUHT6G/o=; b=z+/DD2ksIIMD99dpwbTEHn8k4O pHg7uHS7eT094skjM9TFMiJ1EniWkjT9HGAw2UunxTT+sN5NEc0TVmCFons1UrnsgzgUrFtgdMgAA zpf3glrmYXKcRmnb6yD71kaZaua4QRrNfvPkOWhj9eWg8lFK/pcT+kIGHV5CWnC6rY4K05AxlyQGQ MNVmgP7cOXDVgnvxewh+FESw9UIPM4X8JwlqSq1KDpZfJCJvo87OGEDT+Mg+bP2H8xuptX9LBOIk/ /hFwEUAGV3O/VZjpRAj6p50xbFOpUl2RhdqH8S/bLLJ6RBn47IsUnnziFAeqODl4eodR/DLjxEOJc juHAjElA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006HdQ-3YUj; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 7/8] nvme: remove superfluous block size check Date: Wed, 13 Nov 2024 01:47:26 -0800 Message-ID: <20241113094727.1497722-8-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam-User: X-Rspamd-Queue-Id: 7760C18000D X-Rspamd-Server: rspam01 X-Stat-Signature: foufcgx5c6yun5rdxdw3abjio7runxey X-Rspam: Yes X-HE-Tag: 1731491249-846617 X-HE-Meta: U2FsdGVkX18+5gx/1xp1sGIT6UMnaUBRxYb540+CGWBjIUayKANmxCiUrBpHCWXIABdtOl1YDtXiWxBmyEa3wlX2p2NJcEdwXIjbfBg8yxmCy0VncyzXYRRrQrInY3qTnCh5Kc6Mh5S1gIHPTnGH7WDzD74ADC+r78jIkgIG/EOXNwPuQx9EWFbAG5j2AEf6ZoTcVGHc604sG/LUQxbtY50KIqlJJMdOI2S6mCy63sZJqetk2NtVrO7DFDMuZNEkri86vYT5RhPqmRF+Bobw0fG/ZwUAdqvOeHMSLv2w1TCE2JvO9rJjfyYe4GmOm+FyWbdEZO9EaL5el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FFC3EfXaUbvo41wTmyXE9nEDcxgrt01tVPMUrEMO7nJCjC2AeSHxMRjoO4dm7cc0XdvTCpSRD9zDLlSTjuloYi0pw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.003111, 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. 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 855b42c92284..86ff872cf6bd 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2022,16 +2022,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 Wed Nov 13 09:47:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895556 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 E4B5AE7716D for ; Thu, 5 Dec 2024 15:23:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 42B196B0126; Thu, 5 Dec 2024 10:19:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 752E46B00FD; Thu, 5 Dec 2024 10:19:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB59A6B00F9; Thu, 5 Dec 2024 10:19:13 -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 2BD2B6B00C3 for ; Wed, 13 Nov 2024 04:47:37 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DA5EF1C57EC for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780591530.17.066F0B4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id 5FBCC10000F for ; Wed, 13 Nov 2024 09:46:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1H770m6u; spf=none (imf05.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=1731491020; 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=Rvjs84UgO5xSGvxl4iuvzBP8tFGehN7pbV06CfLjg3U=; b=k+dVDOM9VYDcHT/bb/TSpJd/HW7dz7bfzOWfdC4aUKhZ5nztXP7IZssSWixg5jYuY8tN/q sXYqUJsIm9CtYc8YbeCcfkm0DAWk87z0t2YQoDKRM2WDyDx2g5Drx1jU7o3ufmtfUnVUyN kK3WOIYqhcC+NgSU4wVsxnjOxXlnIKA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1H770m6u; spf=none (imf05.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=1731491020; a=rsa-sha256; cv=none; b=J0BjlIP0PDFwTGYlgrs9UB/j8wDCxqovH0l2foaM5WtAyTCNi+aCZhRGH7ZgsZediTexeq eMCx/r6f3mVF7Jsb0FkJSwSW3S2d2SigWmjJFpB5/pythsphNV1Zs/lnHiuVzzPqhNLrvq mXzJ63Dt0+RCqFnkdfArjgLV1SjWdC8= 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=Rvjs84UgO5xSGvxl4iuvzBP8tFGehN7pbV06CfLjg3U=; b=1H770m6uZYJRsNLnGwzs/TYE7f gf32SzSFjC1OTx+9oTWzt/eb3OBbFZPEnS9eIjfXxWb2HTKI5997hOMEui1NLkZv1f7ZdY6YplmdP Mn9yTxEs2W9zqrnuQ8d4vAi1CPHtUnxkWedaQYIDf6+IKguB19CZMmWo1EcTap6ncmUpff2BHGbls OLQBDRaZJ95iTWnESxDGpKVS5HBnmtTigRawlaWu+fwrooEVxq4Xo3C74IjethFWPkCoB6Shaj5wN f6u7NAfglv4r8Ldg9UVQvGW7LJMsZ4vtDoE7mP2PiT4MycJMnp0V90SMINbjT9496Ta+2gaUqvIUc c5nUp2MQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yF-00000006He1-03jf; Wed, 13 Nov 2024 09:47:31 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, 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 8/8] bdev: use bdev_io_min() for statx block size Date: Wed, 13 Nov 2024 01:47:27 -0800 Message-ID: <20241113094727.1497722-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5FBCC10000F X-Stat-Signature: ja9osjec3d3gt7wm1c5zm1gpyfzuskak X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1731491174-380856 X-HE-Meta: U2FsdGVkX1971fmRUdiadng+x9AG4W6/t4xE34Pjyir7VoTyh7gtkZxlqbkHpE4fDSQKHUPPo3m6thlIGMKpK+Hj6e3uLrDPzm5tqAWOM672X3oykxwT7O/DX/DMIfs1fXLnsAiWvxJyAXuFeAgWr3HEawH17R5xnWM2SQBleXpKjyyOZpCFQK3YGLQAM3WB9J/xXNMEhL7sGufzUhzNoFYSHOuRjJfoEwA3yWxsu1xhGpEElljpxRaZB2dCpb4WIZziMuXljPMuMWY8LK69qL/Cq5Nk0jHow5mHX2b7E1oCTcV2rolIvvTOlg00q84LXDrNTw/CUF+FR1f25fz1AhGIwvIlfsJ8YDrvQgjkksDm3fe8s2Tda6mVvoUEPp22ZlTKvF9VbBJRMxkcBGi7+5NYjpxgZx4qtjWaXmYQecb4KB4j/qgNXjP7JfPdLh8DLI/Y2nkVd2b6hvkN3hQLoDe/7smPTYBO/86uXt04uq+LLLor25KFtPkzKpTMtLDVZMHy7LDkUFqPtU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ack.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 | 1 + fs/stat.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block/bdev.c b/block/bdev.c index 3a5fd65f6c8e..4dcc501ed953 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -1306,6 +1306,7 @@ void bdev_statx(struct path *path, struct kstat *stat, queue_atomic_write_unit_max_bytes(bd_queue)); } + stat->blksize = (unsigned int) bdev_io_min(bdev); blkdev_put_no_open(bdev); } diff --git a/fs/stat.c b/fs/stat.c index 41e598376d7e..9b579c0b5153 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -268,7 +268,7 @@ static int vfs_statx_path(struct path *path, int flags, struct kstat *stat, * obtained from the bdev backing inode. */ if (S_ISBLK(stat->mode)) - bdev_statx(path, stat, request_mask); + bdev_statx(path, stat, request_mask | STATX_DIOALIGN); return error; }