Skip to content

Commit 40ed054

Browse files
bmarzinsMikulas Patocka
authored andcommitted
dm-flakey: error all IOs when num_features is absent
dm-flakey would error all IOs if num_features was 0, but if it was absent, dm-flakey would never error any IO. Fix this so that no num_features works the same as num_features set to 0. Fixes: aa7d7bc ("dm flakey: add an "error_reads" option") Reported-by: Kent Overstreet <kent.overstreet@linux.dev> Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent 19da6b2 commit 40ed054

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/md/dm-flakey.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ struct per_bio_data {
5353
static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
5454
struct dm_target *ti)
5555
{
56-
int r;
57-
unsigned int argc;
56+
int r = 0;
57+
unsigned int argc = 0;
5858
const char *arg_name;
5959

6060
static const struct dm_arg _args[] = {
@@ -65,14 +65,13 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
6565
{0, PROBABILITY_BASE, "Invalid random corrupt argument"},
6666
};
6767

68-
/* No feature arguments supplied. */
69-
if (!as->argc)
70-
return 0;
71-
72-
r = dm_read_arg_group(_args, as, &argc, &ti->error);
73-
if (r)
68+
if (as->argc && (r = dm_read_arg_group(_args, as, &argc, &ti->error)))
7469
return r;
7570

71+
/* No feature arguments supplied. */
72+
if (!argc)
73+
goto error_all_io;
74+
7675
while (argc) {
7776
arg_name = dm_shift_arg(as);
7877
argc--;
@@ -232,6 +231,7 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
232231
if (!fc->corrupt_bio_byte && !test_bit(ERROR_READS, &fc->flags) &&
233232
!test_bit(DROP_WRITES, &fc->flags) && !test_bit(ERROR_WRITES, &fc->flags) &&
234233
!fc->random_read_corrupt && !fc->random_write_corrupt) {
234+
error_all_io:
235235
set_bit(ERROR_WRITES, &fc->flags);
236236
set_bit(ERROR_READS, &fc->flags);
237237
}

0 commit comments

Comments
 (0)