Commit 8da8df43 authored by Yang Xiuwei's avatar Yang Xiuwei Committed by Jens Axboe
Browse files

block: use __bio_add_page in bio_copy_kern



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: default avatarChristoph Hellwig <hch@infradead.org>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: default avatarYang Xiuwei <yangxiuwei@kylinos.cn>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 539d1b47
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;