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

Wenjie Qi <[email protected]> Mon, 3 Aug 2026 15:57:16 +0800
Newsgroups net.sourceforge.lists.linux-f2fs-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Compressed writeback is currently charged as F2FS_WB_CP_DATA through
WB_DATA_TYPE(..., fio->compressed_page).  That classification keeps
compressed cluster writeback under the checkpoint-guaranteed path for
POR safety after fsync/sync.

When such a compressed write bio fails,
f2fs_compress_write_end_io() only records -EIO in the inode mapping.
Ordinary F2FS_WB_CP_DATA writeback also stops checkpoint on writeback
failure, but compressed writeback does not.  Checkpoint can therefore
continue after a failed checkpoint-guaranteed compressed write and later
persist metadata that points to compressed data blocks whose writeback
failed.

Stop checkpoint on failed compressed write IO the same way as other
F2FS_WB_CP_DATA writeback.

Fixes: 4c8ff7095bef ("f2fs: support data compression")
Cc: [email protected]
Signed-off-by: Wenjie Qi <[email protected]>
---
v2:
- rewrite the changelog around the existing checkpoint-guaranteed
  compressed writeback semantics
- no code changes

 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


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel