]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: check split_sectors validity before bio_split call
authorHongling Zeng <zenghongling@kylinos.cn>
Wed, 29 Jul 2026 07:34:18 +0000 (15:34 +0800)
committerCarlos Maiolino <cem@kernel.org>
Mon, 10 Aug 2026 06:47:03 +0000 (08:47 +0200)
Change the split_sectors check from !split_sectors to split_sectors <= 0
to make the error handling explicit. While bio_split_rw_at() cannot return
a negative error code for the current GC I/O path (GC I/O doesn't use
REQ_ATOMIC/REQ_NOWAIT flags and has proper alignment), making the check
explicit improves code clarity and makes the intent clear.

This also makes the code more robust for future maintenance if different
I/O patterns are introduced.

Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_zone_gc.c

index f76a091308528b3bf267195093672fed926f741e..e00f4771e424db1b24d19c7afa5aa136b8e95fa4 100644 (file)
@@ -802,7 +802,7 @@ xfs_zone_gc_split_write(
 
        split_sectors = bio_split_rw_at(&chunk->bio, lim, &nsegs,
                        lim->max_zone_append_sectors << SECTOR_SHIFT);
-       if (!split_sectors)
+       if (split_sectors <= 0)
                return NULL;
 
        /* ensure the split chunk is still block size aligned */