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

+37 -8
+2
drivers/md/dm-crypt.c
··· 1698 1698 } 1699 1699 1700 1700 ti->num_flush_requests = 1; 1701 + ti->discard_zeroes_data_unsupported = 1; 1702 + 1701 1703 return 0; 1702 1704 1703 1705 bad:
+3 -1
drivers/md/dm-flakey.c
··· 81 81 * corrupt_bio_byte <Nth_byte> <direction> <value> <bio_flags> 82 82 */ 83 83 if (!strcasecmp(arg_name, "corrupt_bio_byte")) { 84 - if (!argc) 84 + if (!argc) { 85 85 ti->error = "Feature corrupt_bio_byte requires parameters"; 86 + return -EINVAL; 87 + } 86 88 87 89 r = dm_read_arg(_args + 1, as, &fc->corrupt_bio_byte, &ti->error); 88 90 if (r)
+1 -1
drivers/md/dm-raid.c
··· 449 449 rs->ti->error = "write_mostly option is only valid for RAID1"; 450 450 return -EINVAL; 451 451 } 452 - if (value > rs->md.raid_disks) { 452 + if (value >= rs->md.raid_disks) { 453 453 rs->ti->error = "Invalid write_mostly drive index given"; 454 454 return -EINVAL; 455 455 }
+26 -6
drivers/md/dm-table.c
··· 1238 1238 return; 1239 1239 1240 1240 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))) 1243 1245 DMWARN("%s: device no longer has a valid integrity profile", 1244 1246 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)); 1249 1250 } 1250 1251 1251 1252 static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev, ··· 1283 1282 return 0; 1284 1283 } 1285 1284 1285 + static bool dm_table_discard_zeroes_data(struct dm_table *t) 1286 + { 1287 + struct dm_target *ti; 1288 + unsigned i = 0; 1289 + 1290 + /* Ensure that all targets supports discard_zeroes_data. */ 1291 + while (i < dm_table_get_num_targets(t)) { 1292 + ti = dm_table_get_target(t, i++); 1293 + 1294 + if (ti->discard_zeroes_data_unsupported) 1295 + return 0; 1296 + } 1297 + 1298 + return 1; 1299 + } 1300 + 1286 1301 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, 1287 1302 struct queue_limits *limits) 1288 1303 { ··· 1320 1303 flush |= REQ_FUA; 1321 1304 } 1322 1305 blk_queue_flush(q, flush); 1306 + 1307 + if (!dm_table_discard_zeroes_data(t)) 1308 + q->limits.discard_zeroes_data = 0; 1323 1309 1324 1310 dm_table_set_integrity(t); 1325 1311
+5
include/linux/device-mapper.h
··· 197 197 * whether or not its underlying devices have support. 198 198 */ 199 199 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; 200 205 }; 201 206 202 207 /* Each target can link one of these into the table */