Skip to content

Commit

Permalink
jbd2: remove __journal_try_to_free_buffer()
Browse files Browse the repository at this point in the history
__journal_try_to_free_buffer() has only one caller and it's logic is
much simple now, so just remove it and open code in
jbd2_journal_try_to_free_buffers().

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230606135928.434610-7-yi.zhang@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Zhang Yi authored and Theodore Ts'o committed Jul 11, 2023
1 parent 46f881b commit 3c55097
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -2099,29 +2099,6 @@ void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
__brelse(bh);
}

/*
* Called from jbd2_journal_try_to_free_buffers().
*
* Called under jh->b_state_lock
*/
static void
__journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
{
struct journal_head *jh;

jh = bh2jh(bh);

if (jh->b_next_transaction != NULL || jh->b_transaction != NULL)
return;

spin_lock(&journal->j_list_lock);
/* Remove written-back checkpointed metadata buffer */
if (jh->b_cp_transaction != NULL)
jbd2_journal_try_remove_checkpoint(jh);
spin_unlock(&journal->j_list_lock);
return;
}

/**
* jbd2_journal_try_to_free_buffers() - try to free page buffers.
* @journal: journal for operation
Expand Down Expand Up @@ -2179,7 +2156,13 @@ bool jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio)
continue;

spin_lock(&jh->b_state_lock);
__journal_try_to_free_buffer(journal, bh);
if (!jh->b_transaction && !jh->b_next_transaction) {
spin_lock(&journal->j_list_lock);
/* Remove written-back checkpointed metadata buffer */
if (jh->b_cp_transaction != NULL)
jbd2_journal_try_remove_checkpoint(jh);
spin_unlock(&journal->j_list_lock);
}
spin_unlock(&jh->b_state_lock);
jbd2_journal_put_journal_head(jh);
if (buffer_jbd(bh))
Expand Down

0 comments on commit 3c55097

Please sign in to comment.