提交 11c9c615 编写于 作者: D Dong Xu Wang 提交者: Kevin Wolf

qed: image fragmentation statistics

Signed-off-by: NDong Xu Wang <wdongxu@linux.vnet.ibm.com>
Reviewed-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 f8111c24
...@@ -68,6 +68,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) ...@@ -68,6 +68,7 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table)
{ {
BDRVQEDState *s = check->s; BDRVQEDState *s = check->s;
unsigned int i, num_invalid = 0; unsigned int i, num_invalid = 0;
uint64_t last_offset = 0;
for (i = 0; i < s->table_nelems; i++) { for (i = 0; i < s->table_nelems; i++) {
uint64_t offset = table->offsets[i]; uint64_t offset = table->offsets[i];
...@@ -76,6 +77,11 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) ...@@ -76,6 +77,11 @@ static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table)
qed_offset_is_zero_cluster(offset)) { qed_offset_is_zero_cluster(offset)) {
continue; continue;
} }
check->result->bfi.allocated_clusters++;
if (last_offset && (last_offset + s->header.cluster_size != offset)) {
check->result->bfi.fragmented_clusters++;
}
last_offset = offset;
/* Detect invalid cluster offset */ /* Detect invalid cluster offset */
if (!qed_check_cluster_offset(s, offset)) { if (!qed_check_cluster_offset(s, offset)) {
...@@ -200,6 +206,9 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix) ...@@ -200,6 +206,9 @@ int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)
check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) * check.used_clusters = g_malloc0(((check.nclusters + 31) / 32) *
sizeof(check.used_clusters[0])); sizeof(check.used_clusters[0]));
check.result->bfi.total_clusters =
(s->header.image_size + s->header.cluster_size - 1) /
s->header.cluster_size;
ret = qed_check_l1_table(&check, s->l1_table); ret = qed_check_l1_table(&check, s->l1_table);
if (ret == 0) { if (ret == 0) {
/* Only check for leaks if entire image was scanned successfully */ /* Only check for leaks if entire image was scanned successfully */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册