mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 00:10:51 +07:00
jbd2: rename j_maxlen to j_total_len and add jbd2_journal_max_txn_bufs
The on-disk superblock field sb->s_maxlen represents the total size of the journal including the fast commit area and is no more the max number of blocks available for a transaction. The maximum number of blocks available to a transaction is reduced by the number of fast commit blocks. So, this patch renames j_maxlen to j_total_len to better represent its intent. Also, it adds a function to calculate max number of bufs available for a transaction. Suggested-by: Jan Kara <jack@suse.cz> Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com> Link: https://lore.kernel.org/r/20201106035911.1942128-6-harshadshirwadkar@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
parent
a80f7fcf18
commit
ede7dc7fa0
@ -280,7 +280,7 @@ static int ext4_getfsmap_logdev(struct super_block *sb, struct ext4_fsmap *keys,
|
||||
|
||||
/* Fabricate an rmap entry for the external log device. */
|
||||
irec.fmr_physical = journal->j_blk_offset;
|
||||
irec.fmr_length = journal->j_maxlen;
|
||||
irec.fmr_length = journal->j_total_len;
|
||||
irec.fmr_owner = EXT4_FMR_OWN_LOG;
|
||||
irec.fmr_flags = 0;
|
||||
|
||||
|
@ -3976,7 +3976,7 @@ int ext4_calculate_overhead(struct super_block *sb)
|
||||
* loaded or not
|
||||
*/
|
||||
if (sbi->s_journal && !sbi->s_journal_bdev)
|
||||
overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
|
||||
overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_total_len);
|
||||
else if (ext4_has_feature_journal(sb) && !sbi->s_journal && j_inum) {
|
||||
/* j_inum for internal journal is non-zero */
|
||||
j_inode = ext4_get_journal_inode(sb, j_inum);
|
||||
|
@ -801,7 +801,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
|
||||
if (first_block < journal->j_tail)
|
||||
freed += journal->j_last - journal->j_first;
|
||||
/* Update tail only if we free significant amount of space */
|
||||
if (freed < journal->j_maxlen / 4)
|
||||
if (freed < jbd2_journal_get_max_txn_bufs(journal))
|
||||
update_tail = 0;
|
||||
}
|
||||
J_ASSERT(commit_transaction->t_state == T_COMMIT);
|
||||
|
@ -1348,7 +1348,7 @@ static journal_t *journal_init_common(struct block_device *bdev,
|
||||
journal->j_dev = bdev;
|
||||
journal->j_fs_dev = fs_dev;
|
||||
journal->j_blk_offset = start;
|
||||
journal->j_maxlen = len;
|
||||
journal->j_total_len = len;
|
||||
/* We need enough buffers to write out full descriptor block. */
|
||||
n = journal->j_blocksize / jbd2_min_tag_size();
|
||||
journal->j_wbufsize = n;
|
||||
@ -1531,7 +1531,7 @@ static int journal_reset(journal_t *journal)
|
||||
journal->j_commit_sequence = journal->j_transaction_sequence - 1;
|
||||
journal->j_commit_request = journal->j_commit_sequence;
|
||||
|
||||
journal->j_max_transaction_buffers = journal->j_maxlen / 4;
|
||||
journal->j_max_transaction_buffers = jbd2_journal_get_max_txn_bufs(journal);
|
||||
|
||||
/*
|
||||
* As a special case, if the on-disk copy is already marked as needing
|
||||
@ -1792,15 +1792,15 @@ static int journal_get_superblock(journal_t *journal)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen)
|
||||
journal->j_maxlen = be32_to_cpu(sb->s_maxlen);
|
||||
else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) {
|
||||
if (be32_to_cpu(sb->s_maxlen) < journal->j_total_len)
|
||||
journal->j_total_len = be32_to_cpu(sb->s_maxlen);
|
||||
else if (be32_to_cpu(sb->s_maxlen) > journal->j_total_len) {
|
||||
printk(KERN_WARNING "JBD2: journal file too short\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (be32_to_cpu(sb->s_first) == 0 ||
|
||||
be32_to_cpu(sb->s_first) >= journal->j_maxlen) {
|
||||
be32_to_cpu(sb->s_first) >= journal->j_total_len) {
|
||||
printk(KERN_WARNING
|
||||
"JBD2: Invalid start block of journal: %u\n",
|
||||
be32_to_cpu(sb->s_first));
|
||||
|
@ -74,8 +74,8 @@ static int do_readahead(journal_t *journal, unsigned int start)
|
||||
|
||||
/* Do up to 128K of readahead */
|
||||
max = start + (128 * 1024 / journal->j_blocksize);
|
||||
if (max > journal->j_maxlen)
|
||||
max = journal->j_maxlen;
|
||||
if (max > journal->j_total_len)
|
||||
max = journal->j_total_len;
|
||||
|
||||
/* Do the readahead itself. We'll submit MAXBUF buffer_heads at
|
||||
* a time to the block device IO layer. */
|
||||
@ -134,7 +134,7 @@ static int jread(struct buffer_head **bhp, journal_t *journal,
|
||||
|
||||
*bhp = NULL;
|
||||
|
||||
if (offset >= journal->j_maxlen) {
|
||||
if (offset >= journal->j_total_len) {
|
||||
printk(KERN_ERR "JBD2: corrupted journal superblock\n");
|
||||
return -EFSCORRUPTED;
|
||||
}
|
||||
|
@ -877,7 +877,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
|
||||
goto done;
|
||||
}
|
||||
|
||||
trace_ocfs2_journal_init_maxlen(j_journal->j_maxlen);
|
||||
trace_ocfs2_journal_init_maxlen(j_journal->j_total_len);
|
||||
|
||||
*dirty = (le32_to_cpu(di->id1.journal1.ij_flags) &
|
||||
OCFS2_JOURNAL_DIRTY_FL);
|
||||
|
@ -988,9 +988,9 @@ struct journal_s
|
||||
struct block_device *j_fs_dev;
|
||||
|
||||
/**
|
||||
* @j_maxlen: Total maximum capacity of the journal region on disk.
|
||||
* @j_total_len: Total maximum capacity of the journal region on disk.
|
||||
*/
|
||||
unsigned int j_maxlen;
|
||||
unsigned int j_total_len;
|
||||
|
||||
/**
|
||||
* @j_reserved_credits:
|
||||
@ -1624,6 +1624,11 @@ int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode);
|
||||
int jbd2_fc_wait_bufs(journal_t *journal, int num_blks);
|
||||
int jbd2_fc_release_bufs(journal_t *journal);
|
||||
|
||||
static inline int jbd2_journal_get_max_txn_bufs(journal_t *journal)
|
||||
{
|
||||
return (journal->j_total_len - journal->j_fc_wbufsize) / 4;
|
||||
}
|
||||
|
||||
/*
|
||||
* is_journal_abort
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user