[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 18/39] qcow2: Refactor get_cluster_table()
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v4 18/39] qcow2: Refactor get_cluster_table() |
Date: |
Mon, 5 Feb 2018 16:33:18 +0200 |
After the previous patch we're now always using l2_load() in
get_cluster_table() regardless of whether a new L2 table has to be
allocated or not.
This patch refactors that part of the code to use one single l2_load()
call.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/qcow2-cluster.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index e0a3802161..9311dafccd 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -695,15 +695,7 @@ static int get_cluster_table(BlockDriverState *bs,
uint64_t offset,
return -EIO;
}
- /* seek the l2 table of the given l2 offset */
-
- if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) {
- /* load the l2 table in memory */
- ret = l2_load(bs, offset, l2_offset, &l2_table);
- if (ret < 0) {
- return ret;
- }
- } else {
+ if (!(s->l1_table[l1_index] & QCOW_OFLAG_COPIED)) {
/* First allocate a new L2 table (and do COW if needed) */
ret = l2_allocate(bs, l1_index);
if (ret < 0) {
@@ -719,11 +711,12 @@ static int get_cluster_table(BlockDriverState *bs,
uint64_t offset,
/* Get the offset of the newly-allocated l2 table */
l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK;
assert(offset_into_cluster(s, l2_offset) == 0);
- /* Load the l2 table in memory */
- ret = l2_load(bs, offset, l2_offset, &l2_table);
- if (ret < 0) {
- return ret;
- }
+ }
+
+ /* load the l2 table in memory */
+ ret = l2_load(bs, offset, l2_offset, &l2_table);
+ if (ret < 0) {
+ return ret;
}
/* find the cluster offset for the given disk offset */
--
2.11.0
- Re: [Qemu-devel] [PATCH v4 27/39] qcow2: Update qcow2_update_snapshot_refcount() to support L2 slices, (continued)
- [Qemu-devel] [PATCH v4 26/39] qcow2: Prepare qcow2_update_snapshot_refcount() for adding L2 slice support, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 14/39] qcow2: Add offset_to_l2_slice_index(), Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 21/39] qcow2: Update qcow2_alloc_cluster_link_l2() to support L2 slices, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 25/39] qcow2: Update zero_single_l2() to support L2 slices, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 19/39] qcow2: Update get_cluster_table() to support L2 slices, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 29/39] qcow2: Prepare expand_zero_clusters_in_l1() for adding L2 slice support, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 16/39] qcow2: Prepare l2_allocate() for adding L2 slice support, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 23/39] qcow2: Update handle_alloc() to support L2 slices, Alberto Garcia, 2018/02/05
- [Qemu-devel] [PATCH v4 18/39] qcow2: Refactor get_cluster_table(),
Alberto Garcia <=
- Re: [Qemu-devel] [PATCH v4 00/39] Allow configuring the qcow2 L2 cache entry size, Max Reitz, 2018/02/05
- Re: [Qemu-devel] [PATCH v4 00/39] Allow configuring the qcow2 L2 cache entry size, Max Reitz, 2018/02/13