linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Shrink fast commit buffer when not used
@ 2022-04-07 12:42 Shaun Tancheff
  2022-05-11 16:33 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Shaun Tancheff @ 2022-04-07 12:42 UTC (permalink / raw)
  To: shaun, Theodore Ts'o, Andreas Dilger,
	open list:EXT4 FILE SYSTEM, open list
  Cc: Shaun Tancheff

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(+)

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");
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-07 12:42 [PATCH] Shrink fast commit buffer when not used Shaun Tancheff
2022-05-11 16:33 ` Theodore Ts'o

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).