Skip to content

Commit 3c55097

Browse files
zhangyi089tytso
authored andcommitted
jbd2: remove __journal_try_to_free_buffer()
__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>
1 parent 46f881b commit 3c55097

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

fs/jbd2/transaction.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,29 +2099,6 @@ void jbd2_journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
20992099
__brelse(bh);
21002100
}
21012101

2102-
/*
2103-
* Called from jbd2_journal_try_to_free_buffers().
2104-
*
2105-
* Called under jh->b_state_lock
2106-
*/
2107-
static void
2108-
__journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
2109-
{
2110-
struct journal_head *jh;
2111-
2112-
jh = bh2jh(bh);
2113-
2114-
if (jh->b_next_transaction != NULL || jh->b_transaction != NULL)
2115-
return;
2116-
2117-
spin_lock(&journal->j_list_lock);
2118-
/* Remove written-back checkpointed metadata buffer */
2119-
if (jh->b_cp_transaction != NULL)
2120-
jbd2_journal_try_remove_checkpoint(jh);
2121-
spin_unlock(&journal->j_list_lock);
2122-
return;
2123-
}
2124-
21252102
/**
21262103
* jbd2_journal_try_to_free_buffers() - try to free page buffers.
21272104
* @journal: journal for operation
@@ -2179,7 +2156,13 @@ bool jbd2_journal_try_to_free_buffers(journal_t *journal, struct folio *folio)
21792156
continue;
21802157

21812158
spin_lock(&jh->b_state_lock);
2182-
__journal_try_to_free_buffer(journal, bh);
2159+
if (!jh->b_transaction && !jh->b_next_transaction) {
2160+
spin_lock(&journal->j_list_lock);
2161+
/* Remove written-back checkpointed metadata buffer */
2162+
if (jh->b_cp_transaction != NULL)
2163+
jbd2_journal_try_remove_checkpoint(jh);
2164+
spin_unlock(&journal->j_list_lock);
2165+
}
21832166
spin_unlock(&jh->b_state_lock);
21842167
jbd2_journal_put_journal_head(jh);
21852168
if (buffer_jbd(bh))

0 commit comments

Comments
 (0)