[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/31] block/parallels: BDRVParallelsState: add cluster_size field
From: |
Kevin Wolf |
Subject: |
[PULL 26/31] block/parallels: BDRVParallelsState: add cluster_size field |
Date: |
Fri, 5 Mar 2021 17:54:49 +0100 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
We are going to use it in more places, calculating
"s->tracks << BDRV_SECTOR_BITS" doesn't look good.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210224104707.88430-4-vsementsov@virtuozzo.com>
Reviewed-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/parallels.h | 1 +
block/parallels.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/parallels.h b/block/parallels.h
index 5aa101cfc8..9a9209e320 100644
--- a/block/parallels.h
+++ b/block/parallels.h
@@ -79,6 +79,7 @@ typedef struct BDRVParallelsState {
ParallelsPreallocMode prealloc_mode;
unsigned int tracks;
+ unsigned int cluster_size;
unsigned int off_multiplier;
Error *migration_blocker;
diff --git a/block/parallels.c b/block/parallels.c
index 3c22dfdc9d..9594d84978 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -421,7 +421,6 @@ static int coroutine_fn parallels_co_check(BlockDriverState
*bs,
int ret;
uint32_t i;
bool flush_bat = false;
- int cluster_size = s->tracks << BDRV_SECTOR_BITS;
size = bdrv_getlength(bs->file->bs);
if (size < 0) {
@@ -472,7 +471,7 @@ static int coroutine_fn parallels_co_check(BlockDriverState
*bs,
high_off = off;
}
- if (prev_off != 0 && (prev_off + cluster_size) != off) {
+ if (prev_off != 0 && (prev_off + s->cluster_size) != off) {
res->bfi.fragmented_clusters++;
}
prev_off = off;
@@ -487,10 +486,10 @@ static int coroutine_fn
parallels_co_check(BlockDriverState *bs,
}
}
- res->image_end_offset = high_off + cluster_size;
+ res->image_end_offset = high_off + s->cluster_size;
if (size > res->image_end_offset) {
int64_t count;
- count = DIV_ROUND_UP(size - res->image_end_offset, cluster_size);
+ count = DIV_ROUND_UP(size - res->image_end_offset, s->cluster_size);
fprintf(stderr, "%s space leaked at the end of the image %" PRId64
"\n",
fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR",
size - res->image_end_offset);
@@ -771,6 +770,7 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
ret = -EFBIG;
goto fail;
}
+ s->cluster_size = s->tracks << BDRV_SECTOR_BITS;
s->bat_size = le32_to_cpu(ph.bat_entries);
if (s->bat_size > INT_MAX / sizeof(uint32_t)) {
--
2.29.2
- [PULL 00/31] Block layer patches, Kevin Wolf, 2021/03/05
- [PULL 06/31] blockjob: report a better error message, Kevin Wolf, 2021/03/05
- [PULL 01/31] iotests: Drop deprecated 'props' from object-add, Kevin Wolf, 2021/03/05
- [PULL 15/31] libqtest: add qtest_remove_abrt_handler(), Kevin Wolf, 2021/03/05
- [PULL 13/31] libqtest: add qtest_socket_server(), Kevin Wolf, 2021/03/05
- [PULL 08/31] storage-daemon: include current command line option in the errors, Kevin Wolf, 2021/03/05
- [PULL 05/31] iotests: Fix up python style in 300, Kevin Wolf, 2021/03/05
- [PULL 09/31] qemu-storage-daemon: add --pidfile option, Kevin Wolf, 2021/03/05
- [PULL 02/31] backup: Remove nodes from job in .clean(), Kevin Wolf, 2021/03/05
- [PULL 26/31] block/parallels: BDRVParallelsState: add cluster_size field,
Kevin Wolf <=
- [PULL 11/31] docs: replace insecure /tmp examples in qsd docs, Kevin Wolf, 2021/03/05
- [PULL 19/31] block/export: use VIRTIO_BLK_SECTOR_BITS, Kevin Wolf, 2021/03/05
- [PULL 25/31] parallels.txt: fix bitmap L1 table description, Kevin Wolf, 2021/03/05
- [PULL 10/31] docs: show how to spawn qemu-storage-daemon with fd passing, Kevin Wolf, 2021/03/05
- [PULL 20/31] block/export: fix vhost-user-blk export sector number calculation, Kevin Wolf, 2021/03/05
- [PULL 17/31] tests/qtest: add multi-queue test case to vhost-user-blk-test, Kevin Wolf, 2021/03/05
- [PULL 21/31] block/export: port virtio-blk discard/write zeroes input validation, Kevin Wolf, 2021/03/05
- [PULL 23/31] block/export: port virtio-blk read/write range check, Kevin Wolf, 2021/03/05
- [PULL 03/31] backup-top: Refuse I/O in inactive state, Kevin Wolf, 2021/03/05
- [PULL 30/31] MAINTAINERS: update parallels block driver, Kevin Wolf, 2021/03/05