From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796181396; b=VHY9ZCc2tUD+syFZCZvjV0Oh+7BOIX+CEIKDCjGLKqZheSAVBDmlqUHz7K0phMLJnVfD Hi9McvuNxN1BiKSrDKeoFAG8eu50vRlFfEuys76ovGrUInnoRy+x22JuG9JivJEDvfbbj Jc0gqYw0J51nNUO3kLgqTQWKC+8+kzUtTkrnmslH3zTSZKlx93Zw5FmFG/M5d3TsdH8xF JrUneUa7MfVpxwmT6sh+++dD6GsVEhokUGACtA4i9NU2OtgWFVoNzmwlPL2QgnPSANw+D fnDh5iwttH7HGQE+GAUOBgGP2hil/Odio9JjNPqJHUSoSl/0MBh13Lo1KDdFaxZysqw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796181396; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=0gZjnFlwLNiXwDAD5EDzBZ1+USfRsOPXFxNc1xOO9sI=; b=EG+zpVWhTmM5WPAOY7H33OLkAJKrY74C/jSOuoyyQ+dwCjBhy2mPxEGEaNKSLFNRfAuB L2Jluxb6QulnPaJ091eeoTTFpRqbgaeqtS7d1juRbXkFMKP7qGSci2vcLFbf6YJDNzBam Te6sJ3i4XbAUDz0Lf9xEOLzdXJrqUgEotUhMqfDguAAHmknwTcQlBOTK5/P0cpLUX9EBt +yOiaHBNiKAUuksFD5uqsWvK/EbfORScgG5byTbAmesTt22YCQuPwEmP0OGKBJQBwSPIb cDSskAMBDJsxmcmd08wN345K2GQEwh5CRQVhWZl5oY4FSRYrMl99MEvf8glWN0z5GiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tEyPMR02; arc=none smtp.remote-ip=209.85.221.53 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3629760A2621 for ; Wed, 2 Dec 2026 03:16:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3629760A2621 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tEyPMR02 Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-4a5024b3c28so7539556f8f.0 for ; Tue, 01 Dec 2026 19:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796181394; x=1796786194; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0gZjnFlwLNiXwDAD5EDzBZ1+USfRsOPXFxNc1xOO9sI=; b=tEyPMR0239mHWNaFr+aXXJcD9pvTyyy7ZzYbUVpaAYjfCE40ETuzh+9BaeJHwVVMPm 08y8ZsrQHImw26kZzbvaZk/M2NnFQc8baUKZaJPLv9bM7AGOBTJ92u2TJotRPyu6ImX+ Suj2RHIhshswguEAgi6O5plVpFcjYLsqAuDR0nuXhhJZFWlylL9GmGm0DoAqQ6zSCnYT jESF3wHES5YMFUZ99a4Nzbml9jZfTRIF9eqnyQiw7C3Jbb47By+tHc0KjLc7hMszckIw i1TELkp4SyvnknLfpcknM8fuPxMjEbUJE0hG/ZkPNr4HamCVGCaeXo7n/YrMHwvbqTJx GWgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796181394; x=1796786194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0gZjnFlwLNiXwDAD5EDzBZ1+USfRsOPXFxNc1xOO9sI=; b=sKv+gbN0vSVU0pKwOZoY10IN0u3ZDeHotzzpQ89xtMT01Pm+KgoRh3QNYphHsm+BRE ZuP8ld+AIQSb+DZAeZASmQuL8eG4k18MATFTokbrC5dT353Ays6RSvbpc1BzvrbDONRw BPWqhT1VRDoL4477oYQ6GdDf0Usay+DOHZNQe/q/ibeqJArbPiGSjgdNw3CgMgz/q8Xr nVsHdXJ3V38p3XRmL8FVuCvoD0jraQN+0C+QxMe8mbgA5NF5e2VfZcZuKxSeXHu6NOKD mukPhqxLrlTs3oQ95rLVX6tiDeDsG0SZychlUFhm33gHCS+Tm0qgrdtyNq5SC12eqF3X Hlpg== X-Gm-Message-State: APuU4Z8Dyjod3sacsnK/gWoH1TZ+OxIRVs0pR9ckU7/6GKmBbrxCTNIe 1jGdWW35O/UsAmJu66sixBFmt190pHOzQkL5Gwm6T4MzRBr+toMYX/0HHsrD4cdeh48CI/YY X-Gm-Gg: AZFdTZdnUlz6xzlx6w9jTNfV1iMcxDta6hH11nyVR0kjsOXJzN0gHz5KuWo+77U5PvF FQLBppY21VxUQf+wadp2V/A1Vrk9Q1xHcnQXW4MMPOIkspgF47rTU6i2wTeYH6kom3okBYEWlMT wqpI/IAo3xw79UYD9n8yEcfZMbmEusz9bSuIzqKUT9Yu+lWK9p4oeHgVDAPu4Llur6LjLINpg5H 3H89zqRMez9NCLSXETpDt3vSvsR9SPBL7Cnf8JTYy9AcTMxIldlOGDKtSZtG9yTAAoDc8yfhl7k 3vjTawJZiV0B1TMekj8J6CDnC1rEQIF964TX+a7HdcP3Aouz0q2Sq60hrWzSNcLJ3OsPZdAjxR3 OwqB91JqPsFnRQ3le6rY5d5lGHInBBD53p2vE7kAedaFK0y/LkWKRs47PX4XR7+VSrof9l6yclO o53ZGOBsXyxRDVRJIzNUq9bCgATbM3KJWD/G5gVRIdxz9+zKNzEgPl9EeVClWc1O8w5supFhbQb lxIXZO2TKtsuESycKuyAwrSZmJRTSJI1pJDXj4jruui7LcMNcafejRrT6KpXp/DhJETr2YthY3K 5AA4U0VEFsVpBTaA/5uHJspmZMRHnip5onv72Q== X-Received: by 2002:a5d:5e01:0:b0:492:2b36:a149 with SMTP id ffacd0b85a97d-4aa59ffe3c1mr89132032f8f.25.1796181394536; Tue, 01 Dec 2026 19:16:34 -0800 (PST) Received: from NULL.Home.net ([2001:8a0:7280:4000:12d:c3b9:cecc:8966]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab65cb4341sm73334766f8f.4.2026.12.01.19.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 19:16:34 -0800 (PST) From: Eric Curtin To: linux-kernel@vger.kernel.org Cc: Ryan Roberts , OGAWA Hirofumi Subject: [RFC PATCH v2 22/22] fat: Use MAX_BUF_PER_PAGE_SIZE_MAX to size buffer_head arrays Date: Wed, 2 Dec 2026 03:15:25 +0000 Message-ID: <20261202031533.1665444-23-ericcurtin17@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202031533.1665444-1-ericcurtin17@gmail.com> References: <20261202031533.1665444-1-ericcurtin17@gmail.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ryan Roberts MAX_BUF_PER_PAGE is derived from PAGE_SIZE, so with boot-time page size selection it cannot be used to size an on-stack array. Add MAX_BUF_PER_PAGE_SIZE_MAX, the value of MAX_BUF_PER_PAGE at PAGE_SIZE_MAX, and use it for the bhs[] arrays in fat_alloc_new_dir(), fat_add_new_entries(), __fat_alloc_clusters() and fat_free_clusters(). No functional change for compile-time page sizes. Signed-off-by: Ryan Roberts Signed-off-by: Eric Curtin --- fs/fat/dir.c | 4 ++-- fs/fat/fatent.c | 4 ++-- include/linux/buffer_head.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 0cebcaf82426..3923d68153dd 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c @@ -1184,7 +1184,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; @@ -1251,7 +1251,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 2d10a815a579..1b2d925656fb 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -510,7 +510,7 @@ static int __fat_alloc_clusters(struct inode *inode, int *cluster, int nr_cluste 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; lock_fat(sbi); @@ -616,7 +616,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 f8782b719026..dbf1948950af 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -42,6 +42,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;