All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-integrity: count failures
@ 2017-07-21 16:00 Mikulas Patocka
  2017-07-27 13:10 ` Milan Broz
  0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2017-07-21 16:00 UTC (permalink / raw)
  To: Mike Snitzer, Milan Broz, Jonathan Brassow; +Cc: dm-devel

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.

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

---
 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) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dm-integrity: count failures
  2017-07-21 16:00 [PATCH] dm-integrity: count failures Mikulas Patocka
@ 2017-07-27 13:10 ` Milan Broz
  2017-07-27 15:49   ` Mike Snitzer
  0 siblings, 1 reply; 3+ messages in thread
From: Milan Broz @ 2017-07-27 13:10 UTC (permalink / raw)
  To: Mikulas Patocka, Mike Snitzer, Jonathan Brassow; +Cc: dm-devel

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@redhat.com>
> 
> ---
>  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) {
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dm-integrity: count failures
  2017-07-27 13:10 ` Milan Broz
@ 2017-07-27 15:49   ` Mike Snitzer
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Snitzer @ 2017-07-27 15:49 UTC (permalink / raw)
  To: Milan Broz; +Cc: dm-devel, Mikulas Patocka

On Thu, Jul 27 2017 at  9:10am -0400,
Milan Broz <gmazyland@gmail.com> wrote:

> 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.

OK, I bumped the version from 1.0.0 to 1.1.0 and pushed to linux-next
for 4.14 inclusion.

Thanks,
Mike

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-27 15:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-21 16:00 [PATCH] dm-integrity: count failures Mikulas Patocka
2017-07-27 13:10 ` Milan Broz
2017-07-27 15:49   ` Mike Snitzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.