Commit 6367f177 authored by Linus Torvalds's avatar Linus Torvalds

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
parents a7c56eba 983c7db3
...@@ -1698,6 +1698,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) ...@@ -1698,6 +1698,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
} }
ti->num_flush_requests = 1; ti->num_flush_requests = 1;
ti->discard_zeroes_data_unsupported = 1;
return 0; return 0;
bad: bad:
......
...@@ -81,8 +81,10 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc, ...@@ -81,8 +81,10 @@ static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
* corrupt_bio_byte <Nth_byte> <direction> <value> <bio_flags> * corrupt_bio_byte <Nth_byte> <direction> <value> <bio_flags>
*/ */
if (!strcasecmp(arg_name, "corrupt_bio_byte")) { if (!strcasecmp(arg_name, "corrupt_bio_byte")) {
if (!argc) if (!argc) {
ti->error = "Feature corrupt_bio_byte requires parameters"; ti->error = "Feature corrupt_bio_byte requires parameters";
return -EINVAL;
}
r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error);
if (r) if (r)
......
...@@ -449,7 +449,7 @@ static int parse_raid_params(struct raid_set *rs, char **argv, ...@@ -449,7 +449,7 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
rs->ti->error = "write_mostly option is only valid for RAID1"; rs->ti->error = "write_mostly option is only valid for RAID1";
return -EINVAL; return -EINVAL;
} }
if (value > rs->md.raid_disks) { if (value >= rs->md.raid_disks) {
rs->ti->error = "Invalid write_mostly drive index given"; rs->ti->error = "Invalid write_mostly drive index given";
return -EINVAL; return -EINVAL;
} }
......
...@@ -1238,14 +1238,15 @@ static void dm_table_set_integrity(struct dm_table *t) ...@@ -1238,14 +1238,15 @@ static void dm_table_set_integrity(struct dm_table *t)
return; return;
template_disk = dm_table_get_integrity_disk(t, true); template_disk = dm_table_get_integrity_disk(t, true);
if (!template_disk && if (template_disk)
blk_integrity_is_initialized(dm_disk(t->md))) { blk_integrity_register(dm_disk(t->md),
blk_get_integrity(template_disk));
else if (blk_integrity_is_initialized(dm_disk(t->md)))
DMWARN("%s: device no longer has a valid integrity profile", DMWARN("%s: device no longer has a valid integrity profile",
dm_device_name(t->md)); dm_device_name(t->md));
return; else
} DMWARN("%s: unable to establish an integrity profile",
blk_integrity_register(dm_disk(t->md), dm_device_name(t->md));
blk_get_integrity(template_disk));
} }
static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev, 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) ...@@ -1282,6 +1283,22 @@ static bool dm_table_supports_flush(struct dm_table *t, unsigned flush)
return 0; return 0;
} }
static bool dm_table_discard_zeroes_data(struct dm_table *t)
{
struct dm_target *ti;
unsigned i = 0;
/* Ensure that all targets supports discard_zeroes_data. */
while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);
if (ti->discard_zeroes_data_unsupported)
return 0;
}
return 1;
}
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
struct queue_limits *limits) struct queue_limits *limits)
{ {
...@@ -1304,6 +1321,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, ...@@ -1304,6 +1321,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
} }
blk_queue_flush(q, flush); blk_queue_flush(q, flush);
if (!dm_table_discard_zeroes_data(t))
q->limits.discard_zeroes_data = 0;
dm_table_set_integrity(t); dm_table_set_integrity(t);
/* /*
......
...@@ -197,6 +197,11 @@ struct dm_target { ...@@ -197,6 +197,11 @@ struct dm_target {
* whether or not its underlying devices have support. * whether or not its underlying devices have support.
*/ */
unsigned discards_supported:1; unsigned discards_supported:1;
/*
* Set if this target does not return zeroes on discarded blocks.
*/
unsigned discard_zeroes_data_unsupported:1;
}; };
/* Each target can link one of these into the table */ /* Each target can link one of these into the table */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment