[PATCH] f2fs: stop checkpoint on compressed write IO error

Wenjie Qi posted 1 patch 2 weeks ago
fs/f2fs/compress.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] f2fs: stop checkpoint on compressed write IO error
Posted by Wenjie Qi 2 weeks ago
Compressed data writes are accounted as F2FS_WB_CP_DATA because they
write compressed pages through fio->compressed_page.  Their end_io path
should therefore have the same checkpoint-stop behavior as ordinary
F2FS_WB_CP_DATA writes.

However, f2fs_compress_write_end_io() only records -EIO in the inode
mapping when the bio fails.  The filesystem can keep checkpointing after
that failure, so a later checkpoint may persist metadata that points to
compressed data blocks whose writeback failed.

Stop checkpointing with STOP_CP_REASON_WRITE_FAIL for failed compressed
F2FS_WB_CP_DATA writes, matching the ordinary data write end_io path.

Fixes: 4c8ff7095bef ("f2fs: support data compression")
Cc: stable@kernel.org
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
 fs/f2fs/compress.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index caf522d667d6..9b1501004456 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -1488,8 +1488,11 @@ void f2fs_compress_write_end_io(struct bio *bio, struct folio *folio)
 				f2fs_is_compressed_page(folio));
 	int i;
 
-	if (unlikely(bio->bi_status != BLK_STS_OK))
+	if (unlikely(bio->bi_status != BLK_STS_OK)) {
 		mapping_set_error(cic->inode->i_mapping, -EIO);
+		if (type == F2FS_WB_CP_DATA)
+			f2fs_stop_checkpoint(sbi, true, STOP_CP_REASON_WRITE_FAIL);
+	}
 
 	f2fs_compress_free_page(page);
 
-- 
2.43.0
Re: [PATCH] f2fs: stop checkpoint on compressed write IO error
Posted by Chao Yu 1 week, 6 days ago
On 5/25/26 14:14, Wenjie Qi wrote:
> Compressed data writes are accounted as F2FS_WB_CP_DATA because they
> write compressed pages through fio->compressed_page.  Their end_io path
> should therefore have the same checkpoint-stop behavior as ordinary
> F2FS_WB_CP_DATA writes.
> 
> However, f2fs_compress_write_end_io() only records -EIO in the inode
> mapping when the bio fails.  The filesystem can keep checkpointing after
> that failure, so a later checkpoint may persist metadata that points to
> compressed data blocks whose writeback failed.
> 
> Stop checkpointing with STOP_CP_REASON_WRITE_FAIL for failed compressed
> F2FS_WB_CP_DATA writes, matching the ordinary data write end_io path.
> 
> Fixes: 4c8ff7095bef ("f2fs: support data compression")
> Cc: stable@kernel.org
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,