All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
@ 2026-10-12 11:47 guolingxing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: guolingxing @ 2026-10-12 11:47 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
system device to make sure all checkpointed data are on permanent
storage before it updates the log tail in the superblock.  However
the return value of blkdev_issue_flush() is ignored so if the flush
fails, we still advance the log tail.  After a crash the journal
recovery will consider the checkpointed transactions as committed
and skip the replay while their data may have never reached the
disk, which may lead to a filesystem corruption.

Abort the journal when the flush fails, similar to how we abort
when detecting writeback errors of the file system device.

Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/checkpoint.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 513273712010..9bbce4c8cadb 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -346,8 +346,14 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
 	 * need this to guarantee correctness.  Fortunately
 	 * jbd2_cleanup_journal_tail() doesn't get called all that often.
 	 */
-	if (journal->j_flags & JBD2_BARRIER)
-		blkdev_issue_flush(journal->j_fs_dev);
+	if (journal->j_flags & JBD2_BARRIER) {
+		int err = blkdev_issue_flush(journal->j_fs_dev);
+
+		if (err) {
+			jbd2_journal_abort(journal, err);
+			return err;
+		}
+	}
 
 	return __jbd2_update_log_tail(journal, first_tid, blocknr);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing
  2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
@ 2026-10-12 11:47 ` guolingxing
  2026-10-12 12:10   ` sashiko-bot
  2026-10-12 15:31   ` Jan Kara
  2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: guolingxing @ 2026-10-12 11:47 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

For journals on a separate device, jbd2_commit_transaction() must
flush the file system device before submitting the commit record,
otherwise the transaction may get committed while the ordered data
are still in the device cache.  However the return value of
blkdev_issue_flush() is ignored so if the flush fails, the commit
record is still submitted and fsync() reports success although the
ordered data may have never reached the disk.  After a crash the
journal recovery will consider such transactions committed and data
written by fsync() may be lost.

Abort the journal when the flush fails.  The commit record is then
not submitted anymore since journal_submit_commit_record() checks
for an aborted journal.

Fixes: cc3e1bea5d87 ("ext4, jbd2: Add barriers for file systems with exernal journals")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/commit.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 3029cb6f6d64..99477e9c78c7 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -800,8 +800,12 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	 */
 	if ((commit_transaction->t_need_data_flush || update_tail) &&
 	    (journal->j_fs_dev != journal->j_dev) &&
-	    (journal->j_flags & JBD2_BARRIER))
-		blkdev_issue_flush(journal->j_fs_dev);
+	    (journal->j_flags & JBD2_BARRIER)) {
+		int err = blkdev_issue_flush(journal->j_fs_dev);
+
+		if (err)
+			jbd2_journal_abort(journal, err);
+	}
 
 	/* Done it all: now write the commit record asynchronously. */
 	if (jbd2_has_feature_async_commit(journal)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
@ 2026-10-12 11:47 ` guolingxing
  2026-10-12 12:16   ` sashiko-bot
  2026-10-12 15:33   ` Jan Kara
  2026-10-12 12:03 ` [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing sashiko-bot
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: guolingxing @ 2026-10-12 11:47 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

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@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/commit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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);
+
+		if (err)
+			jbd2_journal_abort(journal, err);
 	}
 
 	if (err)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
  2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
  2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
@ 2026-10-12 12:03 ` sashiko-bot
  2026-10-12 15:29 ` Jan Kara
  2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
  4 siblings, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-12 12:03 UTC (permalink / raw)
  To: guolingxing; +Cc: tytso, linux-ext4

> jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
> system device to make sure all checkpointed data are on permanent
> storage before it updates the log tail in the superblock.  However
> the return value of blkdev_issue_flush() is ignored so if the flush
> fails, we still advance the log tail.  After a crash the journal
> recovery will consider the checkpointed transactions as committed
> and skip the replay while their data may have never reached the
> disk, which may lead to a filesystem corruption.
> 
> Abort the journal when the flush fails, similar to how we abort
> when detecting writeback errors of the file system device.
> 
> Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012114713.4049391-1-guolingxing@tju.edu.cn?part=1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
@ 2026-10-12 12:10   ` sashiko-bot
  2026-10-12 15:31   ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-12 12:10 UTC (permalink / raw)
  To: guolingxing; +Cc: tytso, linux-ext4

