[PATCH 4/4] fat: allocate multiple clusters in fallocate

From: Matheus Alves de Almeida

Date: Wed Oct 07 2026 - 22:12:57 EST


The fat_fallocate() code currently does many 1-cluster allocations when
growing a file. Make it allocate everything with one call instead.

Signed-off-by: Matheus Alves de Almeida <matheus.aalmeida@xxxxxxxxxxxx>
---
fs/fat/file.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/fat/file.c b/fs/fat/file.c
index 41d49e9de..3aa541c6b 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -290,12 +290,10 @@ static long fat_fallocate(struct file *file, int mode,
nr_cluster = (mm_bytes + (sbi->cluster_size - 1)) >>
sbi->cluster_bits;

- /* Start the allocation.We are not zeroing out the clusters */
- while (nr_cluster-- > 0) {
- err = fat_add_clusters(inode, 1);
- if (err)
- goto error;
- }
+ /* Allocate the clusters. We are not zeroing them out */
+ err = fat_add_clusters(inode, nr_cluster);
+ if (err)
+ goto error;
} else {
if ((offset + len) <= i_size_read(inode))
goto error;
--
2.43.0