block: Keep bdrv_check*_request()'s return value
Do not throw away the value returned by bdrv_check_request() and bdrv_check_byte_request(). Fix up some coding style issues in the proximity of the affected hunks. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 1423162705-32065-17-git-send-email-mreitz@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
c0191e763b
commit
b9c649470b
35
block.c
35
block.c
@ -3098,8 +3098,10 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
|
|||||||
if (!drv) {
|
if (!drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
}
|
}
|
||||||
if (bdrv_check_byte_request(bs, offset, bytes)) {
|
|
||||||
return -EIO;
|
ret = bdrv_check_byte_request(bs, offset, bytes);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs->copy_on_read) {
|
if (bs->copy_on_read) {
|
||||||
@ -3342,8 +3344,10 @@ static int coroutine_fn bdrv_co_do_pwritev(BlockDriverState *bs,
|
|||||||
if (bs->read_only) {
|
if (bs->read_only) {
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
}
|
}
|
||||||
if (bdrv_check_byte_request(bs, offset, bytes)) {
|
|
||||||
return -EIO;
|
ret = bdrv_check_byte_request(bs, offset, bytes);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* throttling disk I/O */
|
/* throttling disk I/O */
|
||||||
@ -4197,12 +4201,18 @@ int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
|
|||||||
const uint8_t *buf, int nb_sectors)
|
const uint8_t *buf, int nb_sectors)
|
||||||
{
|
{
|
||||||
BlockDriver *drv = bs->drv;
|
BlockDriver *drv = bs->drv;
|
||||||
if (!drv)
|
int ret;
|
||||||
|
|
||||||
|
if (!drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
if (!drv->bdrv_write_compressed)
|
}
|
||||||
|
if (!drv->bdrv_write_compressed) {
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
if (bdrv_check_request(bs, sector_num, nb_sectors))
|
}
|
||||||
return -EIO;
|
ret = bdrv_check_request(bs, sector_num, nb_sectors);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
|
assert(QLIST_EMPTY(&bs->dirty_bitmaps));
|
||||||
|
|
||||||
@ -5117,12 +5127,15 @@ static void coroutine_fn bdrv_discard_co_entry(void *opaque)
|
|||||||
int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
|
int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
|
||||||
int nb_sectors)
|
int nb_sectors)
|
||||||
{
|
{
|
||||||
int max_discard;
|
int max_discard, ret;
|
||||||
|
|
||||||
if (!bs->drv) {
|
if (!bs->drv) {
|
||||||
return -ENOMEDIUM;
|
return -ENOMEDIUM;
|
||||||
} else if (bdrv_check_request(bs, sector_num, nb_sectors)) {
|
}
|
||||||
return -EIO;
|
|
||||||
|
ret = bdrv_check_request(bs, sector_num, nb_sectors);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
} else if (bs->read_only) {
|
} else if (bs->read_only) {
|
||||||
return -EROFS;
|
return -EROFS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user