[PATCH 08/11] fs/ntfs3: reserve a compression unit in maxbytes_sparse

From: Konstantin Komarov

Date: Fri Oct 09 2026 - 13:19:21 EST


With 32-bit clusters, the maximum size of a sparse file was computed
as the largest offset addressable by a 32-bit VCN.

Reserve one compression unit below the limit so the rounded-up VCN
still fits.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@xxxxxxxxxxxxxxxxxxxx>
---
fs/ntfs3/super.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index cf67d34568d8..0c347085cb85 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1235,8 +1235,13 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
sbi->maxbytes_sparse = MAX_LFS_FILESIZE;
sb->s_maxbytes = MAX_LFS_FILESIZE;
#else
- /* Maximum size for sparse file. */
- sbi->maxbytes_sparse = (1ull << (cluster_bits + 32)) - 1;
+ /*
+ * Maximum size for sparse file:
+ * 16 aligned up clusters should fit in 32 bits.
+ * xfstest 308 on sparse file.
+ */
+ sbi->maxbytes_sparse = (1ull << (cluster_bits + 32)) - 1 -
+ (sbi->cluster_size << NTFS_LZNT_CUNIT);
sb->s_maxbytes = 0xFFFFFFFFull << cluster_bits;
#endif

--
2.43.0