From 231bb267644ee3a9ebfd9c7f42d5d41610194b45 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 10 Oct 2013 11:09:23 +0200 Subject: qcow2: Use negated overflow check mask In qcow2_check_metadata_overlap and qcow2_pre_write_overlap_check, change the parameter signifying the checks to perform from its current positive form to a negative one, i.e., it will no longer explicitly specify every check to perform but rather a mask of checks not to perform. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'block/qcow2.h') diff --git a/block/qcow2.h b/block/qcow2.h index 455e38de64..8692011347 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -433,9 +433,9 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, void qcow2_process_discards(BlockDriverState *bs, int ret); -int qcow2_check_metadata_overlap(BlockDriverState *bs, int chk, int64_t offset, +int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, int64_t size); -int qcow2_pre_write_overlap_check(BlockDriverState *bs, int chk, int64_t offset, +int qcow2_pre_write_overlap_check(BlockDriverState *bs, int ign, int64_t offset, int64_t size); /* qcow2-cluster.c functions */ -- cgit v1.2.3 From 3e3553905cfc814d59de6d1a634c3a991b2a9257 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 10 Oct 2013 11:09:24 +0200 Subject: qcow2: Make overlap check mask variable Replace the QCOW2_OL_DEFAULT macro by a variable overlap_check in BDRVQcowState. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'block/qcow2.h') diff --git a/block/qcow2.h b/block/qcow2.h index 8692011347..6c85bb9395 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -203,6 +203,8 @@ typedef struct BDRVQcowState { bool discard_passthrough[QCOW2_DISCARD_MAX]; + int overlap_check; /* bitmask of Qcow2MetadataOverlap values */ + uint64_t incompatible_features; uint64_t compatible_features; uint64_t autoclear_features; @@ -321,9 +323,6 @@ typedef enum QCow2MetadataOverlap { QCOW2_OL_REFCOUNT_TABLE | QCOW2_OL_REFCOUNT_BLOCK | \ QCOW2_OL_SNAPSHOT_TABLE | QCOW2_OL_INACTIVE_L1) -/* The default checks to perform */ -#define QCOW2_OL_DEFAULT QCOW2_OL_CACHED - #define L1E_OFFSET_MASK 0x00ffffffffffff00ULL #define L2E_OFFSET_MASK 0x00ffffffffffff00ULL #define L2E_COMPRESSED_OFFSET_SIZE_MASK 0x3fffffffffffffffULL -- cgit v1.2.3 From 05de7e86cab3ed3830de38b38b39bbc711bc1158 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 10 Oct 2013 11:09:25 +0200 Subject: qcow2: Add overlap-check options Add runtime options to tune the overlap checks to be performed before write accesses. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'block/qcow2.h') diff --git a/block/qcow2.h b/block/qcow2.h index 6c85bb9395..28ccc4aa5f 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -63,6 +63,15 @@ #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request" #define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot" #define QCOW2_OPT_DISCARD_OTHER "pass-discard-other" +#define QCOW2_OPT_OVERLAP "overlap-check" +#define QCOW2_OPT_OVERLAP_MAIN_HEADER "overlap-check.main-header" +#define QCOW2_OPT_OVERLAP_ACTIVE_L1 "overlap-check.active-l1" +#define QCOW2_OPT_OVERLAP_ACTIVE_L2 "overlap-check.active-l2" +#define QCOW2_OPT_OVERLAP_REFCOUNT_TABLE "overlap-check.refcount-table" +#define QCOW2_OPT_OVERLAP_REFCOUNT_BLOCK "overlap-check.refcount-block" +#define QCOW2_OPT_OVERLAP_SNAPSHOT_TABLE "overlap-check.snapshot-table" +#define QCOW2_OPT_OVERLAP_INACTIVE_L1 "overlap-check.inactive-l1" +#define QCOW2_OPT_OVERLAP_INACTIVE_L2 "overlap-check.inactive-l2" typedef struct QCowHeader { uint32_t magic; -- cgit v1.2.3 From 4a273c398b0c96985d56fed8156e19876b2e3c9e Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 10 Oct 2013 11:09:27 +0200 Subject: qcow2: Add more overlap check bitmask macros 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 Signed-off-by: Kevin Wolf --- block/qcow2.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'block/qcow2.h') diff --git a/block/qcow2.h b/block/qcow2.h index 28ccc4aa5f..922e19062a 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_INACTIVE_L1) + +/* 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 -- cgit v1.2.3