From 21df65b6444858ddee3a86d8666571bb41695614 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Fri, 17 Dec 2010 15:58:22 +0000 Subject: qed: Add support for zero clusters Zero clusters are similar to unallocated clusters except instead of reading their value from a backing file when one is available, the cluster is always read as zero. This implements read support only. At this stage, QED will never write a zero cluster. Signed-off-by: Anthony Liguori Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qed.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'block/qed.h') diff --git a/block/qed.h b/block/qed.h index 2925e37b1c..3e1ab84781 100644 --- a/block/qed.h +++ b/block/qed.h @@ -161,6 +161,7 @@ typedef struct { enum { QED_CLUSTER_FOUND, /* cluster found */ + QED_CLUSTER_ZERO, /* zero cluster found */ QED_CLUSTER_L2, /* cluster missing in L2 */ QED_CLUSTER_L1, /* cluster missing in L1 */ }; @@ -298,4 +299,29 @@ static inline bool qed_check_table_offset(BDRVQEDState *s, uint64_t offset) qed_check_cluster_offset(s, end_offset); } +static inline bool qed_offset_is_cluster_aligned(BDRVQEDState *s, + uint64_t offset) +{ + if (qed_offset_into_cluster(s, offset)) { + return false; + } + return true; +} + +static inline bool qed_offset_is_unalloc_cluster(uint64_t offset) +{ + if (offset == 0) { + return true; + } + return false; +} + +static inline bool qed_offset_is_zero_cluster(uint64_t offset) +{ + if (offset == 1) { + return true; + } + return false; +} + #endif /* BLOCK_QED_H */ -- cgit v1.2.3 From 19dfc44a94f759848a0f7de7378b2f8b9af6b5d0 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Sun, 24 Apr 2011 18:38:58 +0100 Subject: qed: Fix consistency check on 32-bit hosts The qed_bytes_to_clusters() function is normally used with size_t lengths. Consistency check used it with file size length and therefore failed on 32-bit hosts when the image file is 4 GB or more. Make qed_bytes_to_clusters() explicitly 64-bit and update consistency check to keep 64-bit cluster counts. Reported-by: Michael Tokarev Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'block/qed.h') diff --git a/block/qed.h b/block/qed.h index 3e1ab84781..1d1421fee1 100644 --- a/block/qed.h +++ b/block/qed.h @@ -252,7 +252,7 @@ static inline uint64_t qed_offset_into_cluster(BDRVQEDState *s, uint64_t offset) return offset & (s->header.cluster_size - 1); } -static inline unsigned int qed_bytes_to_clusters(BDRVQEDState *s, size_t bytes) +static inline uint64_t qed_bytes_to_clusters(BDRVQEDState *s, uint64_t bytes) { return qed_start_of_cluster(s, bytes + (s->header.cluster_size - 1)) / (s->header.cluster_size - 1); -- cgit v1.2.3