> For journals on a separate device, jbd2_commit_transaction() must
> flush the file system device before submitting the commit record,
> otherwise the transaction may get committed while the ordered data
> are still in the device cache.  However the return value of
> blkdev_issue_flush() is ignored so if the flush fails, the commit
> record is still submitted and fsync() reports success although the
> ordered data may have never reached the disk.  After a crash the
> journal recovery will consider such transactions committed and data
> written by fsync() may be lost.
> 
> Abort the journal when the flush fails.  The commit record is then
> not submitted anymore since journal_submit_commit_record() checks
> for an aborted journal.
> 
> Fixes: cc3e1bea5d87 ("ext4, jbd2: Add barriers for file systems with exernal journals")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012114713.4049391-1-guolingxing@tju.edu.cn?part=2


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
@ 2026-10-12 12:16   ` sashiko-bot
  2026-10-12 15:33   ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-12 12:16 UTC (permalink / raw)
  To: guolingxing; +Cc: tytso, linux-ext4

> 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@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012114713.4049391-1-guolingxing@tju.edu.cn?part=3


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
  2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
                   ` (2 preceding siblings ...)
  2026-10-12 12:03 ` [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing sashiko-bot
@ 2026-10-12 15:29 ` Jan Kara
  2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
  4 siblings, 0 replies; 17+ messages in thread
From: Jan Kara @ 2026-10-12 15:29 UTC (permalink / raw)
  To: guolingxing; +Cc: Theodore Ts'o, Jan Kara, linux-ext4, linux-kernel, stable

On Mon 12-10-26 11:47:11, guolingxing wrote:
> jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
> system device to make sure all checkpointed data are on permanent
> storage before it updates the log tail in the superblock.  However
> the return value of blkdev_issue_flush() is ignored so if the flush
> fails, we still advance the log tail.  After a crash the journal
> recovery will consider the checkpointed transactions as committed
> and skip the replay while their data may have never reached the
> disk, which may lead to a filesystem corruption.
> 
> Abort the journal when the flush fails, similar to how we abort
> when detecting writeback errors of the file system device.
> 
> Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jbd2/checkpoint.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
> index 513273712010..9bbce4c8cadb 100644
> --- a/fs/jbd2/checkpoint.c
> +++ b/fs/jbd2/checkpoint.c
> @@ -346,8 +346,14 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
>  	 * need this to guarantee correctness.  Fortunately
>  	 * jbd2_cleanup_journal_tail() doesn't get called all that often.
>  	 */
> -	if (journal->j_flags & JBD2_BARRIER)
> -		blkdev_issue_flush(journal->j_fs_dev);
> +	if (journal->j_flags & JBD2_BARRIER) {
> +		int err = blkdev_issue_flush(journal->j_fs_dev);
> +
> +		if (err) {
> +			jbd2_journal_abort(journal, err);
> +			return err;
> +		}
> +	}
>  
>  	return __jbd2_update_log_tail(journal, first_tid, blocknr);
>  }
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing
  2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
  2026-10-12 12:10   ` sashiko-bot
@ 2026-10-12 15:31   ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Kara @ 2026-10-12 15:31 UTC (permalink / raw)
  To: guolingxing; +Cc: Theodore Ts'o, Jan Kara, linux-ext4, linux-kernel, stable

On Mon 12-10-26 11:47:12, guolingxing wrote:
> For journals on a separate device, jbd2_commit_transaction() must
> flush the file system device before submitting the commit record,
> otherwise the transaction may get committed while the ordered data
> are still in the device cache.  However the return value of
> blkdev_issue_flush() is ignored so if the flush fails, the commit
> record is still submitted and fsync() reports success although the
> ordered data may have never reached the disk.  After a crash the
> journal recovery will consider such transactions committed and data
> written by fsync() may be lost.
> 
> Abort the journal when the flush fails.  The commit record is then
> not submitted anymore since journal_submit_commit_record() checks
> for an aborted journal.
> 
> Fixes: cc3e1bea5d87 ("ext4, jbd2: Add barriers for file systems with exernal journals")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
...
> diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> index 3029cb6f6d64..99477e9c78c7 100644
> --- a/fs/jbd2/commit.c
> +++ b/fs/jbd2/commit.c
> @@ -800,8 +800,12 @@ void jbd2_journal_commit_transaction(journal_t *journal)
>  	 */
>  	if ((commit_transaction->t_need_data_flush || update_tail) &&
>  	    (journal->j_fs_dev != journal->j_dev) &&
> -	    (journal->j_flags & JBD2_BARRIER))
> -		blkdev_issue_flush(journal->j_fs_dev);
> +	    (journal->j_flags & JBD2_BARRIER)) {
> +		int err = blkdev_issue_flush(journal->j_fs_dev);

This shadows an 'err' definition of already existing variable. Just use
that variable instead. Otherwise the patch looks good.

								Honza

> +
> +		if (err)
> +			jbd2_journal_abort(journal, err);
> +	}
>  
>  	/* Done it all: now write the commit record asynchronously. */
>  	if (jbd2_has_feature_async_commit(journal)) {
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
  2026-10-12 12:16   ` sashiko-bot
