mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dm-verity: skip verity_handle_err on I/O errors for metadata
@ 2025-02-08 23:19 Akilesh Kailash
  2025-02-10 15:02 ` Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Akilesh Kailash @ 2025-02-08 23:19 UTC (permalink / raw)
  To: Mikulas Patocka, Sami Tolvanen
  Cc: akailash, kernel-team, Alasdair Kergon, Mike Snitzer, dm-devel,
	linux-kernel

Handle I/O error for metadata blocks if FEC correction fails.
This is similar to handling I/O error for data blocks:
'commit 2c0468e054c0 ("dm verity: skip redundant verity_handle_err()
on I/O errors")'

Fixes: 2c0468e054c0 ("dm verity: skip redundant verity_handle_err()
on I/O errors")
Signed-off-by: Akilesh Kailash <akailash@google.com>
---

Note: This patch should have been included in the data block fix patch.
A "fixes" tag has been added to address this.
Link: https://lore.kernel.org/all/20210913092642.3237796-1-akailash@google.com/
---
 drivers/md/dm-verity-target.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index e86c1431b108..e1ce3b256f0a 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -353,16 +353,26 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
 		} else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_METADATA,
 					     hash_block, data) == 0)
 			aux->hash_verified = 1;
-		else if (verity_handle_err(v,
+		else {
+			if (bio->bi_status) {
+				/*
+				 * Error correction failed; Just return error
+				 */
+				r = -EIO;
+				goto release_ret_r;
+			}
+			if (verity_handle_err(v,
 					   DM_VERITY_BLOCK_TYPE_METADATA,
 					   hash_block)) {
-			struct bio *bio;
-			io->had_mismatch = true;
-			bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
-			dm_audit_log_bio(DM_MSG_PREFIX, "verify-metadata", bio,
+				struct bio *bio;
+
+				io->had_mismatch = true;
+				bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
+				dm_audit_log_bio(DM_MSG_PREFIX, "verify-metadata", bio,
 					 block, 0);
-			r = -EIO;
-			goto release_ret_r;
+				r = -EIO;
+				goto release_ret_r;
+			}
 		}
 	}
 
-- 
2.48.1.502.g6dc24dfdaf-goog


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

* Re: [PATCH] dm-verity: skip verity_handle_err on I/O errors for metadata
  2025-02-08 23:19 [PATCH] dm-verity: skip verity_handle_err on I/O errors for metadata Akilesh Kailash
@ 2025-02-10 15:02 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2025-02-10 15:02 UTC (permalink / raw)
  To: Akilesh Kailash
  Cc: Sami Tolvanen, kernel-team, Alasdair Kergon, Mike Snitzer,
	dm-devel, linux-kernel

Hi

This doesn't seem correct - bio->bi_status is not set at a place where you 
are testing it.

If metadata I/O fails, the code goes down this branch "if (IS_ERR(data)) 
return PTR_ERR(data);" in verity_verify_level - i.e. it doesn't reach the 
piece that your patch is modifying.

I am sending a next patch (untested) that does forward error correction 
for metadata I/O failures.

Mikulas


On Sat, 8 Feb 2025, Akilesh Kailash wrote:

> Handle I/O error for metadata blocks if FEC correction fails.
> This is similar to handling I/O error for data blocks:
> 'commit 2c0468e054c0 ("dm verity: skip redundant verity_handle_err()
> on I/O errors")'
> 
> Fixes: 2c0468e054c0 ("dm verity: skip redundant verity_handle_err()
> on I/O errors")
> Signed-off-by: Akilesh Kailash <akailash@google.com>
> ---
> 
> Note: This patch should have been included in the data block fix patch.
> A "fixes" tag has been added to address this.
> Link: https://lore.kernel.org/all/20210913092642.3237796-1-akailash@google.com/
> ---
>  drivers/md/dm-verity-target.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index e86c1431b108..e1ce3b256f0a 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c
> @@ -353,16 +353,26 @@ static int verity_verify_level(struct dm_verity *v, struct dm_verity_io *io,
>  		} else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_METADATA,
>  					     hash_block, data) == 0)
>  			aux->hash_verified = 1;
> -		else if (verity_handle_err(v,
> +		else {
> +			if (bio->bi_status) {
> +				/*
> +				 * Error correction failed; Just return error
> +				 */
> +				r = -EIO;
> +				goto release_ret_r;
> +			}
> +			if (verity_handle_err(v,
>  					   DM_VERITY_BLOCK_TYPE_METADATA,
>  					   hash_block)) {
> -			struct bio *bio;
> -			io->had_mismatch = true;
> -			bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
> -			dm_audit_log_bio(DM_MSG_PREFIX, "verify-metadata", bio,
> +				struct bio *bio;
> +
> +				io->had_mismatch = true;
> +				bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
> +				dm_audit_log_bio(DM_MSG_PREFIX, "verify-metadata", bio,
>  					 block, 0);
> -			r = -EIO;
> -			goto release_ret_r;
> +				r = -EIO;
> +				goto release_ret_r;
> +			}
>  		}
>  	}
>  
> -- 
> 2.48.1.502.g6dc24dfdaf-goog
> 


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

end of thread, other threads:[~2025-02-10 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-08 23:19 [PATCH] dm-verity: skip verity_handle_err on I/O errors for metadata Akilesh Kailash
2025-02-10 15:02 ` Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®