mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ext4: report unwritten extent conversion failures as writeback errors
@ 2026-10-15 10:29 guolingxing
  2026-10-19  9:58 ` Jan Kara
  2026-11-01 10:21 ` [PATCH v2] " guolingxing
  0 siblings, 2 replies; 4+ messages in thread
From: guolingxing @ 2026-10-15 10:29 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, Baokun Li, Jan Kara,
	Ojaswin Mujoo, Ritesh Harjani, Zhang Yi
  Cc: linux-ext4, linux-kernel, stable, guolingxing

When a data writeback bio completes successfully but the subsequent
unwritten extent conversion fails, ext4_end_io_end() does not record
the error in the inode's mapping writeback error state.

Bio failures are already recorded by ext4_end_bio(), but conversion
failures are not. When the conversion is processed asynchronously,
its return value is not propagated to userspace, so fsync() may
return success despite the failed conversion.

Record conversion errors with mapping_set_error() before
ext4_release_io_end() ends folio writeback and wakes waiters. This
allows fsync() to observe the failure.

Fixes: b82e384c7bb9 ("ext4: optimize locking for end_io extent conversion")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/ext4/page-io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 0236b6b9785a..2afa4c096156 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -189,6 +189,8 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
 			jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
 	} else {
 		ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
+		if (ret < 0)
+			mapping_set_error(inode->i_mapping, ret);
 	}
 	if (ret < 0 && !ext4_emergency_state(sb) &&
 	    io_end->flag & EXT4_IO_END_UNWRITTEN) {
-- 
2.34.1


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

* Re: [PATCH] ext4: report unwritten extent conversion failures as writeback errors
  2026-10-15 10:29 [PATCH] ext4: report unwritten extent conversion failures as writeback errors guolingxing
@ 2026-10-19  9:58 ` Jan Kara
  2026-11-01 10:21 ` [PATCH v2] " guolingxing
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2026-10-19  9:58 UTC (permalink / raw)
  To: guolingxing
  Cc: Theodore Ts'o, Andreas Dilger, Baokun Li, Jan Kara,
	Ojaswin Mujoo, Ritesh Harjani, Zhang Yi, linux-ext4,
	linux-kernel, stable

On Thu 15-10-26 10:29:43, guolingxing wrote:
> When a data writeback bio completes successfully but the subsequent
> unwritten extent conversion fails, ext4_end_io_end() does not record
> the error in the inode's mapping writeback error state.
> 
> Bio failures are already recorded by ext4_end_bio(), but conversion
> failures are not. When the conversion is processed asynchronously,
> its return value is not propagated to userspace, so fsync() may
> return success despite the failed conversion.
> 
> Record conversion errors with mapping_set_error() before
> ext4_release_io_end() ends folio writeback and wakes waiters. This
> allows fsync() to observe the failure.
> 
> Fixes: b82e384c7bb9 ("ext4: optimize locking for end_io extent conversion")
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>

I don't think the Fixes tag is correct. Even before b82e384c7bb9 we seem to
have been dropping the error on the floor. But otherwise feel free to add:

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

								Honza

> ---
>  fs/ext4/page-io.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
> index 0236b6b9785a..2afa4c096156 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -189,6 +189,8 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
>  			jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
>  	} else {
>  		ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
> +		if (ret < 0)
> +			mapping_set_error(inode->i_mapping, ret);
>  	}
>  	if (ret < 0 && !ext4_emergency_state(sb) &&
>  	    io_end->flag & EXT4_IO_END_UNWRITTEN) {
> -- 
> 2.34.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* [PATCH v2] ext4: report unwritten extent conversion failures as writeback errors
  2026-10-15 10:29 [PATCH] ext4: report unwritten extent conversion failures as writeback errors guolingxing
  2026-10-19  9:58 ` Jan Kara
@ 2026-11-01 10:21 ` guolingxing
  2026-11-02 11:50   ` Zhang Yi
  1 sibling, 1 reply; 4+ messages in thread
From: guolingxing @ 2026-11-01 10:21 UTC (permalink / raw)
  To: Jan Kara, Theodore Ts'o
  Cc: Andreas Dilger, Baokun Li, Ojaswin Mujoo, Ritesh Harjani,
	Zhang Yi, linux-ext4, linux-kernel, guolingxing, stable

When a data writeback bio completes successfully but the subsequent
unwritten extent conversion fails, ext4_end_io_end() does not record
the error in the inode's mapping writeback error state.

Bio failures are already recorded by ext4_end_bio(), but conversion
failures are not. When the conversion is processed asynchronously,
its return value is not propagated to userspace, so fsync() may
return success despite the failed conversion.

Record conversion errors with mapping_set_error() before
ext4_release_io_end() ends folio writeback and wakes waiters. This
allows fsync() to observe the failure.

Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
Reviewed-by: Jan Kara <jack@suse.cz>
---
Changes since v1:
- Drop the incorrect Fixes tag. The conversion error was already lost
  before commit b82e384c7bb9, as pointed out by Jan Kara.
- Collect Reviewed-by from Jan Kara.

 fs/ext4/page-io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
index 734d856a6d478..2701452fa65ca 100644
--- a/fs/ext4/page-io.c
+++ b/fs/ext4/page-io.c
@@ -192,6 +192,8 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
 			jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
 	} else {
 		ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
+		if (ret < 0)
+			mapping_set_error(inode->i_mapping, ret);
 	}
 	if (ret < 0 && !ext4_emergency_state(sb) &&
 	    io_end->flag & EXT4_IO_END_UNWRITTEN) {
-- 
2.34.1


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

* Re: [PATCH v2] ext4: report unwritten extent conversion failures as writeback errors
  2026-11-01 10:21 ` [PATCH v2] " guolingxing
@ 2026-11-02 11:50   ` Zhang Yi
  0 siblings, 0 replies; 4+ messages in thread
From: Zhang Yi @ 2026-11-02 11:50 UTC (permalink / raw)
  To: guolingxing
  Cc: Theodore Ts'o, Jan Kara, Andreas Dilger, Baokun Li,
	Ojaswin Mujoo, Ritesh Harjani, linux-ext4, linux-kernel, stable

On 11/1/2026 6:21 PM, guolingxing wrote:
> When a data writeback bio completes successfully but the subsequent
> unwritten extent conversion fails, ext4_end_io_end() does not record
> the error in the inode's mapping writeback error state.
> 
> Bio failures are already recorded by ext4_end_bio(), but conversion
> failures are not. When the conversion is processed asynchronously,
> its return value is not propagated to userspace, so fsync() may
> return success despite the failed conversion.
> 
> Record conversion errors with mapping_set_error() before
> ext4_release_io_end() ends folio writeback and wakes waiters. This
> allows fsync() to observe the failure.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
> Reviewed-by: Jan Kara <jack@suse.cz>

Thank you for the fix. This looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
> Changes since v1:
> - Drop the incorrect Fixes tag. The conversion error was already lost
>   before commit b82e384c7bb9, as pointed out by Jan Kara.
> - Collect Reviewed-by from Jan Kara.
> 
>  fs/ext4/page-io.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c
> index 734d856a6d478..2701452fa65ca 100644
> --- a/fs/ext4/page-io.c
> +++ b/fs/ext4/page-io.c
> @@ -192,6 +192,8 @@ static int ext4_end_io_end(ext4_io_end_t *io_end)
>  			jbd2_journal_abort(EXT4_SB(sb)->s_journal, ret);
>  	} else {
>  		ret = ext4_convert_unwritten_io_end_vec(handle, io_end);
> +		if (ret < 0)
> +			mapping_set_error(inode->i_mapping, ret);
>  	}
>  	if (ret < 0 && !ext4_emergency_state(sb) &&
>  	    io_end->flag & EXT4_IO_END_UNWRITTEN) {


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

end of thread, other threads:[~2026-11-02 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 10:29 [PATCH] ext4: report unwritten extent conversion failures as writeback errors guolingxing
2026-10-19  9:58 ` Jan Kara
2026-11-01 10:21 ` [PATCH v2] " guolingxing
2026-11-02 11:50   ` Zhang Yi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®