[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 35/35] qcow2: fix range check
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 35/35] qcow2: fix range check |
Date: |
Mon, 12 Sep 2011 16:19:34 +0200 |
From: Frediano Ziglio <address@hidden>
QCowL2Meta::offset is not cluster aligned but only sector aligned
however nb_clusters count cluster from cluster start.
This fix range check. Note that old code have no corruption issues
related to this check cause it only cause intersection to occur
when shouldn't.
Signed-off-by: Frediano Ziglio <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 428b5ad..2f76311 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -776,17 +776,17 @@ again:
*/
QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {
- uint64_t end_offset = offset + nb_clusters * s->cluster_size;
- uint64_t old_offset = old_alloc->offset;
- uint64_t old_end_offset = old_alloc->offset +
- old_alloc->nb_clusters * s->cluster_size;
+ uint64_t start = offset >> s->cluster_bits;
+ uint64_t end = start + nb_clusters;
+ uint64_t old_start = old_alloc->offset >> s->cluster_bits;
+ uint64_t old_end = old_start + old_alloc->nb_clusters;
- if (end_offset < old_offset || offset > old_end_offset) {
+ if (end < old_start || start > old_end) {
/* No intersection */
} else {
- if (offset < old_offset) {
+ if (start < old_start) {
/* Stop at the start of a running allocation */
- nb_clusters = (old_offset - offset) >> s->cluster_bits;
+ nb_clusters = old_start - start;
} else {
nb_clusters = 0;
}
--
1.7.6
- [Qemu-devel] [PATCH 14/35] block: Drop medium lock tracking, ask device models instead, (continued)
- [Qemu-devel] [PATCH 14/35] block: Drop medium lock tracking, ask device models instead, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 16/35] rbd: allow client id to be specified in config string, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 21/35] ide/atapi: Preserve tray state on migration, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 12/35] scsi-disk: Track tray locked state, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 15/35] block: Rename bdrv_set_locked() to bdrv_lock_medium(), Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 22/35] block: Clean up remaining users of "removable", Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 20/35] scsi-disk: Fix START_STOP to fail when it can't eject, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 28/35] block: Reset buffer alignment on detach, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 24/35] block: Show whether the virtual tray is open in info block, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 31/35] ide/atapi scsi-disk: Make monitor eject -f, then change work, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 35/35] qcow2: fix range check,
Kevin Wolf <=
- [Qemu-devel] [PATCH 34/35] qcow2: align cluster_data to block to improve performance using O_DIRECT, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 19/35] ide/atapi: Don't fail eject when tray is already open, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 25/35] block: Move BlockConf & friends from block_int.h to block.h, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 26/35] hw: Trim superfluous #include "block_int.h", Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 30/35] block: New change_media_cb() parameter load, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 32/35] qcow2: initialize metadata before inserting in cluster_allocs, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 23/35] block: Drop BlockDriverState member removable, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 33/35] ahci: Remove unused struct member, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 17/35] rbd: clean up, fix style, Kevin Wolf, 2011/09/12
- [Qemu-devel] [PATCH 18/35] rbd: fix leak in qemu_rbd_open failure paths, Kevin Wolf, 2011/09/12