Blame SOURCES/0073-fs-ntfs3-Initiliaze-sb-blocksize-only-in-one-place-r.patch

Kmods SIG 8b815c
From 28861e3bbd9e7ac4cd9c811aad71b4d116e27930 Mon Sep 17 00:00:00 2001
Kmods SIG 8b815c
From: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 8b815c
Date: Thu, 9 Sep 2021 21:09:42 +0300
Kmods SIG 8b815c
Subject: [Backport 28861e3bbd9e] src: Initiliaze sb blocksize only in one
Kmods SIG 8b815c
 place + refactor
Kmods SIG 8b815c
Kmods SIG 8b815c
Right now sb blocksize first get initiliazed in fill_super but in can be
Kmods SIG 8b815c
changed in helper function. It makes more sense to that this happened
Kmods SIG 8b815c
only in one place.
Kmods SIG 8b815c
Kmods SIG 8b815c
Because we move this to helper function it makes more sense that
Kmods SIG 8b815c
s_maxbytes will also be there. I rather have every sb releted thing in
Kmods SIG 8b815c
fill_super, but because there is already sb releted stuff in this
Kmods SIG 8b815c
helper. This will have to do for now.
Kmods SIG 8b815c
Kmods SIG 8b815c
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Kmods SIG 8b815c
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Kmods SIG 8b815c
---
Kmods SIG 8b815c
 src/super.c | 13 +++----------
Kmods SIG 8b815c
 1 file changed, 3 insertions(+), 10 deletions(-)
Kmods SIG 8b815c
Kmods SIG 8b815c
diff --git a/src/super.c b/src/super.c
Kmods SIG 8b815c
index 3d034eac2bd197408e7e64a279799d68ad1a8129..cefb9ddaf4db78890e9dc389416f47323bf33bcd 100644
Kmods SIG 8b815c
--- a/src/super.c
Kmods SIG 8b815c
+++ b/src/super.c
Kmods SIG 8b815c
@@ -840,8 +840,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
Kmods SIG 8b815c
 	rec->total = cpu_to_le32(sbi->record_size);
Kmods SIG 8b815c
 	((struct ATTRIB *)Add2Ptr(rec, ao))->type = ATTR_END;
Kmods SIG 8b815c
 
Kmods SIG 8b815c
-	if (sbi->cluster_size < PAGE_SIZE)
Kmods SIG 8b815c
-		sb_set_blocksize(sb, sbi->cluster_size);
Kmods SIG 8b815c
+	sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE));
Kmods SIG 8b815c
 
Kmods SIG 8b815c
 	sbi->block_mask = sb->s_blocksize - 1;
Kmods SIG 8b815c
 	sbi->blocks_per_cluster = sbi->cluster_size >> sb->s_blocksize_bits;
Kmods SIG 8b815c
@@ -854,9 +853,11 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
Kmods SIG 8b815c
 	if (clusters >= (1ull << (64 - sbi->cluster_bits)))
Kmods SIG 8b815c
 		sbi->maxbytes = -1;
Kmods SIG 8b815c
 	sbi->maxbytes_sparse = -1;
Kmods SIG 8b815c
+	sb->s_maxbytes = MAX_LFS_FILESIZE;
Kmods SIG 8b815c
 #else
Kmods SIG 8b815c
 	/* Maximum size for sparse file. */
Kmods SIG 8b815c
 	sbi->maxbytes_sparse = (1ull << (sbi->cluster_bits + 32)) - 1;
Kmods SIG 8b815c
+	sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
Kmods SIG 8b815c
 #endif
Kmods SIG 8b815c
 
Kmods SIG 8b815c
 	err = 0;
Kmods SIG 8b815c
@@ -911,20 +912,12 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
Kmods SIG 8b815c
 			~(u64)(sbi->discard_granularity - 1);
Kmods SIG 8b815c
 	}
Kmods SIG 8b815c
 
Kmods SIG 8b815c
-	sb_set_blocksize(sb, PAGE_SIZE);
Kmods SIG 8b815c
-
Kmods SIG 8b815c
 	/* Parse boot. */
Kmods SIG 8b815c
 	err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512,
Kmods SIG 8b815c
 				  bdev->bd_inode->i_size);
Kmods SIG 8b815c
 	if (err)
Kmods SIG 8b815c
 		return err;
Kmods SIG 8b815c
 
Kmods SIG 8b815c
-#ifdef CONFIG_NTFS3_64BIT_CLUSTER
Kmods SIG 8b815c
-	sb->s_maxbytes = MAX_LFS_FILESIZE;
Kmods SIG 8b815c
-#else
Kmods SIG 8b815c
-	sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
Kmods SIG 8b815c
-#endif
Kmods SIG 8b815c
-
Kmods SIG 8b815c
 	/*
Kmods SIG 8b815c
 	 * Load $Volume. This should be done before $LogFile
Kmods SIG 8b815c
 	 * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'.
Kmods SIG 8b815c
-- 
Kmods SIG 8b815c
2.31.1
Kmods SIG 8b815c