diff mbox

[5/6] qcow2: Add more overlap check bitmask macros

Message ID 1379666231-10443-6-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz Sept. 20, 2013, 8:37 a.m. UTC
Introduces the macros QCOW2_OL_CONSTANT and QCOW2_OL_ALL in addition to
the already existing QCOW2_OL_CACHED, signifying all metadata overlap
checks that can be performed in constant time (regardless of image size
etc.) and truly all available overlap checks, respectively.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block/qcow2.h | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Comments

Kevin Wolf Oct. 9, 2013, 1:07 p.m. UTC | #1
Am 20.09.2013 um 10:37 hat Max Reitz geschrieben:
> Introduces the macros QCOW2_OL_CONSTANT and QCOW2_OL_ALL in addition to
> the already existing QCOW2_OL_CACHED, signifying all metadata overlap
> checks that can be performed in constant time (regardless of image size
> etc.) and truly all available overlap checks, respectively.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/qcow2.h | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/block/qcow2.h b/block/qcow2.h
> index 067ed2f..098c14f 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -326,11 +326,19 @@ typedef enum QCow2MetadataOverlap {
>      QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
>  } QCow2MetadataOverlap;
>  
> +/* Perform all overlap checks which can be done in constant time */
> +#define QCOW2_OL_CONSTANT \
> +    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
> +     QCOW2_OL_SNAPSHOT_TABLE)
> +
>  /* Perform all overlap checks which don't require disk access */
>  #define QCOW2_OL_CACHED \
> -    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_ACTIVE_L2 | \
> -     QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \
> -     QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1)
> +    (QCOW2_OL_CONSTANT | QCOW2_OL_ACTIVE_L2 | QCOW2_OL_REFCOUNT_BLOCK | \
> +     QCOW2_OL_SNAPSHOT_TABLE)

QCOW2_OL_INACTIVE_L1 is lost here.

> +/* Perform all overlap checks */
> +#define QCOW2_OL_ALL \
> +    (QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2)

Kevin
Max Reitz Oct. 9, 2013, 1:22 p.m. UTC | #2
On 2013-10-09 15:07, Kevin Wolf wrote:
> Am 20.09.2013 um 10:37 hat Max Reitz geschrieben:
>> Introduces the macros QCOW2_OL_CONSTANT and QCOW2_OL_ALL in addition to
>> the already existing QCOW2_OL_CACHED, signifying all metadata overlap
>> checks that can be performed in constant time (regardless of image size
>> etc.) and truly all available overlap checks, respectively.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>   block/qcow2.h | 14 +++++++++++---
>>   1 file changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/qcow2.h b/block/qcow2.h
>> index 067ed2f..098c14f 100644
>> --- a/block/qcow2.h
>> +++ b/block/qcow2.h
>> @@ -326,11 +326,19 @@ typedef enum QCow2MetadataOverlap {
>>       QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
>>   } QCow2MetadataOverlap;
>>   
>> +/* Perform all overlap checks which can be done in constant time */
>> +#define QCOW2_OL_CONSTANT \
>> +    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
>> +     QCOW2_OL_SNAPSHOT_TABLE)
>> +
>>   /* Perform all overlap checks which don't require disk access */
>>   #define QCOW2_OL_CACHED \
>> -    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_ACTIVE_L2 | \
>> -     QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \
>> -     QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1)
>> +    (QCOW2_OL_CONSTANT | QCOW2_OL_ACTIVE_L2 | QCOW2_OL_REFCOUNT_BLOCK | \
>> +     QCOW2_OL_SNAPSHOT_TABLE)
> QCOW2_OL_INACTIVE_L1 is lost here.

Oh, right, I'll fix it. Thanks for reviewing, by the way. :)

Max

>> +/* Perform all overlap checks */
>> +#define QCOW2_OL_ALL \
>> +    (QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2)
> Kevin
diff mbox

Patch

diff --git a/block/qcow2.h b/block/qcow2.h
index 067ed2f..098c14f 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -326,11 +326,19 @@  typedef enum QCow2MetadataOverlap {
     QCOW2_OL_INACTIVE_L2    = (1 << QCOW2_OL_INACTIVE_L2_BITNR),
 } QCow2MetadataOverlap;
 
+/* Perform all overlap checks which can be done in constant time */
+#define QCOW2_OL_CONSTANT \
+    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_REFCOUNT_TABLE | \
+     QCOW2_OL_SNAPSHOT_TABLE)
+
 /* Perform all overlap checks which don't require disk access */
 #define QCOW2_OL_CACHED \
-    (QCOW2_OL_MAIN_HEADER | QCOW2_OL_ACTIVE_L1 | QCOW2_OL_ACTIVE_L2 | \
-     QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \
-     QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1)
+    (QCOW2_OL_CONSTANT | QCOW2_OL_ACTIVE_L2 | QCOW2_OL_REFCOUNT_BLOCK | \
+     QCOW2_OL_SNAPSHOT_TABLE)
+
+/* Perform all overlap checks */
+#define QCOW2_OL_ALL \
+    (QCOW2_OL_CACHED | QCOW2_OL_INACTIVE_L2)
 
 #define L1E_OFFSET_MASK 0x00ffffffffffff00ULL
 #define L2E_OFFSET_MASK 0x00ffffffffffff00ULL