On 07/21/2017 06:00 PM, Mikulas Patocka wrote: > This is a patch to count errors in dm-integrity - as Jon suggested. > > This patch changes dm-integrity so that it counts the number of checksum > failures and reports the counter in the status line. Please increase minor target version when adding such table/status feature. I see it is queued for the next kernel so still possibility to fix it. (You will save me another hack in libcryptsetup when detecting availability of this feature :-) Thanks! Milan > > Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx> > > --- > drivers/md/dm-integrity.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > Index: linux-2.6/drivers/md/dm-integrity.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-integrity.c > +++ linux-2.6/drivers/md/dm-integrity.c > @@ -225,6 +225,8 @@ struct dm_integrity_c { > struct alg_spec internal_hash_alg; > struct alg_spec journal_crypt_alg; > struct alg_spec journal_mac_alg; > + > + atomic64_t number_of_mismatches; > }; > > struct dm_integrity_range { > @@ -309,6 +311,8 @@ static void dm_integrity_dtr(struct dm_t > > 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)) > DMERR("Error on %s: %d", msg, err); > } > @@ -1273,6 +1277,7 @@ again: > DMERR("Checksum failed at sector 0x%llx", > (unsigned long long)(sector - ((r + ic->tag_size - 1) / ic->tag_size))); > r = -EILSEQ; > + atomic64_inc(&ic->number_of_mismatches); > } > if (likely(checksums != checksums_onstack)) > kfree(checksums); > @@ -2222,7 +2227,7 @@ static void dm_integrity_status(struct d > > switch (type) { > case STATUSTYPE_INFO: > - result[0] = '\0'; > + DMEMIT("%llu", (unsigned long long)atomic64_read(&ic->number_of_mismatches)); > break; > > case STATUSTYPE_TABLE: { > @@ -2795,6 +2800,7 @@ static int dm_integrity_ctr(struct dm_ta > bio_list_init(&ic->flush_bio_list); > init_waitqueue_head(&ic->copy_to_journal_wait); > 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); > if (r) { > -- dm-devel mailing list dm-devel@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/dm-devel