Lines Matching full:check

2  * QEMU Enhanced Disk Format Consistency Check
40 * @check: Check structure
44 static bool qed_set_used_clusters(QEDCheck *check, uint64_t offset, in qed_set_used_clusters() argument
47 uint64_t cluster = qed_bytes_to_clusters(check->s, offset); in qed_set_used_clusters()
52 if (qed_test_bit(check->used_clusters, cluster)) { in qed_set_used_clusters()
56 qed_set_bit(check->used_clusters, cluster); in qed_set_used_clusters()
60 check->result->corruptions += corruptions; in qed_set_used_clusters()
65 * Check an L2 table
69 static unsigned int qed_check_l2_table(QEDCheck *check, QEDTable *table) in qed_check_l2_table() argument
71 BDRVQEDState *s = check->s; in qed_check_l2_table()
82 check->result->bfi.allocated_clusters++; in qed_check_l2_table()
84 check->result->bfi.fragmented_clusters++; in qed_check_l2_table()
90 if (check->fix) { in qed_check_l2_table()
92 check->result->corruptions_fixed++; in qed_check_l2_table()
94 check->result->corruptions++; in qed_check_l2_table()
101 qed_set_used_clusters(check, offset, 1); in qed_check_l2_table()
108 * Descend tables and check each cluster is referenced once only
111 qed_check_l1_table(QEDCheck *check, QEDTable *table) in qed_check_l1_table() argument
113 BDRVQEDState *s = check->s; in qed_check_l1_table()
118 qed_set_used_clusters(check, s->header.l1_table_offset, in qed_check_l1_table()
132 if (check->fix) { in qed_check_l1_table()
134 check->result->corruptions_fixed++; in qed_check_l1_table()
136 check->result->corruptions++; in qed_check_l1_table()
143 if (!qed_set_used_clusters(check, offset, s->header.table_size)) { in qed_check_l1_table()
147 ret = qed_read_l2_table_sync(s, &check->request, offset); in qed_check_l1_table()
149 check->result->check_errors++; in qed_check_l1_table()
154 num_invalid_l2 = qed_check_l2_table(check, in qed_check_l1_table()
155 check->request.l2_table->table); in qed_check_l1_table()
158 if (num_invalid_l2 > 0 && check->fix) { in qed_check_l1_table()
159 ret = qed_write_l2_table_sync(s, &check->request, 0, in qed_check_l1_table()
162 check->result->check_errors++; in qed_check_l1_table()
170 qed_unref_l2_cache_entry(check->request.l2_table); in qed_check_l1_table()
171 check->request.l2_table = NULL; in qed_check_l1_table()
174 if (num_invalid_l1 > 0 && check->fix) { in qed_check_l1_table()
177 check->result->check_errors++; in qed_check_l1_table()
186 * Check for unreferenced (leaked) clusters
188 static void qed_check_for_leaks(QEDCheck *check) in qed_check_for_leaks() argument
190 BDRVQEDState *s = check->s; in qed_check_for_leaks()
193 for (i = s->header.header_size; i < check->nclusters; i++) { in qed_check_for_leaks()
194 if (!qed_test_bit(check->used_clusters, i)) { in qed_check_for_leaks()
195 check->result->leaks++; in qed_check_for_leaks()
201 * Mark an image clean once it passes check or has been repaired
216 /* Ensure fixes reach storage before clearing check bit */ in qed_check_mark_clean()
226 QEDCheck check = { in qed_check() local
235 check.used_clusters = g_try_new0(uint32_t, (check.nclusters + 31) / 32); in qed_check()
236 if (check.nclusters && check.used_clusters == NULL) { in qed_check()
240 check.result->bfi.total_clusters = in qed_check()
242 ret = qed_check_l1_table(&check, s->l1_table); in qed_check()
244 /* Only check for leaks if entire image was scanned successfully */ in qed_check()
245 qed_check_for_leaks(&check); in qed_check()
252 g_free(check.used_clusters); in qed_check()