Skip to content

Commit dbf2bab

Browse files
zhangyi089tytso
authored andcommitted
jbd2: simplify journal_clean_one_cp_list()
Now that __try_to_free_cp_buf() remove checkpointed buffer or transaction when the buffer is not 'busy', which is only called by journal_clean_one_cp_list(). This patch simplify this function by remove __try_to_free_cp_buf() and invoke __cp_buffer_busy() directly. Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 4ba3fcd commit dbf2bab

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

fs/jbd2/checkpoint.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,6 @@ static inline bool __cp_buffer_busy(struct journal_head *jh)
9191
return (jh->b_transaction || buffer_locked(bh) || buffer_dirty(bh));
9292
}
9393

94-
/*
95-
* Try to release a checkpointed buffer from its transaction.
96-
* Returns 1 if we released it and 2 if we also released the
97-
* whole transaction.
98-
*
99-
* Requires j_list_lock
100-
*/
101-
static int __try_to_free_cp_buf(struct journal_head *jh)
102-
{
103-
int ret = 0;
104-
struct buffer_head *bh = jh2bh(jh);
105-
106-
if (!jh->b_transaction && !buffer_locked(bh) && !buffer_dirty(bh)) {
107-
JBUFFER_TRACE(jh, "remove from checkpoint list");
108-
ret = __jbd2_journal_remove_checkpoint(jh) + 1;
109-
}
110-
return ret;
111-
}
112-
11394
/*
11495
* __jbd2_log_wait_for_space: wait until there is space in the journal.
11596
*
@@ -440,7 +421,6 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy)
440421
{
441422
struct journal_head *last_jh;
442423
struct journal_head *next_jh = jh;
443-
int ret;
444424

445425
if (!jh)
446426
return 0;
@@ -449,13 +429,11 @@ static int journal_clean_one_cp_list(struct journal_head *jh, bool destroy)
449429
do {
450430
jh = next_jh;
451431
next_jh = jh->b_cpnext;
452-
if (!destroy)
453-
ret = __try_to_free_cp_buf(jh);
454-
else
455-
ret = __jbd2_journal_remove_checkpoint(jh) + 1;
456-
if (!ret)
432+
433+
if (!destroy && __cp_buffer_busy(jh))
457434
return 0;
458-
if (ret == 2)
435+
436+
if (__jbd2_journal_remove_checkpoint(jh))
459437
return 1;
460438
/*
461439
* This function only frees up some memory

0 commit comments

Comments
 (0)