From: Ryan Roberts <ryan.roberts@arm.com>
To: "Theodore Ts'o" <tytso@mit.edu>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Andrew Morton <akpm@linux-foundation.org>,
Anshuman Khandual <anshuman.khandual@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Christian Brauner <brauner@kernel.org>,
David Hildenbrand <david@redhat.com>,
Greg Marsden <greg.marsden@oracle.com>,
Ivan Ivanov <ivan.ivanov@suse.com>,
Kalesh Singh <kaleshsingh@google.com>,
Marc Zyngier <maz@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Matthias Brugger <mbrugger@suse.com>,
Miroslav Benes <mbenes@suse.cz>,
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
Will Deacon <will@kernel.org>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
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 [thread overview]
Message-ID: <20241014105912.3207374-7-ryan.roberts@arm.com> (raw)
In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com>
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 <ryan.roberts@arm.com>
---
***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;
--
2.43.0
next prev parent reply other threads:[~2024-10-14 10:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241014105514.3206191-1-ryan.roberts@arm.com>
[not found] ` <20241014105912.3207374-1-ryan.roberts@arm.com>
2024-10-14 10:58 ` [RFC PATCH v1 06/57] mm: Remove PAGE_SIZE compile-time constant assumption Ryan Roberts
2024-10-16 14:37 ` Ryan Roberts
2024-11-14 10:17 ` Vlastimil Babka
2024-11-26 10:08 ` Ryan Roberts
2024-10-14 10:58 ` Ryan Roberts [this message]
2024-10-14 10:58 ` [RFC PATCH v1 08/57] fs: " Ryan Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241014105912.3207374-7-ryan.roberts@arm.com \
--to=ryan.roberts@arm.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=greg.marsden@oracle.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=ivan.ivanov@suse.com \
--cc=kaleshsingh@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=mbenes@suse.cz \
--cc=mbrugger@suse.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).