@ 2026-10-12 15:33   ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Kara @ 2026-10-12 15:33 UTC (permalink / raw)
  To: guolingxing; +Cc: Theodore Ts'o, Jan Kara, linux-ext4, linux-kernel, stable

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@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
...
> 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@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush()
  2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
                   ` (3 preceding siblings ...)
  2026-10-12 15:29 ` Jan Kara
@ 2026-10-13  1:40 ` guolingxing
  2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
                     ` (2 more replies)
  4 siblings, 3 replies; 17+ messages in thread
From: guolingxing @ 2026-10-13  1:40 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing

Check the return value of blkdev_issue_flush() in three JBD2 paths
where it was ignored, and abort the journal on failure. This prevents
journal tail updates or successful transaction completion from
proceeding without the required cache flush succeeding.

Changes since v1:
- 1/3: collected Reviewed-by from Jan Kara.
- 2/3: reuse the existing err variable instead of declaring a new
  one that shadows it, per review from Jan Kara.
- 3/3: use flush_err to avoid shadowing err, preserve any earlier
  commit-record error, and reuse the existing abort handling,
  as suggested by Jan Kara.

guolingxing (3):
  jbd2: check return value of blkdev_issue_flush() when checkpointing
  jbd2: check return value of blkdev_issue_flush() when committing
  jbd2: check return value of blkdev_issue_flush() for async commits

 fs/jbd2/checkpoint.c | 10 ++++++++--
 fs/jbd2/commit.c     | 13 ++++++++++---
 2 files changed, 18 insertions(+), 5 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
  2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
