From patchwork Mon Oct 14 10:58:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834675 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 A62CED1A43B for ; Mon, 14 Oct 2024 10:59:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 381DB6B008C; Mon, 14 Oct 2024 06:59:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 333C36B0092; Mon, 14 Oct 2024 06:59:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D27B6B0093; Mon, 14 Oct 2024 06:59:52 -0400 (EDT) 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 01EAC6B008C for ; Mon, 14 Oct 2024 06:59:51 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4133F1C611C for ; Mon, 14 Oct 2024 10:59:43 +0000 (UTC) X-FDA: 82671912330.07.02965D4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 50955C0019 for ; Mon, 14 Oct 2024 10:59:47 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903449; h=from:from: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; bh=hXo3oIPvtAqxU/+rzneWWG3oIuEw/H2AD2/H28YBHxs=; b=OUkC3mubqjMAInnftgsSuXrzGNuiE84C7meaS2nr4L5JY24sIbqQC6DanW3Gb7p8y5EZOk zKTZLRHIIr998bdxVUuNzemC4Yj2NkU0A4ZH486STP1lvl+h2JZYPlb/q4XtDk38gs/UYY ywHpcNq65d4lED8s4HwDf9mEMTQCWys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903449; a=rsa-sha256; cv=none; b=yroq/1/nO1YUEQDkvFkxmd9mAGKaj2+bvAHTlhwEwN2ERV0d3JLUeH4avGJExmpthYfnfV wTmttBxObfIj3fd5knoT2r7Y6bAUGiqGdYnxJtkdzU3WD/ohmCLQ/yvp6TyjOhikGEar/f nuDk1rGWn3Py7WUwQs8/lliw5ivvpHA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf10.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 130DB1684; Mon, 14 Oct 2024 04:00:19 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2FB0B3F51B; Mon, 14 Oct 2024 03:59:46 -0700 (PDT) From: Ryan Roberts To: "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , Christian Brauner , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , OGAWA Hirofumi , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 07/57] fs: Introduce MAX_BUF_PER_PAGE_SIZE_MAX for array sizing Date: Mon, 14 Oct 2024 11:58:14 +0100 Message-ID: <20241014105912.3207374-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 50955C0019 X-Stat-Signature: xpzgjsybu41xc76tpjjnoryj9ngf1dni X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1728903587-779265 X-HE-Meta: U2FsdGVkX1+Rw+GFacgjdkFf4xXeOtf3yzck3geUXn76k3y0dPjlF9aTjw5ybeCjL9JfDQIE5T8424jdUyIhV/u4/atgyt+4qpdraQ9/iYNq9Tc4aIFm6tg3K/owE4sg2tWDVcYIMdbtTY3XYnpTbV5hKH2q2OL8317+AXf1tFy5NF16eV9zUWenx8u9iWX4uQTTWy8S5NgqsKtiLO8uvq6+S2E8TJk/K7x80e2b0ki0aDBHjg3HMy/EW4YAPHs97OGDBO+GPLaeWxqaMs5+3VB0D60liY99Z5/aKyM5XgMl99/99VxgQgK/CmVJi/2ja67TsFhsIq4fLJzPs1sKpIJUtYYj4kGn8UY8dlDk5R3KDDEfP4SChQTB+C4Rga+HXLhiaa2j13vWEc4J4+f+u0OMXd2b+ed3zzMD+97dYd5P+8QKemZpOeTn3sEO1V/ATIorag5aGABjL9Mf0LOsiA1C9oEYS9DyglZmttA/D+EVgcM1s4eQfa/BP06qU8YxZwrPrd+Tf5EfO7Y069RAwn+0lYkKOG5SAZJoZBlk3B9DanP/cDMxG4gC0hoPetxGI5eWjh39O1PaZvhQiAyavzZhNmzgpB+ZXt41iC9CoPdXsScXOodwcTAoQMZvvya246H6SSwuBnZw7ti+3Mo4Q29Y86VagXFoFM3BbsoBmuYiNrmcmXyiLSIeHzRkWXQvynYFcwWOUPo4DsAc2ETBmKdu2DHqTVLQnCgNSLriEslV7omv785kOvy6k76j5q4OIewfu7bZQC0jbRjgZ1HMcYdAWbh311rE07FLKMXmOZglXrG2XrjNsiW/2PUvmpG6WUq1EHccdxCX7ZSsZ8vU4sS2gUfy6/v6uvKWVU/QJcCjTumHOtnzeKV+La5L2XVp1t3bLCWujhUMxyvEFvS8aYBZWUhyN8jHgCaxjjMTYd4OApXMz6iqMTuMIPqpx7v2VSlRBaJfmmv7GLhST7r MFcr13RK 2ansm4/y9gZki0vu3G2KBnEV3pCK43PrrxGvaIg5l7JbPtm7ZC6ISTRmQvxjW8oE9Uk6/NzrLl/69SvLyzgHQAxeAVQKzQAiAz55wwLr/hGTAuOCV3wLx1KYhl+wWJSocx+jIA8mouWXSPgaW9YgpTrkTfyVYJdUBUh7Xz1grw9K39p/HNMc7JIjaw6gJNGcQsx/gNdjndMfbOaUvMXzgiCu58uwxhmW5ONgX 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: To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Code that previously defined arrays with MAX_BUF_PER_PAGE will no longer work with boot-time page selection because PAGE_SIZE is not known at compile-time. Introduce MAX_BUF_PER_PAGE_SIZE_MAX for this purpose, which is the requirement in the limit when PAGE_SIZE_MAX is the selected page size. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ fs/buffer.c | 2 +- fs/ext4/move_extent.c | 2 +- fs/ext4/readpage.c | 2 +- fs/fat/dir.c | 4 ++-- fs/fat/fatent.c | 4 ++-- include/linux/buffer_head.h | 1 + 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index e55ad471c5306..f00542ad43a5c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2371,7 +2371,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, *arr[MAX_BUF_PER_PAGE_SIZE_MAX]; size_t blocksize; int nr, i; int fully_mapped = 1; diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 204f53b236229..68304426c6f45 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -172,7 +172,7 @@ mext_page_mkuptodate(struct folio *folio, unsigned from, unsigned to) { struct inode *inode = folio->mapping->host; sector_t block; - struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE]; + struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE_SIZE_MAX]; unsigned int blocksize, block_start, block_end; int i, err, nr = 0, partial = 0; BUG_ON(!folio_test_locked(folio)); diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 8494492582abe..5808d85096aeb 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -221,7 +221,7 @@ int ext4_mpage_readpages(struct inode *inode, sector_t block_in_file; sector_t last_block; sector_t last_block_in_file; - sector_t blocks[MAX_BUF_PER_PAGE]; + sector_t blocks[MAX_BUF_PER_PAGE_SIZE_MAX]; unsigned page_block; struct block_device *bdev = inode->i_sb->s_bdev; int length; diff --git a/fs/fat/dir.c b/fs/fat/dir.c index acbec5bdd5210..f3e96ecf21c92 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -1146,7 +1146,7 @@ int fat_alloc_new_dir(struct inode *dir, struct timespec64 *ts) { struct super_block *sb = dir->i_sb; struct msdos_sb_info *sbi = MSDOS_SB(sb); - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; + struct buffer_head *bhs[MAX_BUF_PER_PAGE_SIZE_MAX]; struct msdos_dir_entry *de; sector_t blknr; __le16 date, time; @@ -1213,7 +1213,7 @@ static int fat_add_new_entries(struct inode *dir, void *slots, int nr_slots, { struct super_block *sb = dir->i_sb; struct msdos_sb_info *sbi = MSDOS_SB(sb); - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; + struct buffer_head *bhs[MAX_BUF_PER_PAGE_SIZE_MAX]; sector_t blknr, start_blknr, last_blknr; unsigned long size, copy; int err, i, n, offset, cluster[2]; diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 1db348f8f887a..322cf5b8e5590 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -469,7 +469,7 @@ int fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluster) struct msdos_sb_info *sbi = MSDOS_SB(sb); const struct fatent_operations *ops = sbi->fatent_ops; struct fat_entry fatent, prev_ent; - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; + struct buffer_head *bhs[MAX_BUF_PER_PAGE_SIZE_MAX]; int i, count, err, nr_bhs, idx_clus; BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */ @@ -557,7 +557,7 @@ int fat_free_clusters(struct inode *inode, int cluster) struct msdos_sb_info *sbi = MSDOS_SB(sb); const struct fatent_operations *ops = sbi->fatent_ops; struct fat_entry fatent; - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; + struct buffer_head *bhs[MAX_BUF_PER_PAGE_SIZE_MAX]; int i, err, nr_bhs; int first_cl = cluster, dirty_fsinfo = 0; diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 14acf1bbe0ce6..5dff4837b76cd 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -41,6 +41,7 @@ enum bh_state_bits { }; #define MAX_BUF_PER_PAGE (PAGE_SIZE / 512) +#define MAX_BUF_PER_PAGE_SIZE_MAX (PAGE_SIZE_MAX / 512) struct page; struct buffer_head;