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

* Re: [PATCH] Shrink fast commit buffer when not used
  2022-04-07 12:42 [PATCH] Shrink fast commit buffer when not used Shaun Tancheff
@ 2022-05-11 16:33 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2022-05-11 16:33 UTC (permalink / raw)
  To: Shaun Tancheff
  Cc: shaun, Andreas Dilger, open list:EXT4 FILE SYSTEM, open list

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

^ permalink raw reply	[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).