]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: use __bio_add_page in bio_copy_kern
authorYang Xiuwei <yangxiuwei@kylinos.cn>
Wed, 4 Mar 2026 04:51:19 +0000 (12:51 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 4 Mar 2026 13:59:26 +0000 (06:59 -0700)
Since the bio is allocated with the exact number of pages needed via
blk_rq_map_bio_alloc(), and the loop iterates exactly that many times,
bio_add_page() cannot fail due to insufficient space.  Switch to
__bio_add_page() and remove the dead error handling code.

Suggested-by: Christoph Hellwig <hch@infradead.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-map.c

index 4533094d94583b7dbc6726c2580268918e29c32e..c6fa2238d578227204fb77f4eadffb0eb3e82442 100644 (file)
@@ -398,8 +398,7 @@ static struct bio *bio_copy_kern(struct request *rq, void *data, unsigned int le
                if (op_is_write(op))
                        memcpy(page_address(page), p, bytes);
 
-               if (bio_add_page(bio, page, bytes, 0) < bytes)
-                       break;
+               __bio_add_page(bio, page, bytes, 0);
 
                len -= bytes;
                p += bytes;