Skip to content

Commit 078760d

Browse files
Ye Bintytso
authored andcommitted
jbd2: use shrink_type type instead of bool type for __jbd2_journal_clean_checkpoint_list()
"enum shrink_type" can clearly express the meaning of the parameter of __jbd2_journal_clean_checkpoint_list(), and there is no need to use the bool type. Signed-off-by: Ye Bin <yebin10@huawei.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Zhang Yi <yi.zhang@huawei.com> Link: https://lore.kernel.org/r/20240407065355.1528580-2-yebin10@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent b4b4fda commit 078760d

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

fs/jbd2/checkpoint.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
337337

338338
/* Checkpoint list management */
339339

340-
enum shrink_type {SHRINK_DESTROY, SHRINK_BUSY_STOP, SHRINK_BUSY_SKIP};
341-
342340
/*
343341
* journal_shrink_one_cp_list
344342
*
@@ -472,21 +470,25 @@ unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal,
472470
* journal_clean_checkpoint_list
473471
*
474472
* Find all the written-back checkpoint buffers in the journal and release them.
475-
* If 'destroy' is set, release all buffers unconditionally.
473+
* If 'type' is SHRINK_DESTROY, release all buffers unconditionally. If 'type'
474+
* is SHRINK_BUSY_STOP, will stop release buffers if encounters a busy buffer.
475+
* To avoid wasting CPU cycles scanning the buffer list in some cases, don't
476+
* pass SHRINK_BUSY_SKIP 'type' for this function.
476477
*
477478
* Called with j_list_lock held.
478479
*/
479-
void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy)
480+
void __jbd2_journal_clean_checkpoint_list(journal_t *journal,
481+
enum shrink_type type)
480482
{
481483
transaction_t *transaction, *last_transaction, *next_transaction;
482-
enum shrink_type type;
483484
bool released;
484485

486+
WARN_ON_ONCE(type == SHRINK_BUSY_SKIP);
487+
485488
transaction = journal->j_checkpoint_transactions;
486489
if (!transaction)
487490
return;
488491

489-
type = destroy ? SHRINK_DESTROY : SHRINK_BUSY_STOP;
490492
last_transaction = transaction->t_cpprev;
491493
next_transaction = transaction;
492494
do {
@@ -527,7 +529,7 @@ void jbd2_journal_destroy_checkpoint(journal_t *journal)
527529
spin_unlock(&journal->j_list_lock);
528530
break;
529531
}
530-
__jbd2_journal_clean_checkpoint_list(journal, true);
532+
__jbd2_journal_clean_checkpoint_list(journal, SHRINK_DESTROY);
531533
spin_unlock(&journal->j_list_lock);
532534
cond_resched();
533535
}

fs/jbd2/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ void jbd2_journal_commit_transaction(journal_t *journal)
501501
* frees some memory
502502
*/
503503
spin_lock(&journal->j_list_lock);
504-
__jbd2_journal_clean_checkpoint_list(journal, false);
504+
__jbd2_journal_clean_checkpoint_list(journal, SHRINK_BUSY_STOP);
505505
spin_unlock(&journal->j_list_lock);
506506

507507
jbd2_debug(3, "JBD2: commit phase 1\n");

include/linux/jbd2.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,9 @@ void jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block);
14341434
extern void jbd2_journal_commit_transaction(journal_t *);
14351435

14361436
/* Checkpoint list management */
1437-
void __jbd2_journal_clean_checkpoint_list(journal_t *journal, bool destroy);
1437+
enum shrink_type {SHRINK_DESTROY, SHRINK_BUSY_STOP, SHRINK_BUSY_SKIP};
1438+
1439+
void __jbd2_journal_clean_checkpoint_list(journal_t *journal, enum shrink_type type);
14381440
unsigned long jbd2_journal_shrink_checkpoint_list(journal_t *journal, unsigned long *nr_to_scan);
14391441
int __jbd2_journal_remove_checkpoint(struct journal_head *);
14401442
int jbd2_journal_try_remove_checkpoint(struct journal_head *jh);

0 commit comments

Comments
 (0)