[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 11/18] parallels: respect error code of bdrv_getlengt
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 11/18] parallels: respect error code of bdrv_getlength() in allocate_clusters() |
Date: |
Tue, 8 Aug 2017 15:58:31 +0200 |
From: "Denis V. Lunev" <address@hidden>
If we can not get the file length, the state of BDS is broken completely.
Return error to the caller.
Signed-off-by: Denis V. Lunev <address@hidden>
CC: Markus Armbruster <address@hidden>
CC: Kevin Wolf <address@hidden>
CC: Max Reitz <address@hidden>
CC: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block/parallels.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index 5bbdfabb7a..6794e53c0b 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -192,7 +192,7 @@ static int64_t allocate_clusters(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
{
BDRVParallelsState *s = bs->opaque;
- int64_t pos, space, idx, to_allocate, i;
+ int64_t pos, space, idx, to_allocate, i, len;
pos = block_status(s, sector_num, nb_sectors, pnum);
if (pos > 0) {
@@ -214,7 +214,11 @@ static int64_t allocate_clusters(BlockDriverState *bs,
int64_t sector_num,
assert(idx < s->bat_size && idx + to_allocate <= s->bat_size);
space = to_allocate * s->tracks;
- if (s->data_end + space > bdrv_getlength(bs->file->bs) >>
BDRV_SECTOR_BITS) {
+ len = bdrv_getlength(bs->file->bs);
+ if (len < 0) {
+ return len;
+ }
+ if (s->data_end + space > (len >> BDRV_SECTOR_BITS)) {
int ret;
space += s->prealloc_size;
if (s->prealloc_mode == PRL_PREALLOC_MODE_FALLOCATE) {
--
2.13.4
- [Qemu-block] [PULL 02/18] quorum: Set sectors-count to 0 when reporting a flush error, (continued)
- [Qemu-block] [PULL 02/18] quorum: Set sectors-count to 0 when reporting a flush error, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 01/18] qemu-iotests/109: Fix lock race condition, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 05/18] block/vhdx: check error return of bdrv_flush(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 06/18] block/vhdx: check error return of bdrv_truncate(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 03/18] block/vhdx: check error return of bdrv_getlength(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 04/18] block/vhdx: check for offset overflow to bdrv_truncate(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 08/18] block/null: Remove 'filename' option, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 09/18] vmdk: Fix error handling/reporting of vmdk_check, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 07/18] block: drop bdrv_set_key from BlockDriver, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 10/18] block: respect error code from bdrv_getlength in handle_aiocb_write_zeroes, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 11/18] parallels: respect error code of bdrv_getlength() in allocate_clusters(),
Kevin Wolf <=
- [Qemu-block] [PULL 12/18] parallels: drop check that bdrv_truncate() is working, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 13/18] block: Fix order in bdrv_replace_child(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 14/18] block: Allow reopen rw without BDRV_O_ALLOW_RDWR, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 16/18] qemu-io: Allow reopen read-write, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 15/18] block: Set BDRV_O_ALLOW_RDWR during rw reopen, Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 18/18] block/nfs: fix mutex assertion in nfs_file_close(), Kevin Wolf, 2017/08/08
- [Qemu-block] [PULL 17/18] qemu-iotests: Test reopen between read-only and read-write, Kevin Wolf, 2017/08/08
- Re: [Qemu-block] [PULL 00/18] Block layer patches for 2.10.0-rc2, Peter Maydell, 2017/08/08