diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/io.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/block/io.c b/block/io.c index 3e91074c9f..ef75a5abb4 100644 --- a/block/io.c +++ b/block/io.c @@ -884,17 +884,12 @@ static bool coroutine_fn bdrv_wait_serialising_requests(BdrvTrackedRequest *self return waited; } -static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, - size_t size) +static int bdrv_check_byte_request(int64_t offset, size_t size) { if (size > BDRV_REQUEST_MAX_BYTES) { return -EIO; } - if (!bdrv_is_inserted(bs)) { - return -ENOMEDIUM; - } - if (offset < 0) { return -EIO; } @@ -1642,7 +1637,11 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child, trace_bdrv_co_preadv(bs, offset, bytes, flags); - ret = bdrv_check_byte_request(bs, offset, bytes); + if (!bdrv_is_inserted(bs)) { + return -ENOMEDIUM; + } + + ret = bdrv_check_byte_request(offset, bytes); if (ret < 0) { return ret; } @@ -2054,11 +2053,11 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child, trace_bdrv_co_pwritev(child->bs, offset, bytes, flags); - if (!bs->drv) { + if (!bdrv_is_inserted(bs)) { return -ENOMEDIUM; } - ret = bdrv_check_byte_request(bs, offset, bytes); + ret = bdrv_check_byte_request(offset, bytes); if (ret < 0) { return ret; } @@ -3045,10 +3044,10 @@ static int coroutine_fn bdrv_co_copy_range_internal( assert(!(read_flags & BDRV_REQ_NO_FALLBACK)); assert(!(write_flags & BDRV_REQ_NO_FALLBACK)); - if (!dst || !dst->bs) { + if (!dst || !dst->bs || !bdrv_is_inserted(dst->bs)) { return -ENOMEDIUM; } - ret = bdrv_check_byte_request(dst->bs, dst_offset, bytes); + ret = bdrv_check_byte_request(dst_offset, bytes); if (ret) { return ret; } @@ -3056,10 +3055,10 @@ static int coroutine_fn bdrv_co_copy_range_internal( return bdrv_co_pwrite_zeroes(dst, dst_offset, bytes, write_flags); } - if (!src || !src->bs) { + if (!src || !src->bs || !bdrv_is_inserted(src->bs)) { return -ENOMEDIUM; } - ret = bdrv_check_byte_request(src->bs, src_offset, bytes); + ret = bdrv_check_byte_request(src_offset, bytes); if (ret) { return ret; } |