Commit 3f2e5393 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

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: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 1e3b21c6
...@@ -225,6 +225,8 @@ struct dm_integrity_c { ...@@ -225,6 +225,8 @@ struct dm_integrity_c {
struct alg_spec internal_hash_alg; struct alg_spec internal_hash_alg;
struct alg_spec journal_crypt_alg; struct alg_spec journal_crypt_alg;
struct alg_spec journal_mac_alg; struct alg_spec journal_mac_alg;
atomic64_t number_of_mismatches;
}; };
struct dm_integrity_range { struct dm_integrity_range {
...@@ -309,6 +311,8 @@ static void dm_integrity_dtr(struct dm_target *ti); ...@@ -309,6 +311,8 @@ static void dm_integrity_dtr(struct dm_target *ti);
static void dm_integrity_io_error(struct dm_integrity_c *ic, const char *msg, int err) static void dm_integrity_io_error(struct dm_integrity_c *ic, const char *msg, int err)
{ {
if (err == -EILSEQ)
atomic64_inc(&ic->number_of_mismatches);
if (!cmpxchg(&ic->failed, 0, err)) if (!cmpxchg(&ic->failed, 0, err))
DMERR("Error on %s: %d", msg, err); DMERR("Error on %s: %d", msg, err);
} }
...@@ -1273,6 +1277,7 @@ static void integrity_metadata(struct work_struct *w) ...@@ -1273,6 +1277,7 @@ static void integrity_metadata(struct work_struct *w)
DMERR("Checksum failed at sector 0x%llx", DMERR("Checksum failed at sector 0x%llx",
(unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size))); (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size)));
r = -EILSEQ; r = -EILSEQ;
atomic64_inc(&ic->number_of_mismatches);
} }
if (likely(checksums != checksums_onstack)) if (likely(checksums != checksums_onstack))
kfree(checksums); kfree(checksums);
...@@ -2230,7 +2235,7 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type, ...@@ -2230,7 +2235,7 @@ static void dm_integrity_status(struct dm_target *ti, status_type_t type,
switch (type) { switch (type) {
case STATUSTYPE_INFO: case STATUSTYPE_INFO:
result[0] = '\0'; DMEMIT("%llu", (unsigned long long)atomic64_read(&ic->number_of_mismatches));
break; break;
case STATUSTYPE_TABLE: { case STATUSTYPE_TABLE: {
...@@ -2803,6 +2808,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -2803,6 +2808,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
bio_list_init(&ic->flush_bio_list); bio_list_init(&ic->flush_bio_list);
init_waitqueue_head(&ic->copy_to_journal_wait); init_waitqueue_head(&ic->copy_to_journal_wait);
init_completion(&ic->crypto_backoff); init_completion(&ic->crypto_backoff);
atomic64_set(&ic->number_of_mismatches, 0);
r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ic->dev); r = dm_get_device(ti, argv[0], dm_table_get_mode(ti->table), &ic->dev);
if (r) { if (r) {
...@@ -3199,7 +3205,7 @@ static void dm_integrity_dtr(struct dm_target *ti) ...@@ -3199,7 +3205,7 @@ static void dm_integrity_dtr(struct dm_target *ti)
static struct target_type integrity_target = { static struct target_type integrity_target = {
.name = "integrity", .name = "integrity",
.version = {1, 0, 0}, .version = {1, 1, 0},
.module = THIS_MODULE, .module = THIS_MODULE,
.features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY, .features = DM_TARGET_SINGLETON | DM_TARGET_INTEGRITY,
.ctr = dm_integrity_ctr, .ctr = dm_integrity_ctr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment