dm flakey: fix logic when corrupting a bio
authorMikulas Patocka <mpatocka@redhat.com>
Sun, 22 Jan 2023 19:03:56 +0000 (14:03 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:34:22 +0000 (09:34 +0100)
commitea603083f9d724fc703fd0f502532c0a726de327
treef5cecf22d2dc61bf7b8b7342f7707983c71c83fb
parentb57ba4e952506020bcf3f32f8d7fc0263d1f408b
dm flakey: fix logic when corrupting a bio

commit aa56b9b75996ff4c76a0a4181c2fa0206c3d91cc upstream.

If "corrupt_bio_byte" is set to corrupt reads and corrupt_bio_flags is
used, dm-flakey would erroneously return all writes as errors. Likewise,
if "corrupt_bio_byte" is set to corrupt writes, dm-flakey would return
errors for all reads.

Fix the logic so that if fc->corrupt_bio_byte is non-zero, dm-flakey
will not abort reads on writes with an error.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-flakey.c