All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-devel] [PATCH 3/3] dm-flakey: fix logic when corruping a bio
@ 2023-01-22 19:03 Mikulas Patocka
  2023-01-23  5:11 ` Sweet Tea Dorminy
  0 siblings, 1 reply; 2+ messages in thread
From: Mikulas Patocka @ 2023-01-22 19:03 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: dm-devel

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

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

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
 drivers/md/dm-flakey.c |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Index: bcachefs/drivers/md/dm-flakey.c
===================================================================
--- bcachefs.orig/drivers/md/dm-flakey.c	2023-01-22 17:22:10.000000000 +0100
+++ bcachefs/drivers/md/dm-flakey.c	2023-01-22 17:22:10.000000000 +0100
@@ -365,9 +365,11 @@ static int flakey_map(struct dm_target *
 		/*
 		 * Corrupt matching writes.
 		 */
-		if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) {
-			if (all_corrupt_bio_flags_match(bio, fc))
-				corrupt_bio_data(bio, fc);
+		if (fc->corrupt_bio_byte) {
+			if ((fc->corrupt_bio_rw == WRITE)) {
+				if (all_corrupt_bio_flags_match(bio, fc))
+					corrupt_bio_data(bio, fc);
+			}
 			goto map_bio;
 		}
 
@@ -393,13 +395,14 @@ static int flakey_end_io(struct dm_targe
 		return DM_ENDIO_DONE;
 
 	if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
-		if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
-		    all_corrupt_bio_flags_match(bio, fc)) {
-			/*
-			 * Corrupt successful matching READs while in down state.
-			 */
-			corrupt_bio_data(bio, fc);
-
+		if (fc->corrupt_bio_byte) {
+			if ((fc->corrupt_bio_rw == READ) &&
+			    all_corrupt_bio_flags_match(bio, fc)) {
+				/*
+				 * Corrupt successful matching READs while in down state.
+				 */
+				corrupt_bio_data(bio, fc);
+			}
 		} else if (!test_bit(DROP_WRITES, &fc->flags) &&
 			   !test_bit(ERROR_WRITES, &fc->flags)) {
 			/*
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


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

* Re: [dm-devel] [PATCH 3/3] dm-flakey: fix logic when corruping a bio
  2023-01-22 19:03 [dm-devel] [PATCH 3/3] dm-flakey: fix logic when corruping a bio Mikulas Patocka
@ 2023-01-23  5:11 ` Sweet Tea Dorminy
  0 siblings, 0 replies; 2+ messages in thread
From: Sweet Tea Dorminy @ 2023-01-23  5:11 UTC (permalink / raw)
  To: dm-devel



On 1/22/23 14:03, Mikulas Patocka wrote:
> If "corrupt_bio_byte" is set to corrupt reads and corrupt_bio_flags is
> used, dm-flakey would errorneously return all writes as errors. Likewise,
                        ^erroneously^
> if "corrupt_bio_byte" is set to corrupt writes, dm-flakey would return
> errors for all reads.
> 
> This patch fixes the logic, so that if fc->corrupt_bio_byte is non-zero,
> dm-flakey would not abort reads on writes with an error.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> Cc: stable@vger.kernel.org
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
> 
> ---
>   drivers/md/dm-flakey.c |   23 +++++++++++++----------
>   1 file changed, 13 insertions(+), 10 deletions(-)
> 
> Index: bcachefs/drivers/md/dm-flakey.c
> ===================================================================
> --- bcachefs.orig/drivers/md/dm-flakey.c	2023-01-22 17:22:10.000000000 +0100
> +++ bcachefs/drivers/md/dm-flakey.c	2023-01-22 17:22:10.000000000 +0100
> @@ -365,9 +365,11 @@ static int flakey_map(struct dm_target *
>   		/*
>   		 * Corrupt matching writes.
>   		 */
> -		if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == WRITE)) {
> -			if (all_corrupt_bio_flags_match(bio, fc))
> -				corrupt_bio_data(bio, fc);
> +		if (fc->corrupt_bio_byte) {
> +			if ((fc->corrupt_bio_rw == WRITE)) {
> +				if (all_corrupt_bio_flags_match(bio, fc))
> +					corrupt_bio_data(bio, fc);
> +			}
>   			goto map_bio;
>   		}
>   
> @@ -393,13 +395,14 @@ static int flakey_end_io(struct dm_targe
>   		return DM_ENDIO_DONE;
>   
>   	if (!*error && pb->bio_submitted && (bio_data_dir(bio) == READ)) {
> -		if (fc->corrupt_bio_byte && (fc->corrupt_bio_rw == READ) &&
> -		    all_corrupt_bio_flags_match(bio, fc)) {
> -			/*
> -			 * Corrupt successful matching READs while in down state.
> -			 */
> -			corrupt_bio_data(bio, fc);
> -
> +		if (fc->corrupt_bio_byte) {
> +			if ((fc->corrupt_bio_rw == READ) &&
> +			    all_corrupt_bio_flags_match(bio, fc)) {
> +				/*
> +				 * Corrupt successful matching READs while in down state.
> +				 */
> +				corrupt_bio_data(bio, fc);
> +			}
>   		} else if (!test_bit(DROP_WRITES, &fc->flags) &&
>   			   !test_bit(ERROR_WRITES, &fc->flags)) {
>   			/*
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://listman.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


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

end of thread, other threads:[~2023-01-23  5:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-22 19:03 [dm-devel] [PATCH 3/3] dm-flakey: fix logic when corruping a bio Mikulas Patocka
2023-01-23  5:11 ` Sweet Tea Dorminy

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.