Message ID | 20220407124244.2014497-1-shaun.tancheff@hpe.com |
---|---|
State | Rejected |
Headers | show |
Series | Shrink fast commit buffer when not used | expand |
On Thu, Apr 07, 2022 at 07:42:44PM +0700, Shaun Tancheff wrote: > Shrink the fast-commit buffer when the feature is not > enabled. By default the fast-commit buffer will allocate 256 > blocks if s_num_fc_blks is 0. Set s_num_fc_blks to a smaller > value (> 0) to avoid allocating a large unused buffer, this > also makes more journal credits available when fast commit > is not used. > > Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com> The journal->j_superblock data structure is stored on disk, so when you make this change, it's can and will get written back to disk, at which point the s_num_fc_blks is permanently strunk. If the file system might be mounted with the mount option data=journal mode, fast_commit will be disabled; but it might be subsequently mounted without this mount option. Why do you believe this patch is necessary? If there is a file system which is only going to be mounted using data=journal, the file system should simply not be formwatted with the fast_commit option. - Ted
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 81749eaddf4c..d2df10dc7cc3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4222,6 +4222,14 @@ static int count_overhead(struct super_block *sb, ext4_group_t grp, ext4_count_free(buf, EXT4_CLUSTERS_PER_GROUP(sb) / 8); } +static void strink_journal_fc_buffer(struct super_block *ext4_sb) +{ + journal_t *journal = EXT4_SB(ext4_sb)->s_journal; + journal_superblock_t *sb = journal->j_superblock; + + sb->s_num_fc_blks = cpu_to_be32(8); +} + /* * Compute the overhead and stash it in sbi->s_overhead */ @@ -5189,6 +5197,13 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) goto failed_mount_wq; } + /* Since fast-commit is disabled, shrink it's dedicated memory + * and it's share of the journal space so we can use the extra + * credits + */ + if (!test_opt2(sb, JOURNAL_FAST_COMMIT)) + strink_journal_fc_buffer(sb); + if (!set_journal_csum_feature_set(sb)) { ext4_msg(sb, KERN_ERR, "Failed to set journal checksum " "feature set");
Shrink the fast-commit buffer when the feature is not enabled. By default the fast-commit buffer will allocate 256 blocks if s_num_fc_blks is 0. Set s_num_fc_blks to a smaller value (> 0) to avoid allocating a large unused buffer, this also makes more journal credits available when fast commit is not used. Signed-off-by: Shaun Tancheff <shaun.tancheff@hpe.com> --- fs/ext4/super.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)