From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=210.171.160.6 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796456576; b=Yd8npJokgjcmwHKw8vtMhcg6zfX7YkTTxPhDz982sRnuFcaBjZ6g91AnRq9e1WAUvRUs 6D0Z8M3zNSnmCqWUroV/iUYVUvClpW+kHtT0E47fVAcyUyMQ3KmTSKrCLP5/eq+0q08Bl M7zil4rmRrJlwOmEhZ8YEyG7BFO1WvfxMzNNus+1n7pjGdJoC+SIaCGPi3UA804R+uOIq Yl2Hgk14scaTSjJPjsov5VstGI3kzHYQahqrT0pBLikYgCyMKjrDKEAHNDdh6Y97kxPfJ X2EvhSM68YNGfvCcEhfCTv0+CLQ7rc0NObX7KiSOSyzjfLfVRDAbwAEGj3edpBL2Yow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796456576; h=DMARC-Filter:Received:DKIM-Signature:DKIM-Signature:Received: Received:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: User-Agent:MIME-Version:Content-Type; bh=q+1bgV2Qmc+kG30iAAC0vnw8oRZrNjIqa0Rhd8oZgGw=; b=cNOAPly3Fpia6IJG8/rGGxHBEMQhTqvNDxZsYZL5wCbtt9m3p2viTSZrruM60wXL2E4s 2RpD7k/aWaXmLwphtvOYzekNzcB32td9QP80MU0dlNDyT2Y0IXG0BPTzeb3U0Qz1Pk6Vm gkY3N+i4Acu6UsRpbDft7rKzUsYKy0rpu2Oa05n1zixxOBJTZ/qIg9jqsuZxBrSW7lz4E o0MjqDKsVD0ss/5Rp/C7tp+eaIoz02A1MKtgXNoHIucYfBl7V92g08oDIGQOsDwaEBbzs pCX4KxIUVuDG0+ZNVy0ingGRddTDaMZXWkqiEEsfUfuXbILMelp/NYBaA0GdzyqGQIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mail.parknet.co.jp; spf=pass smtp.mailfrom=parknet.co.jp; dkim=pass header.d=parknet.co.jp header.i=@parknet.co.jp header.a=rsa-sha256 header.s=20250114 header.b=dwVMa7j8; dkim=pass header.d=parknet.co.jp header.i=@parknet.co.jp header.a=ed25519-sha256 header.s=20250114-ed25519 header.b="7xy8/aqx"; arc=none smtp.remote-ip=210.171.160.6 Received: from mail.parknet.co.jp (mail.parknet.co.jp [210.171.160.6]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB48B606A322 for ; Sat, 5 Dec 2026 07:42:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AB48B606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=mail.parknet.co.jp Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=parknet.co.jp Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=parknet.co.jp header.i=@parknet.co.jp header.a=rsa-sha256 header.s=20250114 header.b=dwVMa7j8; dkim=pass header.d=parknet.co.jp header.i=@parknet.co.jp header.a=ed25519-sha256 header.s=20250114-ed25519 header.b=7xy8/aqx Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id 7A3C020BD280; Sat, 5 Dec 2026 16:42:46 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=parknet.co.jp; s=20250114; t=1796456566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=q+1bgV2Qmc+kG30iAAC0vnw8oRZrNjIqa0Rhd8oZgGw=; b=dwVMa7j8MujFkv648iiSd/Adjcm+AjIPMLY0GId2eyz0Y3a+vv3x1ejgPx8iO+ncCoayv/ 1blN/h12Cmzorsc8FqabqJ4u4XG6E604enSF5sa7iLh1/93ZcEhEa4kYCPUdAAbL9wodQZ UjnSCntwJaEQ2jOD6A+Ovmij1Ojsh4Tp1fT7gke9IMRPwig85+N3WTQK8avTM0BnQcX0MP TaELCCcqob7IjSeJsPWNWHq7xaFKEoH/o8FkljChE2CtBZhv5rzgrifbsBmUBcefHOhuj9 0eLr6HcWmCWg7K1Ln8Uq+4xiT3Y6H3hPjhpAjKDywtSxxu+4ruH8voTXIk+6YQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=parknet.co.jp; s=20250114-ed25519; t=1796456566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=q+1bgV2Qmc+kG30iAAC0vnw8oRZrNjIqa0Rhd8oZgGw=; b=7xy8/aqxzl8Fu9K3FpTCgD7hKtajyzWQbSoH6aM5dAqMs9Iy3fGPuQPOwHQyTBzsl/aKUD rIqrBb7n2hXdVGDQ== Received: from devron.myhome.or.jp (devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (Postfix) with ESMTPS id 00CA7E000AA; Sat, 05 Dec 2026 16:42:46 +0900 (JST) Received: by devron.myhome.or.jp (Postfix, from userid 1000) id E70EB2200167; Sat, 05 Dec 2026 16:42:45 +0900 (JST) From: OGAWA Hirofumi To: Eric Curtin Cc: linux-kernel@vger.kernel.org, Ryan Roberts Subject: Re: [RFC PATCH v2 22/22] fat: Use MAX_BUF_PER_PAGE_SIZE_MAX to size buffer_head arrays In-Reply-To: <20261202031533.1665444-23-ericcurtin17@gmail.com> References: <20261202031533.1665444-1-ericcurtin17@gmail.com> <20261202031533.1665444-23-ericcurtin17@gmail.com> Date: Sat, 05 Dec 2026 16:42:45 +0900 Message-ID: <87ik182mx6.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) 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-Type: text/plain Eric Curtin writes: > 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 Hm, this usage was to prevent stack overflow. So it should not use possible maximum value. Looks like no other users than fatfs anymore. So instead, could you copy it to fs/fat/fat.h as FAT_BUF_ON_STACK or such? (and MAX_BUF_PER_PAGE can change to it or remove) #define FAT_BUF_ON_STACK 8 Thanks. > --- > 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; > -- OGAWA Hirofumi