* [PATCH] dm-verity: skip verity_handle_error on I/O errors
@ 2021-09-13 9:26 ` Akilesh Kailash
0 siblings, 0 replies; 4+ messages in thread
From: Akilesh Kailash @ 2021-09-13 9:26 UTC (permalink / raw)
Cc: akailash, samitolvanen, kernel-team, Alasdair Kergon,
Mike Snitzer, dm-devel, linux-kernel
If there is an I/O error and FEC correction fails, return
an error instead of calling verity_handle_error().
Suggested-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Akilesh Kailash <akailash@google.com>
---
This was discussed in [1] by Sami Tolvanen but was
never implemented.
[1] https://lore.kernel.org/dm-devel/b004e7c7-f795-77ed-19b9-983785780e92@gmail.com/T/#mec4df1ba3f3cb63846875fb2bfc1f8b3100f31f1
drivers/md/dm-verity-target.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 22a5ac82446a..a6f7c452ee80 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -475,6 +475,7 @@ static int verity_verify_io(struct dm_verity_io *io)
struct bvec_iter start;
unsigned b;
struct crypto_wait wait;
+ struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
for (b = 0; b < io->n_blocks; b++) {
int r;
@@ -529,9 +530,17 @@ static int verity_verify_io(struct dm_verity_io *io)
else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA,
cur_block, NULL, &start) == 0)
continue;
- else if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
+ else {
+ if (bio->bi_status) {
+ /*
+ * Error correction failed; Just return error
+ */
+ return -EIO;
+ }
+ if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
cur_block))
- return -EIO;
+ return -EIO;
+ }
}
return 0;
--
2.33.0.309.g3052b89438-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [dm-devel] [PATCH] dm-verity: skip verity_handle_error on I/O errors
@ 2021-09-13 9:26 ` Akilesh Kailash
0 siblings, 0 replies; 4+ messages in thread
From: Akilesh Kailash @ 2021-09-13 9:26 UTC (permalink / raw)
Cc: Mike Snitzer, linux-kernel, dm-devel, samitolvanen, akailash,
kernel-team, Alasdair Kergon
If there is an I/O error and FEC correction fails, return
an error instead of calling verity_handle_error().
Suggested-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Akilesh Kailash <akailash@google.com>
---
This was discussed in [1] by Sami Tolvanen but was
never implemented.
[1] https://lore.kernel.org/dm-devel/b004e7c7-f795-77ed-19b9-983785780e92@gmail.com/T/#mec4df1ba3f3cb63846875fb2bfc1f8b3100f31f1
drivers/md/dm-verity-target.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
index 22a5ac82446a..a6f7c452ee80 100644
--- a/drivers/md/dm-verity-target.c
+++ b/drivers/md/dm-verity-target.c
@@ -475,6 +475,7 @@ static int verity_verify_io(struct dm_verity_io *io)
struct bvec_iter start;
unsigned b;
struct crypto_wait wait;
+ struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
for (b = 0; b < io->n_blocks; b++) {
int r;
@@ -529,9 +530,17 @@ static int verity_verify_io(struct dm_verity_io *io)
else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA,
cur_block, NULL, &start) == 0)
continue;
- else if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
+ else {
+ if (bio->bi_status) {
+ /*
+ * Error correction failed; Just return error
+ */
+ return -EIO;
+ }
+ if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
cur_block))
- return -EIO;
+ return -EIO;
+ }
}
return 0;
--
2.33.0.309.g3052b89438-goog
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dm-verity: skip verity_handle_error on I/O errors
2021-09-13 9:26 ` [dm-devel] " Akilesh Kailash
@ 2021-09-13 17:55 ` Sami Tolvanen
-1 siblings, 0 replies; 4+ messages in thread
From: Sami Tolvanen @ 2021-09-13 17:55 UTC (permalink / raw)
To: Akilesh Kailash
Cc: Android Kernel Team, Alasdair Kergon, Mike Snitzer,
device-mapper development, LKML
Hi Akilesh,
On Mon, Sep 13, 2021 at 2:27 AM Akilesh Kailash <akailash@google.com> wrote:
>
> If there is an I/O error and FEC correction fails, return
> an error instead of calling verity_handle_error().
>
> Suggested-by: Sami Tolvanen <samitolvanen@google.com>
> Signed-off-by: Akilesh Kailash <akailash@google.com>
> ---
> This was discussed in [1] by Sami Tolvanen but was
> never implemented.
>
> [1] https://lore.kernel.org/dm-devel/b004e7c7-f795-77ed-19b9-983785780e92@gmail.com/T/#mec4df1ba3f3cb63846875fb2bfc1f8b3100f31f1
Great, thanks for the patch!
> drivers/md/dm-verity-target.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index 22a5ac82446a..a6f7c452ee80 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c
> @@ -475,6 +475,7 @@ static int verity_verify_io(struct dm_verity_io *io)
> struct bvec_iter start;
> unsigned b;
> struct crypto_wait wait;
> + struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
>
> for (b = 0; b < io->n_blocks; b++) {
> int r;
> @@ -529,9 +530,17 @@ static int verity_verify_io(struct dm_verity_io *io)
> else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA,
> cur_block, NULL, &start) == 0)
> continue;
> - else if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
> + else {
> + if (bio->bi_status) {
> + /*
> + * Error correction failed; Just return error
> + */
> + return -EIO;
> + }
> + if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
> cur_block))
> - return -EIO;
> + return -EIO;
> + }
> }
>
> return 0;
This looks correct to me. A non-zero bio->bi_status here means that
FEC must be enabled because otherwise we wouldn't have ended up in
verity_verify_io() in the first place, and returning -EIO when
verity_fec_decode() fails after attempting to correct an I/O error is
consistent with the non-FEC behavior of dm-verity.
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Sami
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dm-devel] [PATCH] dm-verity: skip verity_handle_error on I/O errors
@ 2021-09-13 17:55 ` Sami Tolvanen
0 siblings, 0 replies; 4+ messages in thread
From: Sami Tolvanen @ 2021-09-13 17:55 UTC (permalink / raw)
To: Akilesh Kailash
Cc: device-mapper development, Android Kernel Team, Mike Snitzer,
Alasdair Kergon, LKML
Hi Akilesh,
On Mon, Sep 13, 2021 at 2:27 AM Akilesh Kailash <akailash@google.com> wrote:
>
> If there is an I/O error and FEC correction fails, return
> an error instead of calling verity_handle_error().
>
> Suggested-by: Sami Tolvanen <samitolvanen@google.com>
> Signed-off-by: Akilesh Kailash <akailash@google.com>
> ---
> This was discussed in [1] by Sami Tolvanen but was
> never implemented.
>
> [1] https://lore.kernel.org/dm-devel/b004e7c7-f795-77ed-19b9-983785780e92@gmail.com/T/#mec4df1ba3f3cb63846875fb2bfc1f8b3100f31f1
Great, thanks for the patch!
> drivers/md/dm-verity-target.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c
> index 22a5ac82446a..a6f7c452ee80 100644
> --- a/drivers/md/dm-verity-target.c
> +++ b/drivers/md/dm-verity-target.c
> @@ -475,6 +475,7 @@ static int verity_verify_io(struct dm_verity_io *io)
> struct bvec_iter start;
> unsigned b;
> struct crypto_wait wait;
> + struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_io_data_size);
>
> for (b = 0; b < io->n_blocks; b++) {
> int r;
> @@ -529,9 +530,17 @@ static int verity_verify_io(struct dm_verity_io *io)
> else if (verity_fec_decode(v, io, DM_VERITY_BLOCK_TYPE_DATA,
> cur_block, NULL, &start) == 0)
> continue;
> - else if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
> + else {
> + if (bio->bi_status) {
> + /*
> + * Error correction failed; Just return error
> + */
> + return -EIO;
> + }
> + if (verity_handle_err(v, DM_VERITY_BLOCK_TYPE_DATA,
> cur_block))
> - return -EIO;
> + return -EIO;
> + }
> }
>
> return 0;
This looks correct to me. A non-zero bio->bi_status here means that
FEC must be enabled because otherwise we wouldn't have ended up in
verity_verify_io() in the first place, and returning -EIO when
verity_fec_decode() fails after attempting to correct an I/O error is
consistent with the non-FEC behavior of dm-verity.
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Sami
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-13 17:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 9:26 [PATCH] dm-verity: skip verity_handle_error on I/O errors Akilesh Kailash
2021-09-13 9:26 ` [dm-devel] " Akilesh Kailash
2021-09-13 17:55 ` Sami Tolvanen
2021-09-13 17:55 ` [dm-devel] " Sami Tolvanen
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.