dm integrity: count and display checksum failures

This changes DM integrity to count the number of checksum failures and
report the counter in response to STATUSTYPE_INFO request (via 'dmsetup
status').

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Mikulas Patocka and committed by
Mike Snitzer
3f2e5393 1e3b21c6

+8 -2
+8 -2
drivers/md/dm-integrity.c
··· 225 225 struct alg_spec internal_hash_alg; 226 226 struct alg_spec journal_crypt_alg; 227 227 struct alg_spec journal_mac_alg; 228 + 229 + atomic64_t number_of_mismatches; 228 230 }; 229 231 230 232 struct dm_integrity_range { ··· 311 309 312 310 static void dm_integrity_io_error(struct dm_integrity_c *ic, const char *msg, int err) 313 311 { 312 + if (err == -EILSEQ) 313 + atomic64_inc(&ic->number_of_mismatches); 314 314 if (!cmpxchg(&ic->failed, 0, err)) 315 315 DMERR("Error on %s: %d", msg, err); 316 316 } ··· 1277 1273 DMERR("Checksum failed at sector 0x%llx", 1278 1274 (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size))); 1279 1275 r = -EILSEQ; 1276 + atomic64_inc(&ic->number_of_mismatches); 1280 1277 } 1281 1278 if (likely(checksums != checksums_onstack)) 1282 1279 kfree(checksums); ··· 2235 2230 2236 2231 switch (type) { 2237 2232 case STATUSTYPE_INFO: 2238 - result[0] = '\0'; 2233 + DMEMIT("%llu", (unsigned long long)atomic64_read(&ic->number_of_mismatches)); 2239 2234 break; 2240 2235 2241 2236 case STATUSTYPE_TABLE: { ··· 2808 2803 bio_list_init(&ic->flush_bio_list); 2809 2804 init_waitqueue_head(&ic->copy_to_journal_wait); 2810 2805 init_completion(&ic->crypto_backoff); 2806 + atomic64_set(&ic->number_of_mismatches, 0); 2811 2807 2812 2808 r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ic->dev); 2813 2809 if (r) { ··· 3205 3199 3206 3200 static struct target_type integrity_target = { 3207 3201 .name = "integrity", 3208 - .version = {1, 0, 0}, 3202 + .version = {1, 1, 0}, 3209 3203 .module = THIS_MODULE, 3210 3204 .features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY, 3211 3205 .ctr = dm_integrity_ctr,