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; From patchwork Mon Oct 14 10:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 1996813 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=ylys=rk=vger.kernel.org=linux-ext4+bounces-4581-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 4XRvS40SYPz1xsc for ; Mon, 14 Oct 2024 22:01:40 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XRvS30Kydz4x8C for ; Mon, 14 Oct 2024 22:01:39 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4XRvS30HPyz4wbr; Mon, 14 Oct 2024 22:01:39 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903699; cv=pass; b=uWEdFRXD4hj41cY6IzTLMIffjbZATftbB+f5zcF/aGcctm4RPflRAhNDziw0rzGVkBi5Q6gUtfrK2G6uGE1VoqVl9fBwssu5246jaLXbuCuiC6E0rrzX8JvRkkvH+bSvpQk1YtHHCdlyPv3kacq1b+hDju1UMOcohLAsA9euANUyNnU6o4n1tL3Wq11WNkTgcuTOtQpa00JHCqmeAO5YZJB2+pKc+wwKVRI3DDIYXm8cAECdRNRyX1HGpW1U84v5oXfe9Kw5qnlPEBK1jGP+vT1zLLpOuzlpDLAfaRs3+SSyQ7o2CdO9RsG2oLRcqJWMrH1AH68e86xhwa4aaWJznQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903699; c=relaxed/relaxed; bh=4YDRe8auf3W9gPGvw4mfS6WcApteYPOWnCg7H4VxM6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=La530nAhqNbi4gkXuaWtb+Elg6jiOkalQYmzX3+Bdz7iHh59pyNZf5OwWkjL7zpXJ3CF7PzaFEOKU2skJfpZSIdBIhuLi/XkUX7BmZEQb+sK/qKWFw1XL5w/J2Cn3yv3V7sxAixIaPolqSWnpR8xPizD4uUHWQnfLG3C39DjorKM1/5Y81vATY7z5qy8m5gb8Ya02UMGUnW18Faz+nKWGGzOvWeZV3XiOdExffuK1qE7meHqGrFd4MiqB8fTOLLXi3usJKBK5hYibEL40Gb3vTekUjbeYtgPS8g49NIblFDQyp/zaO5j1PaenYp7CmNnz64CC9E3hcA3a1v+Uf6cpQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com; spf=pass (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4581-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.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4581-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (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 4XRvS24H89z4x8C for ; Mon, 14 Oct 2024 22:01:38 +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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C67B81C23821 for ; Mon, 14 Oct 2024 11:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C78EA1A7247; Mon, 14 Oct 2024 11:00:01 +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 407BD19D062; Mon, 14 Oct 2024 10:59:59 +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=1728903601; cv=none; b=CVmTu8QbpgCf+ZoiFLfrg0QZzzp8cGHT0hUojEwJo0fqsyf0SJrkUwDEt7+/ZyTwlwvyel0vQpV2jUcYle9JMghNLHQrDgo+mqnAs+Yg264a77WeVmd684BWSf1KBvBMP5uRUrDy70Kq07an/y89InKEyOCt6x7WtvVF0++24xM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728903601; c=relaxed/simple; bh=vfJwjToLALeeCjImxT2qgvgczni/pAelp8cETW25/gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvEPLtDCCJQhB2htmy4MoT/s1Xq4Tc/y7w4fS2Cv0TZkZ/K9PgUR5pwS6RHkQrAzcabpei2U4COw8NIezvUVO2Jd6SHs5visMDLDVwdG8hUlG2CVwmk8P5xkQILU2jpWcNvW0O0aSfvR9M8nClSRvmbg6/3hGETiPq3hXLjhAMY= 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 432CD1684; Mon, 14 Oct 2024 04:00:28 -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 D33E63F51B; Mon, 14 Oct 2024 03:59:55 -0700 (PDT) From: Ryan Roberts To: "Theodore Ts'o" , Andreas Dilger , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 10/57] fs/ext4: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:17 +0100 Message-ID: <20241014105912.3207374-10-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. Convert CPP PAGE_SIZE conditionals to C if/else. For compile-time page size, the compiler will strip the dead part, and for boot-time page size, the condition will be evaluated at run time. 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/ext4/ext4.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261ed..1a6dbd925024a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2415,31 +2415,31 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) { unsigned len = le16_to_cpu(dlen); -#if (PAGE_SIZE >= 65536) - if (len == EXT4_MAX_REC_LEN || len == 0) - return blocksize; - return (len & 65532) | ((len & 3) << 16); -#else - return len; -#endif + if (PAGE_SIZE >= 65536) { + if (len == EXT4_MAX_REC_LEN || len == 0) + return blocksize; + return (len & 65532) | ((len & 3) << 16); + } else { + return len; + } } static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) { BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)); -#if (PAGE_SIZE >= 65536) - if (len < 65536) + if (PAGE_SIZE >= 65536) { + if (len < 65536) + return cpu_to_le16(len); + if (len == blocksize) { + if (blocksize == 65536) + return cpu_to_le16(EXT4_MAX_REC_LEN); + else + return cpu_to_le16(0); + } + return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); + } else { return cpu_to_le16(len); - if (len == blocksize) { - if (blocksize == 65536) - return cpu_to_le16(EXT4_MAX_REC_LEN); - else - return cpu_to_le16(0); } - return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); -#else - return cpu_to_le16(len); -#endif } /*