diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2017-07-21 12:00:00 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-08-28 11:47:17 -0400 |
commit | 3f2e539359bd0e709eb35127dc04df6bf8c3e8de (patch) | |
tree | 61a07d683211e04f852c3e1b7b4e9fe9c3852996 | |
parent | 1e3b21c6fb671a5ce9d77a05a8bde805d8908467 (diff) |
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>
-rw-r--r-- | drivers/md/dm-integrity.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 689f89d8eeef..47fd409b2e2a 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c | |||
@@ -225,6 +225,8 @@ struct dm_integrity_c { | |||
225 | struct alg_spec internal_hash_alg; | 225 | struct alg_spec internal_hash_alg; |
226 | struct alg_spec journal_crypt_alg; | 226 | struct alg_spec journal_crypt_alg; |
227 | struct alg_spec journal_mac_alg; | 227 | struct alg_spec journal_mac_alg; |
228 | |||
229 | atomic64_t number_of_mismatches; | ||
228 | }; | 230 | }; |
229 | 231 | ||
230 | struct dm_integrity_range { | 232 | struct dm_integrity_range { |
@@ -309,6 +311,8 @@ static void dm_integrity_dtr(struct dm_target *ti); | |||
309 | 311 | ||
310 | static void dm_integrity_io_error(struct dm_integrity_c *ic, const char *msg, int err) | 312 | static void dm_integrity_io_error(struct dm_integrity_c *ic, const char *msg, int err) |
311 | { | 313 | { |
314 | if (err == -EILSEQ) | ||
315 | atomic64_inc(&ic->number_of_mismatches); | ||
312 | if (!cmpxchg(&ic->failed, 0, err)) | 316 | if (!cmpxchg(&ic->failed, 0, err)) |
313 | DMERR("Error on %s: %d", msg, err); | 317 | DMERR("Error on %s: %d", msg, err); |
314 | } | 318 | } |
@@ -1273,6 +1277,7 @@ again: | |||
1273 | DMERR("Checksum failed at sector 0x%llx", | 1277 | DMERR("Checksum failed at sector 0x%llx", |
1274 | (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size))); | 1278 | (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size))); |
1275 | r = -EILSEQ; | 1279 | r = -EILSEQ; |
1280 | atomic64_inc(&ic->number_of_mismatches); | ||
1276 | } | 1281 | } |
1277 | if (likely(checksums != checksums_onstack)) | 1282 | if (likely(checksums != checksums_onstack)) |
1278 | kfree(checksums); | 1283 | kfree(checksums); |
@@ -2230,7 +2235,7 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type, | |||
2230 | 2235 | ||
2231 | switch (type) { | 2236 | switch (type) { |
2232 | case STATUSTYPE_INFO: | 2237 | case STATUSTYPE_INFO: |
2233 | result[0] = '\0'; | 2238 | DMEMIT("%llu", (unsigned long long)atomic64_read(&ic->number_of_mismatches)); |
2234 | break; | 2239 | break; |
2235 | 2240 | ||
2236 | case STATUSTYPE_TABLE: { | 2241 | case STATUSTYPE_TABLE: { |
@@ -2803,6 +2808,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
2803 | bio_list_init(&ic->flush_bio_list); | 2808 | bio_list_init(&ic->flush_bio_list); |
2804 | init_waitqueue_head(&ic->copy_to_journal_wait); | 2809 | init_waitqueue_head(&ic->copy_to_journal_wait); |
2805 | init_completion(&ic->crypto_backoff); | 2810 | init_completion(&ic->crypto_backoff); |
2811 | atomic64_set(&ic->number_of_mismatches, 0); | ||
2806 | 2812 | ||
2807 | r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ic->dev); | 2813 | r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ic->dev); |
2808 | if (r) { | 2814 | if (r) { |
@@ -3199,7 +3205,7 @@ static void dm_integrity_dtr(struct dm_target *ti) | |||
3199 | 3205 | ||
3200 | static struct target_type integrity_target = { | 3206 | static struct target_type integrity_target = { |
3201 | .name = "integrity", | 3207 | .name = "integrity", |
3202 | .version = {1, 0, 0}, | 3208 | .version = {1, 1, 0}, |
3203 | .module = THIS_MODULE, | 3209 | .module = THIS_MODULE, |
3204 | .features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY, | 3210 | .features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY, |
3205 | .ctr = dm_integrity_ctr, | 3211 | .ctr = dm_integrity_ctr, |