[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 10/32] qcow2: Add offset_to_sc_index()
From: |
Alberto Garcia |
Subject: |
[PATCH v6 10/32] qcow2: Add offset_to_sc_index() |
Date: |
Sun, 24 May 2020 16:51:30 +0200 |
For a given offset, return the subcluster number within its cluster
(i.e. with 32 subclusters per cluster it returns a number between 0
and 31).
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/qcow2.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qcow2.h b/block/qcow2.h
index 4e9c732831..ca73ac9b67 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -581,6 +581,11 @@ static inline int offset_to_l2_slice_index(BDRVQcow2State
*s, int64_t offset)
return (offset >> s->cluster_bits) & (s->l2_slice_size - 1);
}
+static inline int offset_to_sc_index(BDRVQcow2State *s, int64_t offset)
+{
+ return (offset >> s->subcluster_bits) & (s->subclusters_per_cluster - 1);
+}
+
static inline int64_t qcow2_vm_state_offset(BDRVQcow2State *s)
{
return (int64_t)s->l1_vm_state_index << (s->cluster_bits + s->l2_bits);
--
2.20.1
- [PATCH v6 00/32] Add subcluster allocation to qcow2, Alberto Garcia, 2020/05/24
- [PATCH v6 03/32] qcow2: Add calculate_l2_meta(), Alberto Garcia, 2020/05/24
- [PATCH v6 29/32] qcow2: Add subcluster support to qcow2_measure(), Alberto Garcia, 2020/05/24
- [PATCH v6 14/32] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type(), Alberto Garcia, 2020/05/24
- [PATCH v6 10/32] qcow2: Add offset_to_sc_index(),
Alberto Garcia <=
- [PATCH v6 05/32] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2020/05/24
- [PATCH v6 01/32] qcow2: Make Qcow2AioTask store the full host offset, Alberto Garcia, 2020/05/24
- [PATCH v6 06/32] qcow2: Add get_l2_entry() and set_l2_entry(), Alberto Garcia, 2020/05/24
- [PATCH v6 23/32] qcow2: Add subcluster support to discard_in_l2_slice(), Alberto Garcia, 2020/05/24
- [PATCH v6 12/32] qcow2: Add l2_entry_size(), Alberto Garcia, 2020/05/24
- [PATCH v6 16/32] qcow2: Add qcow2_cluster_is_allocated(), Alberto Garcia, 2020/05/24
- [PATCH v6 09/32] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2020/05/24
- [PATCH v6 02/32] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/05/24
- [PATCH v6 22/32] qcow2: Add subcluster support to zero_in_l2_slice(), Alberto Garcia, 2020/05/24
- [PATCH v6 17/32] qcow2: Add cluster type parameter to qcow2_get_host_offset(), Alberto Garcia, 2020/05/24