Skip to contentSkip to conversation

dm-flakey: Fix corrupt_bio_byte setup checks

PATCH Applied Kent Overstreet 3 participants 5 messages Jun 11, 2025 – Jun 23, 2025 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-flakey: Fix corrupt_bio_byte setup checks

Fix the error_reads mode - it's incompatible with corrupt_bio_byte, but that's only enabled if corrupt_bio_byte is nonzero.

Cc Benjamin Marzinski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Mike Snitzer <[email protected]>
---
 drivers/md/dm-flakey.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/dm-flakey.c +6 -3
index c711db6f8f5c..cf17fd46e255 100644
@@ -215,16 +215,19 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
 	}
 
 	if (test_bit(DROP_WRITES, &fc->flags) &&
-	    (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+	    ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+	     fc->random_write_corrupt)) {
 		ti->error = "drop_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 
 	} else if (test_bit(ERROR_WRITES, &fc->flags) &&
-		   (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+		    fc->random_write_corrupt)) {
 		ti->error = "error_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 	} else if (test_bit(ERROR_READS, &fc->flags) &&
-		   (fc->corrupt_bio_rw == READ || fc->random_read_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == READ) ||
+		    fc->random_read_corrupt)) {
 		ti->error = "error_reads is incompatible with random_read_corrupt or corrupt_bio_byte with the READ flag set";
 		return -EINVAL;
 	}
Signature · 1 line
2.49.0
#1 lore raw
Quoted 8 lines · Kent Overstreet

Fix the error_reads mode - it's incompatible with corrupt_bio_byte, but that's only enabled if corrupt_bio_byte is nonzero.

Cc Benjamin Marzinski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Mike Snitzer <[email protected]>

Also, I see that you guys still aren't testing your changes properly.

Quoted 34 lines
---
 drivers/md/dm-flakey.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/dm-flakey.c +6 -3
index c711db6f8f5c..cf17fd46e255 100644
@@ -215,16 +215,19 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
 	}
 
 	if (test_bit(DROP_WRITES, &fc->flags) &&
-	    (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+	    ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+	     fc->random_write_corrupt)) {
 		ti->error = "drop_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 
 	} else if (test_bit(ERROR_WRITES, &fc->flags) &&
-		   (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+		    fc->random_write_corrupt)) {
 		ti->error = "error_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 	} else if (test_bit(ERROR_READS, &fc->flags) &&
-		   (fc->corrupt_bio_rw == READ || fc->random_read_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == READ) ||
+		    fc->random_read_corrupt)) {
 		ti->error = "error_reads is incompatible with random_read_corrupt or corrupt_bio_byte with the READ flag set";
 		return -EINVAL;
 	}
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Kent Overstreet
Quoted 8 lines · Kent Overstreet

Fix the error_reads mode - it's incompatible with corrupt_bio_byte, but that's only enabled if corrupt_bio_byte is nonzero.

Cc Benjamin Marzinski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Mike Snitzer <[email protected]>
#3 lore raw
In reply to Kent Overstreet
Quoted 8 lines · Kent Overstreet

Fix the error_reads mode - it's incompatible with corrupt_bio_byte, but that's only enabled if corrupt_bio_byte is nonzero.

Cc Benjamin Marzinski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Mike Snitzer <[email protected]>

This commit header should include:

Fixes 19da6b2c9e8e ("dm-flakey: Clean up parsing messages")

So that it gets picked up by the stable kernel.

-Ben

Quoted 33 lines
---
 drivers/md/dm-flakey.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/md/dm-flakey.c +6 -3
index c711db6f8f5c..cf17fd46e255 100644
@@ -215,16 +215,19 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
 	}
 
 	if (test_bit(DROP_WRITES, &fc->flags) &&
-	    (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+	    ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+	     fc->random_write_corrupt)) {
 		ti->error = "drop_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 
 	} else if (test_bit(ERROR_WRITES, &fc->flags) &&
-		   (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == WRITE) ||
+		    fc->random_write_corrupt)) {
 		ti->error = "error_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set";
 		return -EINVAL;
 	} else if (test_bit(ERROR_READS, &fc->flags) &&
-		   (fc->corrupt_bio_rw == READ || fc->random_read_corrupt)) {
+		   ((fc->corrupt_bio_byte && fc->corrupt_bio_rw == READ) ||
+		    fc->random_read_corrupt)) {
 		ti->error = "error_reads is incompatible with random_read_corrupt or corrupt_bio_byte with the READ flag set";
 		return -EINVAL;
 	}
Signature · 1 line
2.49.0
maintainer Applied
#4 lore raw
Quoted 10 lines · Benjamin Marzinski
Quoted 8 lines · Kent Overstreet

Fix the error_reads mode - it's incompatible with corrupt_bio_byte, but that's only enabled if corrupt_bio_byte is nonzero.

Cc Benjamin Marzinski <[email protected]>
Cc Mikulas Patocka <[email protected]>
Cc Mike Snitzer <[email protected]>
Quoted 7 lines

This commit header should include:

Fixes 19da6b2c9e8e ("dm-flakey: Clean up parsing messages")

So that it gets picked up by the stable kernel.

-Ben

I've applied the patch, thanks.

Mikulas