qemu-img: add compressed clusters to BlockFragInfo
Show how many clusters are compressed. This can be used to monitor how many compressed clusters remain and whether to recompress the image. Suggested-by: Cole Robinson <crobinso@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
c9fc508398
commit
e6439d783c
|
@ -24,6 +24,7 @@ typedef struct BlockFragInfo {
|
||||||
uint64_t allocated_clusters;
|
uint64_t allocated_clusters;
|
||||||
uint64_t total_clusters;
|
uint64_t total_clusters;
|
||||||
uint64_t fragmented_clusters;
|
uint64_t fragmented_clusters;
|
||||||
|
uint64_t compressed_clusters;
|
||||||
} BlockFragInfo;
|
} BlockFragInfo;
|
||||||
|
|
||||||
typedef struct QEMUSnapshotInfo {
|
typedef struct QEMUSnapshotInfo {
|
||||||
|
|
|
@ -279,6 +279,10 @@
|
||||||
# field is present if the driver for the image format
|
# field is present if the driver for the image format
|
||||||
# supports it
|
# supports it
|
||||||
#
|
#
|
||||||
|
# @compressed-clusters: #optional total number of compressed clusters, this
|
||||||
|
# field is present if the driver for the image format
|
||||||
|
# supports it
|
||||||
|
#
|
||||||
# Since: 1.4
|
# Since: 1.4
|
||||||
#
|
#
|
||||||
##
|
##
|
||||||
|
@ -288,7 +292,7 @@
|
||||||
'*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
|
'*image-end-offset': 'int', '*corruptions': 'int', '*leaks': 'int',
|
||||||
'*corruptions-fixed': 'int', '*leaks-fixed': 'int',
|
'*corruptions-fixed': 'int', '*leaks-fixed': 'int',
|
||||||
'*total-clusters': 'int', '*allocated-clusters': 'int',
|
'*total-clusters': 'int', '*allocated-clusters': 'int',
|
||||||
'*fragmented-clusters': 'int' } }
|
'*fragmented-clusters': 'int', '*compressed-clusters': 'int' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @StatusInfo:
|
# @StatusInfo:
|
||||||
|
|
|
@ -428,10 +428,11 @@ static void dump_human_image_check(ImageCheck *check)
|
||||||
|
|
||||||
if (check->total_clusters != 0 && check->allocated_clusters != 0) {
|
if (check->total_clusters != 0 && check->allocated_clusters != 0) {
|
||||||
printf("%" PRId64 "/%" PRId64 " = %0.2f%% allocated, "
|
printf("%" PRId64 "/%" PRId64 " = %0.2f%% allocated, "
|
||||||
"%0.2f%% fragmented\n",
|
"%0.2f%% fragmented, %0.2f%% compressed clusters\n",
|
||||||
check->allocated_clusters, check->total_clusters,
|
check->allocated_clusters, check->total_clusters,
|
||||||
check->allocated_clusters * 100.0 / check->total_clusters,
|
check->allocated_clusters * 100.0 / check->total_clusters,
|
||||||
check->fragmented_clusters * 100.0 / check->allocated_clusters);
|
check->fragmented_clusters * 100.0 / check->allocated_clusters,
|
||||||
|
check->compressed_clusters * 100.0 / check->allocated_clusters);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (check->image_end_offset) {
|
if (check->image_end_offset) {
|
||||||
|
@ -472,6 +473,8 @@ static int collect_image_check(BlockDriverState *bs,
|
||||||
check->has_allocated_clusters = result.bfi.allocated_clusters != 0;
|
check->has_allocated_clusters = result.bfi.allocated_clusters != 0;
|
||||||
check->fragmented_clusters = result.bfi.fragmented_clusters;
|
check->fragmented_clusters = result.bfi.fragmented_clusters;
|
||||||
check->has_fragmented_clusters = result.bfi.fragmented_clusters != 0;
|
check->has_fragmented_clusters = result.bfi.fragmented_clusters != 0;
|
||||||
|
check->compressed_clusters = result.bfi.compressed_clusters;
|
||||||
|
check->has_compressed_clusters = result.bfi.compressed_clusters != 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
No errors were found on the image.
|
No errors were found on the image.
|
||||||
|
7292415/8391499= 86.90% allocated, 0.00% fragmented, 0.00% compressed clusters
|
||||||
Image end offset: 4296447488
|
Image end offset: 4296447488
|
||||||
.
|
.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
|
@ -162,7 +162,7 @@ _cleanup_test_img()
|
||||||
_check_test_img()
|
_check_test_img()
|
||||||
{
|
{
|
||||||
$QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \
|
$QEMU_IMG check "$@" -f $IMGFMT $TEST_IMG 2>&1 | \
|
||||||
sed -e "/fragmented$/d" \
|
sed -e '/allocated.*fragmented.*compressed clusters/d' \
|
||||||
-e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
|
-e 's/qemu-img: This image format does not support checks/No errors were found on the image./' \
|
||||||
-e '/Image end offset: [0-9]\+/d'
|
-e '/Image end offset: [0-9]\+/d'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue