Re: [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
From: Jan Kara
Date: Mon Oct 12 2026 - 12:11:09 EST
On Mon 12-10-26 11:47:13, guolingxing wrote:
> When asynchronous commits are enabled, jbd2_commit_transaction()
> calls blkdev_issue_flush() on the journal device to make the commit
> record permanent. However the return value is ignored so if the
> flush fails, the transaction is considered committed although the
> commit record may have never reached the disk. Abort the journal
> when the flush fails, as we already do when waiting for the commit
> record fails.
>
> Fixes: f73bee49855f ("jbd2: Modify ASYNC_COMMIT code to not rely on queue draining on barrier")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: guolingxing <guolingxing@xxxxxxxxxx>
...
> diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> index 99477e9c78c7..32ca502603be 100644
> --- a/fs/jbd2/commit.c
> +++ b/fs/jbd2/commit.c
> @@ -912,7 +912,10 @@ void jbd2_journal_commit_transaction(journal_t *journal)
> stats.run.rs_blocks_logged++;
> if (jbd2_has_feature_async_commit(journal) &&
> journal->j_flags & JBD2_BARRIER) {
> - blkdev_issue_flush(journal->j_dev);
> + int err = blkdev_issue_flush(journal->j_dev);
Again this shadows existing local variable, which is a bad practice. Just
call this flush_err or something.
> +
> + if (err)
> + jbd2_journal_abort(journal, err);
And here we can do instead:
if (!err)
err = flush_err;
since below we take care of aborting the journal if err is set.
Honza
> }
>
> if (err)
> --
> 2.34.1
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR