Skip to content

Commit 6367f17

Browse files
committed
Merge branch 'for-linus' of http://people.redhat.com/agk/git/linux-dm
* 'for-linus' of http://people.redhat.com/agk/git/linux-dm: dm crypt: always disable discard_zeroes_data dm: raid fix write_mostly arg validation dm table: avoid crash if integrity profile changes dm: flakey fix corrupt_bio_byte error path
2 parents a7c56eb + 983c7db commit 6367f17

5 files changed

Lines changed: 37 additions & 8 deletions

File tree

drivers/md/dm-crypt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
16981698
}
16991699

17001700
ti->num_flush_requests = 1;
1701+
ti->discard_zeroes_data_unsupported = 1;
1702+
17011703
return 0;
17021704

17031705
bad:

drivers/md/dm-flakey.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
8181
* corrupt_bio_byte <Nth_byte> <direction> <value> <bio_flags>
8282
*/
8383
if (!strcasecmp(arg_name, "corrupt_bio_byte")) {
84-
if (!argc)
84+
if (!argc) {
8585
ti->error = "Feature corrupt_bio_byte requires parameters";
86+
return -EINVAL;
87+
}
8688

8789
r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error);
8890
if (r)

drivers/md/dm-raid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
449449
rs->ti->error = "write_mostly option is only valid for RAID1";
450450
return -EINVAL;
451451
}
452-
if (value > rs->md.raid_disks) {
452+
if (value >= rs->md.raid_disks) {
453453
rs->ti->error = "Invalid write_mostly drive index given";
454454
return -EINVAL;
455455
}

drivers/md/dm-table.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,14 +1238,15 @@ static void dm_table_set_integrity(struct dm_table *t)
12381238
return;
12391239

12401240
template_disk = dm_table_get_integrity_disk(t, true);
1241-
if (!template_disk &&
1242-
blk_integrity_is_initialized(dm_disk(t->md))) {
1241+
if (template_disk)
1242+
blk_integrity_register(dm_disk(t->md),
1243+
blk_get_integrity(template_disk));
1244+
else if (blk_integrity_is_initialized(dm_disk(t->md)))
12431245
DMWARN("%s: device no longer has a valid integrity profile",
12441246
dm_device_name(t->md));
1245-
return;
1246-
}
1247-
blk_integrity_register(dm_disk(t->md),
1248-
blk_get_integrity(template_disk));
1247+
else
1248+
DMWARN("%s: unable to establish an integrity profile",
1249+
dm_device_name(t->md));
12491250
}
12501251

12511252
static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev,
@@ -1282,6 +1283,22 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned flush)
12821283
return 0;
12831284
}
12841285

1286+
static bool dm_table_discard_zeroes_data(struct dm_table *t)
1287+
{
1288+
struct dm_target *ti;
1289+
unsigned i = 0;
1290+
1291+
/* Ensure that all targets supports discard_zeroes_data. */
1292+
while (i < dm_table_get_num_targets(t)) {
1293+
ti = dm_table_get_target(t, i++);
1294+
1295+
if (ti->discard_zeroes_data_unsupported)
1296+
return 0;
1297+
}
1298+
1299+
return 1;
1300+
}
1301+
12851302
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
12861303
struct queue_limits *limits)
12871304
{
@@ -1304,6 +1321,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
13041321
}
13051322
blk_queue_flush(q, flush);
13061323

1324+
if (!dm_table_discard_zeroes_data(t))
1325+
q->limits.discard_zeroes_data = 0;
1326+
13071327
dm_table_set_integrity(t);
13081328

13091329
/*

include/linux/device-mapper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ struct dm_target {
197197
* whether or not its underlying devices have support.
198198
*/
199199
unsigned discards_supported:1;
200+
201+
/*
202+
* Set if this target does not return zeroes on discarded blocks.
203+
*/
204+
unsigned discard_zeroes_data_unsupported:1;
200205
};
201206

202207
/* Each target can link one of these into the table */

0 commit comments

Comments
 (0)