@ 2026-10-13  1:40   ` guolingxing
  2026-10-13  1:50     ` sashiko-bot
  2026-10-13  1:40   ` [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
  2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
  2 siblings, 1 reply; 17+ messages in thread
From: guolingxing @ 2026-10-13  1:40 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara
  Cc: linux-ext4, linux-kernel, guolingxing, stable, Jan Kara

jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
system device to make sure all checkpointed data are on permanent
storage before it updates the log tail in the superblock.  However
the return value of blkdev_issue_flush() is ignored so if the flush
fails, we still advance the log tail.  After a crash the journal
recovery will consider the checkpointed transactions as committed
and skip the replay while their data may have never reached the
disk, which may lead to a filesystem corruption.

Abort the journal when the flush fails, similar to how we abort
when detecting writeback errors of the file system device.

Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
Cc: stable@vger.kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/checkpoint.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
index 513273712010..9bbce4c8cadb 100644
--- a/fs/jbd2/checkpoint.c
+++ b/fs/jbd2/checkpoint.c
@@ -346,8 +346,14 @@ int jbd2_cleanup_journal_tail(journal_t *journal)
 	 * need this to guarantee correctness.  Fortunately
 	 * jbd2_cleanup_journal_tail() doesn't get called all that often.
 	 */
-	if (journal->j_flags & JBD2_BARRIER)
-		blkdev_issue_flush(journal->j_fs_dev);
+	if (journal->j_flags & JBD2_BARRIER) {
+		int err = blkdev_issue_flush(journal->j_fs_dev);
+
+		if (err) {
+			jbd2_journal_abort(journal, err);
+			return err;
+		}
+	}
 
 	return __jbd2_update_log_tail(journal, first_tid, blocknr);
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing
  2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
  2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
@ 2026-10-13  1:40   ` guolingxing
  2026-10-13  1:48     ` sashiko-bot
  2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
  2 siblings, 1 reply; 17+ messages in thread
From: guolingxing @ 2026-10-13  1:40 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

For journals on a separate device, jbd2_commit_transaction() must
flush the file system device before submitting the commit record,
otherwise the transaction may get committed while the ordered data
are still in the device cache.  However the return value of
blkdev_issue_flush() is ignored so if the flush fails, the commit
record is still submitted and fsync() reports success although the
ordered data may have never reached the disk.  After a crash the
journal recovery will consider such transactions committed and data
written by fsync() may be lost.

Abort the journal when the flush fails.  The commit record is then
not submitted anymore since journal_submit_commit_record() checks
for an aborted journal.

Fixes: cc3e1bea5d87 ("ext4, jbd2: Add barriers for file systems with exernal journals")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/commit.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 3029cb6f6d64..8c561e42b60a 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -800,8 +800,12 @@ void jbd2_journal_commit_transaction(journal_t *journal)
 	 */
 	if ((commit_transaction->t_need_data_flush || update_tail) &&
 	    (journal->j_fs_dev != journal->j_dev) &&
-	    (journal->j_flags & JBD2_BARRIER))
-		blkdev_issue_flush(journal->j_fs_dev);
+	    (journal->j_flags & JBD2_BARRIER)) {
+		err = blkdev_issue_flush(journal->j_fs_dev);
+
+		if (err)
+			jbd2_journal_abort(journal, err);
+	}
 
 	/* Done it all: now write the commit record asynchronously. */
 	if (jbd2_has_feature_async_commit(journal)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
  2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
  2026-10-13  1:40   ` [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
@ 2026-10-13  1:40   ` guolingxing
  2026-10-13  1:49     ` sashiko-bot
  2026-10-13 12:20     ` Jan Kara
  2 siblings, 2 replies; 17+ messages in thread
From: guolingxing @ 2026-10-13  1:40 UTC (permalink / raw)
  To: Theodore Ts'o, Jan Kara; +Cc: linux-ext4, linux-kernel, guolingxing, stable

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@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/jbd2/commit.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 8c561e42b60a..4e8ebce34077 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 flush_err = blkdev_issue_flush(journal->j_dev);
+
+		if (!err)
+			err = flush_err;
 	}
 
 	if (err)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing
  2026-10-13  1:40   ` [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
@ 2026-10-13  1:48     ` sashiko-bot
  0 siblings, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-13  1:48 UTC (permalink / raw)
  To: guolingxing; +Cc: linux-ext4, tytso

> For journals on a separate device, jbd2_commit_transaction() must
> flush the file system device before submitting the commit record,
> otherwise the transaction may get committed while the ordered data
> are still in the device cache.  However the return value of
> blkdev_issue_flush() is ignored so if the flush fails, the commit
> record is still submitted and fsync() reports success although the
> ordered data may have never reached the disk.  After a crash the
> journal recovery will consider such transactions committed and data
> written by fsync() may be lost.
> 
> Abort the journal when the flush fails.  The commit record is then
> not submitted anymore since journal_submit_commit_record() checks
> for an aborted journal.
> 
> Fixes: cc3e1bea5d87 ("ext4, jbd2: Add barriers for file systems with exernal journals")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013014028.1152277-1-guolingxing@tju.edu.cn?part=2


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
@ 2026-10-13  1:49     ` sashiko-bot
  2026-10-13 12:20     ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-13  1:49 UTC (permalink / raw)
  To: guolingxing; +Cc: linux-ext4, tytso

> 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@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013014028.1152277-1-guolingxing@tju.edu.cn?part=3


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing
  2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
@ 2026-10-13  1:50     ` sashiko-bot
  0 siblings, 0 replies; 17+ messages in thread
From: sashiko-bot @ 2026-10-13  1:50 UTC (permalink / raw)
  To: guolingxing; +Cc: linux-ext4, tytso

> jbd2_cleanup_journal_tail() calls blkdev_issue_flush() on the file
> system device to make sure all checkpointed data are on permanent
> storage before it updates the log tail in the superblock.  However
> the return value of blkdev_issue_flush() is ignored so if the flush
> fails, we still advance the log tail.  After a crash the journal
> recovery will consider the checkpointed transactions as committed
> and skip the replay while their data may have never reached the
> disk, which may lead to a filesystem corruption.
> 
> Abort the journal when the flush fails, similar to how we abort
> when detecting writeback errors of the file system device.
> 
> Fixes: 79feb521a447 ("jbd2: issue cache flush after checkpointing even with internal journal")
> Cc: stable@vger.kernel.org
> Reviewed-by: Jan Kara <jack@suse.cz>
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013014028.1152277-1-guolingxing@tju.edu.cn?part=1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits
  2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
  2026-10-13  1:49     ` sashiko-bot
@ 2026-10-13 12:20     ` Jan Kara
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Kara @ 2026-10-13 12:20 UTC (permalink / raw)
  To: guolingxing; +Cc: Theodore Ts'o, Jan Kara, linux-ext4, linux-kernel, stable

On Tue 13-10-26 01:40:28, 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@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/jbd2/commit.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
> index 8c561e42b60a..4e8ebce34077 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 flush_err = blkdev_issue_flush(journal->j_dev);
> +
> +		if (!err)
> +			err = flush_err;
>  	}
>  
>  	if (err)
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2026-10-13 12:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 11:47 [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
2026-10-12 11:47 ` [PATCH 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
2026-10-12 12:10   ` sashiko-bot
2026-10-12 15:31   ` Jan Kara
2026-10-12 11:47 ` [PATCH 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
2026-10-12 12:16   ` sashiko-bot
2026-10-12 15:33   ` Jan Kara
2026-10-12 12:03 ` [PATCH 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing sashiko-bot
2026-10-12 15:29 ` Jan Kara
2026-10-13  1:40 ` [PATCH v2 0/3] jbd2: check return value of blkdev_issue_flush() guolingxing
2026-10-13  1:40   ` [PATCH v2 1/3] jbd2: check return value of blkdev_issue_flush() when checkpointing guolingxing
2026-10-13  1:50     ` sashiko-bot
2026-10-13  1:40   ` [PATCH v2 2/3] jbd2: check return value of blkdev_issue_flush() when committing guolingxing
2026-10-13  1:48     ` sashiko-bot
2026-10-13  1:40   ` [PATCH v2 3/3] jbd2: check return value of blkdev_issue_flush() for async commits guolingxing
2026-10-13  1:49     ` sashiko-bot
2026-10-13 12:20     ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.