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: 1996812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=xemd=rk=vger.kernel.org=linux-ext4+bounces-4580-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XRvRG2sRMz1xsc for ; Mon, 14 Oct 2024 22:00:58 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XRvRF2Znyz4wcl for ; Mon, 14 Oct 2024 22:00:57 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4XRvRF2XrYz4x7X; Mon, 14 Oct 2024 22:00:57 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.80.249 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903657; cv=pass; b=nt/PT0qBzfpoEwKSZN7IYLI66ulmrYRQCQ96lPP4+ZKHZV0CNjlj5G8R+CJYWf9PFIg6aX9YZmil7kTwspCz0m5qAptM0R3fqdT+fWhAXQ+Hf7GYhKaZWaazvGeCSEzSCEixmClTi9mlyKTPoudFGu8N4+A3zSSa/6j6Y+LGnVNHoCPAUkK8F1nS+HruaGjFmDr3cnLeNZblJyZGu5rXoEyDHYCEES37PDEXONqJB+AYFNvqe6ybUP8jdEgN6bKCJvFbMNS3VTb8wS6EqPrFEM67kg40eqw6EV+ZYxGMKf9FiXHpB0xikZR9fAhoWup2IrFBqrqh+enUdeiZZJpCqg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903657; c=relaxed/relaxed; bh=hXo3oIPvtAqxU/+rzneWWG3oIuEw/H2AD2/H28YBHxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EjbOyC+3/aCXIHb343SjCrgfGY3YQBbu39SWAjSlYc/EZ4vzbqrOXAoqgcOavq6pBREYgil4ufpUQAyMqeXYukCTqOqL7COl2qwVfEXs5Oq4LI0obwuZXP3kR6aVESq2rjXMDqhL++9C9GcLHSz8F7AR6nFJmdl2Lkg4MrtWR/7vCcWhGubLi8nvAYSius1Wh9gLCA2ABZccjhFUNFJCT13jgtpPUOi7xk4FDigGes3wIjDtzSOgNGrnuyWN32jSBgk/CWlz3Sfs8yylwrwn+GYVoWMlmXcCsFATleA/GzrOf26R01vwPLpUV9SEEjNK7vlSLZxP9njt74qRYQDTXA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com; spf=pass (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4580-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4580-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XRvRD5kxsz4wcl for ; Mon, 14 Oct 2024 22:00:56 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5AD871F23BC4 for ; Mon, 14 Oct 2024 11:00:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA19D1A2626; Mon, 14 Oct 2024 10:59:51 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F2B7019CC3A; Mon, 14 Oct 2024 10:59:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728903591; cv=none; b=iRNWXLQFs9MNj+1xwv6IFqUz1Et3imNzgwP1Q+jJJG4HiE69EjcCv8todM3PRO5c7CmQx25Kqnnx+CdEtK5wlCZvCGYhzNPWwQIh26xAIdt5ydNiBQIEgmBr39kQlGaowDiLtw2QIsHD/kpWYEDi4q5Q94QAmJos5+ZX8sn1lOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728903591; c=relaxed/simple; bh=qcw7gwKfkemGiCBFt3H0lPkxjBXG/J4WpLGVGwUe6T8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=evbrpKNrrw8iEd5sR+a5q/dxnGdo0e12WOQ0H3OevZGXZO7dP2JpOEuiMndNRBR/A/K24d3LSoaM2JxDFLke/N9R56ua9k+CNq1hpqsLxKfYf21/8yvsczLJPnPqYtcdH0fkJvJqAELhRo3mwzbGuelGSAj8UUyxBK/g1EX4lvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=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> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;