ntfs3.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Kari Argillander <kari.argillander@gmail.com>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	ntfs3@lists.linux.dev
Cc: Kari Argillander <kari.argillander@gmail.com>,
	linux-kernel@vger.kernel.org,
	Christian Brauner <christian.brauner@ubuntu.com>
Subject: [PATCH 11/11] fs/ntfs3: Initiliaze sb blocksize only in one place + refactor
Date: Thu,  9 Sep 2021 21:09:42 +0300	[thread overview]
Message-ID: <20210909180942.8634-12-kari.argillander@gmail.com> (raw)
In-Reply-To: <20210909180942.8634-1-kari.argillander@gmail.com>

Right now sb blocksize first get initiliazed in fill_super but in can be
changed in helper function. It makes more sense to that this happened
only in one place.

Because we move this to helper function it makes more sense that
s_maxbytes will also be there. I rather have every sb releted thing in
fill_super, but because there is already sb releted stuff in this
helper. This will have to do for now.

Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
---
I really would like to initialize all sb stuff in fill_super and I try
it but it did not work out so well. Maybe if we do more refactoring
then maybe, but this should still be better that these can be found in
one place.

---
 fs/ntfs3/super.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 321fcfce64e1..9ad04fcf535a 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -842,8 +842,7 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
 	rec->total = cpu_to_le32(sbi->record_size);
 	((struct ATTRIB *)Add2Ptr(rec, ao))->type = ATTR_END;
 
-	if (sbi->cluster_size < PAGE_SIZE)
-		sb_set_blocksize(sb, sbi->cluster_size);
+	sb_set_blocksize(sb, min_t(u32, sbi->cluster_size, PAGE_SIZE));
 
 	sbi->block_mask = sb->s_blocksize - 1;
 	sbi->blocks_per_cluster = sbi->cluster_size >> sb->s_blocksize_bits;
@@ -856,9 +855,11 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size,
 	if (clusters >= (1ull << (64 - sbi->cluster_bits)))
 		sbi->maxbytes = -1;
 	sbi->maxbytes_sparse = -1;
+	sb->s_maxbytes = MAX_LFS_FILESIZE;
 #else
 	/* Maximum size for sparse file. */
 	sbi->maxbytes_sparse = (1ull << (sbi->cluster_bits + 32)) - 1;
+	sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
 #endif
 
 	err = 0;
@@ -913,20 +914,12 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
 			~(u64)(sbi->discard_granularity - 1);
 	}
 
-	sb_set_blocksize(sb, PAGE_SIZE);
-
 	/* Parse boot. */
 	err = ntfs_init_from_boot(sb, rq ? queue_logical_block_size(rq) : 512,
 				  bdev->bd_inode->i_size);
 	if (err)
 		return err;
 
-#ifdef CONFIG_NTFS3_64BIT_CLUSTER
-	sb->s_maxbytes = MAX_LFS_FILESIZE;
-#else
-	sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits;
-#endif
-
 	/*
 	 * Load $Volume. This should be done before $LogFile
 	 * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'.
-- 
2.25.1


  parent reply	other threads:[~2021-09-09 18:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09 18:09 [PATCH 00/11] fs/ntfs3: Refactor fill_super Kari Argillander
2021-09-09 18:09 ` [PATCH 01/11] fs/ntfs3: Fix wrong error message $Logfile -> $UpCase Kari Argillander
2021-09-09 18:09 ` [PATCH 02/11] fs/ntfs3: Change EINVAL to ENOMEM when d_make_root fails Kari Argillander
2021-09-09 18:09 ` [PATCH 03/11] fs/ntfs3: Remove impossible fault condition in fill_super Kari Argillander
2021-09-09 18:09 ` [PATCH 04/11] fs/ntfs3: Return straight without goto " Kari Argillander
2021-09-09 18:09 ` [PATCH 05/11] fs/ntfs3: Remove unnecessary variable loading " Kari Argillander
2021-09-09 18:09 ` [PATCH 06/11] fs/ntfs3: Use sb instead of sbi->sb " Kari Argillander
2021-09-09 18:09 ` [PATCH 07/11] fs/ntfs3: Remove tmp var is_ro in ntfs_fill_super Kari Argillander
2021-09-09 18:09 ` [PATCH 08/11] fs/ntfs3: Remove tmp pointer bd_inode in fill_super Kari Argillander
2021-09-09 18:09 ` [PATCH 09/11] fs/ntfs3: Remove tmp pointer upcase " Kari Argillander
2021-09-09 18:09 ` [PATCH 10/11] fs/ntfs3: Initialize pointer before use place " Kari Argillander
2021-09-09 18:09 ` Kari Argillander [this message]
2021-09-20 16:07 ` [PATCH 00/11] fs/ntfs3: Refactor fill_super Konstantin Komarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909180942.8634-12-kari.argillander@gmail.com \
    --to=kari.argillander@gmail.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).