[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 24/61] qcow2: Use offset_into_cluster() and offset_to
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 24/61] qcow2: Use offset_into_cluster() and offset_to_l2_index() |
Date: |
Fri, 23 Jun 2017 18:21:22 +0200 |
From: Alberto Garcia <address@hidden>
We already have functions for doing these calculations, so let's use
them instead of doing everything by hand. This makes the code a bit
more readable.
Signed-off-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 4 ++--
block/qcow2.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 01f2101..3d341fd 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -556,7 +556,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t
offset,
/* find the cluster offset for the given disk offset */
- l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
+ l2_index = offset_to_l2_index(s, offset);
*cluster_offset = be64_to_cpu(l2_table[l2_index]);
nb_clusters = size_to_clusters(s, bytes_needed);
@@ -693,7 +693,7 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t
offset,
/* find the cluster offset for the given disk offset */
- l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
+ l2_index = offset_to_l2_index(s, offset);
*new_l2_table = l2_table;
*new_l2_index = l2_index;
diff --git a/block/qcow2.c b/block/qcow2.c
index 328b1d4..088ffe1 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -356,7 +356,7 @@ static int validate_table_offset(BlockDriverState *bs,
uint64_t offset,
}
/* Tables must be cluster aligned */
- if (offset & (s->cluster_size - 1)) {
+ if (offset_into_cluster(s, offset) != 0) {
return -EINVAL;
}
--
1.8.3.1
- Re: [Qemu-block] [Qemu-devel] [PULL 11/61] virtio-pci: use ioeventfd even when KVM is disabled, (continued)
- [Qemu-block] [PULL 15/61] qemu-iotests: 068: test iothread mode, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 17/61] qcow2: Remove unused Error variable in do_perform_cow(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 18/61] qcow2: Use unsigned int for both members of Qcow2COWRegion, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 20/61] qcow2: Split do_perform_cow() into _read(), _encrypt() and _write(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 16/61] nvme: Add support for Read Data and Write Data in CMBs., Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 19/61] qcow2: Make perform_cow() call do_perform_cow() twice, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 21/61] qcow2: Allow reading both COW regions with only one request, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 22/61] qcow2: Pass a QEMUIOVector to do_perform_cow_{read, write}(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 26/61] qed: Make qed_read_table() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 24/61] qcow2: Use offset_into_cluster() and offset_to_l2_index(),
Kevin Wolf <=
- [Qemu-block] [PULL 25/61] qed: Use bottom half to resume waiting requests, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 27/61] qed: Remove callback from qed_read_table(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 23/61] qcow2: Merge the writing of the COW regions with the guest data, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 28/61] qed: Remove callback from qed_read_l2_table(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 29/61] qed: Remove callback from qed_find_cluster(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 30/61] qed: Make qed_read_backing_file() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 31/61] qed: Make qed_copy_from_backing_file() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 33/61] qed: Make qed_write_header() synchronous, Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 32/61] qed: Remove callback from qed_copy_from_backing_file(), Kevin Wolf, 2017/06/23
- [Qemu-block] [PULL 34/61] qed: Remove callback from qed_write_header(), Kevin Wolf, 2017/06/23