Skip to content

Commit 9bd23c3

Browse files
harshadjstytso
authored andcommitted
jbd2: add a helper to find out number of fast commit blocks
Add a helper to read number of fast commit blocks from jbd2 superblock and also rename the JBD2_MIN_FC_BLKS to JBD2_DEFAULT_FAST_COMMIT_BLOCKS since this constant is just the default number of fast commit blocks to use in case number of fast commit blocks isn't set in jbd2 superblock. Signed-off-by: Harshad Shirwadkar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 941ba12 commit 9bd23c3

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

fs/jbd2/journal.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,9 +1869,7 @@ static int load_superblock(journal_t *journal)
18691869

18701870
if (jbd2_has_feature_fast_commit(journal)) {
18711871
journal->j_fc_last = be32_to_cpu(sb->s_maxlen);
1872-
num_fc_blocks = be32_to_cpu(sb->s_num_fc_blks);
1873-
if (!num_fc_blocks)
1874-
num_fc_blocks = JBD2_MIN_FC_BLOCKS;
1872+
num_fc_blocks = jbd2_journal_get_num_fc_blks(sb);
18751873
if (journal->j_last - num_fc_blocks >= JBD2_MIN_JOURNAL_BLOCKS)
18761874
journal->j_last = journal->j_fc_last - num_fc_blocks;
18771875
journal->j_fc_first = journal->j_last + 1;
@@ -2102,9 +2100,7 @@ jbd2_journal_initialize_fast_commit(journal_t *journal)
21022100
journal_superblock_t *sb = journal->j_superblock;
21032101
unsigned long long num_fc_blks;
21042102

2105-
num_fc_blks = be32_to_cpu(sb->s_num_fc_blks);
2106-
if (num_fc_blks == 0)
2107-
num_fc_blks = JBD2_MIN_FC_BLOCKS;
2103+
num_fc_blks = jbd2_journal_get_num_fc_blks(sb);
21082104
if (journal->j_last - num_fc_blks < JBD2_MIN_JOURNAL_BLOCKS)
21092105
return -ENOSPC;
21102106

include/linux/jbd2.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern void *jbd2_alloc(size_t size, gfp_t flags);
6868
extern void jbd2_free(void *ptr, size_t size);
6969

7070
#define JBD2_MIN_JOURNAL_BLOCKS 1024
71-
#define JBD2_MIN_FC_BLOCKS 256
71+
#define JBD2_DEFAULT_FAST_COMMIT_BLOCKS 256
7272

7373
#ifdef __KERNEL__
7474

@@ -1692,6 +1692,13 @@ static inline int jbd2_journal_has_csum_v2or3(journal_t *journal)
16921692
return journal->j_chksum_driver != NULL;
16931693
}
16941694

1695+
static inline int jbd2_journal_get_num_fc_blks(journal_superblock_t *jsb)
1696+
{
1697+
int num_fc_blocks = be32_to_cpu(jsb->s_num_fc_blks);
1698+
1699+
return num_fc_blocks ? num_fc_blocks : JBD2_DEFAULT_FAST_COMMIT_BLOCKS;
1700+
}
1701+
16951702
/*
16961703
* Return number of free blocks in the log. Must be called under j_state_lock.
16971704
*/

0 commit comments

Comments
 (0)