[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/33] qcow2: Prepare qcow2_get_cluster_type() for ex
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 16/33] qcow2: Prepare qcow2_get_cluster_type() for external data file |
Date: |
Fri, 8 Mar 2019 13:58:06 +0100 |
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/qcow2.h b/block/qcow2.h
index 7a34bd0c53..8fe2d55005 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -521,7 +521,15 @@ static inline QCow2ClusterType
qcow2_get_cluster_type(BlockDriverState *bs,
}
return QCOW2_CLUSTER_ZERO_PLAIN;
} else if (!(l2_entry & L2E_OFFSET_MASK)) {
- return QCOW2_CLUSTER_UNALLOCATED;
+ /* Offset 0 generally means unallocated, but it is ambiguous with
+ * external data files because 0 is a valid offset there. However, all
+ * clusters in external data files always have refcount 1, so we can
+ * rely on QCOW_OFLAG_COPIED to disambiguate. */
+ if (has_data_file(bs) && (l2_entry & QCOW_OFLAG_COPIED)) {
+ return QCOW2_CLUSTER_NORMAL;
+ } else {
+ return QCOW2_CLUSTER_UNALLOCATED;
+ }
} else {
return QCOW2_CLUSTER_NORMAL;
}
--
2.20.1
- [Qemu-devel] [PULL 14/33] qcow2: Basic definitions for external data files, (continued)
- [Qemu-devel] [PULL 14/33] qcow2: Basic definitions for external data files, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 17/33] qcow2: Prepare count_contiguous_clusters() for external data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 18/33] qcow2: Don't assume 0 is an invalid cluster offset, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 20/33] qcow2: Prepare qcow2_co_block_status() for data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 15/33] qcow2: Pass bs to qcow2_get_cluster_type(), Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 23/33] qcow2: Support external data file in qemu-img check, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 22/33] qcow2: Return error for snapshot operation with data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 19/33] qcow2: Return 0/-errno in qcow2_alloc_compressed_cluster_offset(), Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 09/33] qemu-iotests: Improve portability by searching bash in the $PATH, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 24/33] qcow2: Add basic data-file infrastructure, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 16/33] qcow2: Prepare qcow2_get_cluster_type() for external data file,
Kevin Wolf <=
- [Qemu-devel] [PULL 21/33] qcow2: External file I/O, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 28/33] qemu-iotests: Preallocation with external data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 25/33] qcow2: Creating images with external data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 26/33] qcow2: Store data file name in the image, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 32/33] qemu-iotests: Add dependency to qemu-nbd tool, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 30/33] qemu-iotests: amend with external data file, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 33/33] qcow2 spec: Describe string header extensions, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 31/33] ahci-test: Add dependency to qemu-img tool, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 27/33] qcow2: Implement data-file-raw create option, Kevin Wolf, 2019/03/08
- [Qemu-devel] [PULL 29/33] qemu-iotests: General tests for qcow2 with external data file, Kevin Wolf, 2019/03/08