mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
jbd2: precompute number of transaction descriptor blocks
Instead of computing the number of descriptor blocks a transaction can have each time we need it (which is currently when starting each transaction but will become more frequent later) precompute the number once during journal initialization together with maximum transaction size. We perform the precomputation whenever journal feature set is updated similarly as for computation of journal->j_revoke_records_per_block. CC: stable@vger.kernel.org Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Link: https://patch.msgid.link/20240624170127.3253-2-jack@suse.cz Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
@@ -62,28 +62,6 @@ void jbd2_journal_free_transaction(transaction_t *transaction)
|
||||
kmem_cache_free(transaction_cache, transaction);
|
||||
}
|
||||
|
||||
/*
|
||||
* Base amount of descriptor blocks we reserve for each transaction.
|
||||
*/
|
||||
static int jbd2_descriptor_blocks_per_trans(journal_t *journal)
|
||||
{
|
||||
int tag_space = journal->j_blocksize - sizeof(journal_header_t);
|
||||
int tags_per_block;
|
||||
|
||||
/* Subtract UUID */
|
||||
tag_space -= 16;
|
||||
if (jbd2_journal_has_csum_v2or3(journal))
|
||||
tag_space -= sizeof(struct jbd2_journal_block_tail);
|
||||
/* Commit code leaves a slack space of 16 bytes at the end of block */
|
||||
tags_per_block = (tag_space - 16) / journal_tag_bytes(journal);
|
||||
/*
|
||||
* Revoke descriptors are accounted separately so we need to reserve
|
||||
* space for commit block and normal transaction descriptor blocks.
|
||||
*/
|
||||
return 1 + DIV_ROUND_UP(journal->j_max_transaction_buffers,
|
||||
tags_per_block);
|
||||
}
|
||||
|
||||
/*
|
||||
* jbd2_get_transaction: obtain a new transaction_t object.
|
||||
*
|
||||
@@ -109,7 +87,7 @@ static void jbd2_get_transaction(journal_t *journal,
|
||||
transaction->t_expires = jiffies + journal->j_commit_interval;
|
||||
atomic_set(&transaction->t_updates, 0);
|
||||
atomic_set(&transaction->t_outstanding_credits,
|
||||
jbd2_descriptor_blocks_per_trans(journal) +
|
||||
journal->j_transaction_overhead_buffers +
|
||||
atomic_read(&journal->j_reserved_credits));
|
||||
atomic_set(&transaction->t_outstanding_revokes, 0);
|
||||
atomic_set(&transaction->t_handle_count, 0);
|
||||
|
||||
Reference in New Issue
Block a user