fs/jbd2/journal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
From: Baolin Liu <liubaolin@kylinos.cn>
Replace BUG_ON with J_ASSERT to write the assertion in a positive form.
No functional change.
Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
fs/jbd2/journal.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index d480b94117cd..c858ade1f7f3 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1058,7 +1058,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
unsigned long freed;
int ret;
- BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
+ J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
/*
* We cannot afford for write to remain in drive's caches since as
@@ -1863,7 +1863,7 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
return -EIO;
}
- BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
+ J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
jbd2_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
tail_block, tail_tid);
@@ -1897,7 +1897,7 @@ static void jbd2_mark_journal_empty(journal_t *journal, blk_opf_t write_flags)
journal_superblock_t *sb = journal->j_superblock;
bool had_fast_commit = false;
- BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
+ J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
lock_buffer(journal->j_sb_buffer);
if (sb->s_start == 0) { /* Is it already empty? */
unlock_buffer(journal->j_sb_buffer);
--
2.39.2
Hello!
On Wed 12-11-25 18:29:14, Baolin Liu wrote:
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> Replace BUG_ON with J_ASSERT to write the assertion in a positive form.
>
> No functional change.
>
> Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
Thanks for the patch I don't think this is really useful. It is IMO just
a pointless churn... If something, we could get rid of J_ASSERT,
J_ASSERT_JH and J_ASSERT_BH macros which are mostly pointless obfuscation
but even that will cause newer patches to not apply to later stable kernels
and thus I don't think it's really worth it.
Honza
> ---
> fs/jbd2/journal.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
> index d480b94117cd..c858ade1f7f3 100644
> --- a/fs/jbd2/journal.c
> +++ b/fs/jbd2/journal.c
> @@ -1058,7 +1058,7 @@ int __jbd2_update_log_tail(journal_t *journal, tid_t tid, unsigned long block)
> unsigned long freed;
> int ret;
>
> - BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
> + J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
>
> /*
> * We cannot afford for write to remain in drive's caches since as
> @@ -1863,7 +1863,7 @@ int jbd2_journal_update_sb_log_tail(journal_t *journal, tid_t tail_tid,
> return -EIO;
> }
>
> - BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
> + J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
> jbd2_debug(1, "JBD2: updating superblock (start %lu, seq %u)\n",
> tail_block, tail_tid);
>
> @@ -1897,7 +1897,7 @@ static void jbd2_mark_journal_empty(journal_t *journal, blk_opf_t write_flags)
> journal_superblock_t *sb = journal->j_superblock;
> bool had_fast_commit = false;
>
> - BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
> + J_ASSERT(mutex_is_locked(&journal->j_checkpoint_mutex));
> lock_buffer(journal->j_sb_buffer);
> if (sb->s_start == 0) { /* Is it already empty? */
> unlock_buffer(journal->j_sb_buffer);
> --
> 2.39.2
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
> Sorry, my intention was to unify all the BUG_ON statements in the jbd2 code to J_ASSERT in order to improve readability. > You made a good point — this change could indeed cause conflicts with future patches. > I’ll withdraw this patch and not submit it. > Thank you for your review. 在 2025/11/13 3:29, Jan Kara 写道: > J_ASSERT, > J_ASSERT_JH and J_ASSERT_BH
© 2016 - 2026 Red Hat, Inc.