369
371
limits->logical_block_size >> SECTOR_SHIFT;
370
372
char b[BDEVNAME_SIZE];
375
* Some devices exist without request functions,
376
* such as loop devices not yet bound to backing files.
377
* Forbid the use of such devices.
379
q = bdev_get_queue(bdev);
380
if (!q || !q->make_request_fn) {
381
DMWARN("%s: %s is not yet initialised: "
382
"start=%llu, len=%llu, dev_size=%llu",
383
dm_device_name(ti->table->md), bdevname(bdev, b),
384
(unsigned long long)start,
385
(unsigned long long)len,
386
(unsigned long long)dev_size);
947
* Get a disk whose integrity profile reflects the table's profile.
948
* If %match_all is true, all devices' profiles must match.
949
* If %match_all is false, all devices must at least have an
950
* allocated integrity profile; but uninitialized is ok.
951
* Returns NULL if integrity support was inconsistent or unavailable.
953
static struct gendisk * dm_table_get_integrity_disk(struct dm_table *t,
956
struct list_head *devices = dm_table_get_devices(t);
957
struct dm_dev_internal *dd = NULL;
958
struct gendisk *prev_disk = NULL, *template_disk = NULL;
960
list_for_each_entry(dd, devices, list) {
961
template_disk = dd->dm_dev.bdev->bd_disk;
962
if (!blk_get_integrity(template_disk))
964
if (!match_all && !blk_integrity_is_initialized(template_disk))
965
continue; /* skip uninitialized profiles */
966
else if (prev_disk &&
967
blk_integrity_compare(prev_disk, template_disk) < 0)
969
prev_disk = template_disk;
972
return template_disk;
976
DMWARN("%s: integrity not set: %s and %s profile mismatch",
977
dm_device_name(t->md),
978
prev_disk->disk_name,
979
template_disk->disk_name);
929
984
* Register the mapped device for blk_integrity support if
930
* the underlying devices support it.
985
* the underlying devices have an integrity profile. But all devices
986
* may not have matching profiles (checking all devices isn't reliable
987
* during table load because this table may use other DM device(s) which
988
* must be resumed before they will have an initialized integity profile).
989
* Stacked DM devices force a 2 stage integrity profile validation:
990
* 1 - during load, validate all initialized integrity profiles match
991
* 2 - during resume, validate all integrity profiles match
932
993
static int dm_table_prealloc_integrity(struct dm_table *t, struct mapped_device *md)
934
struct list_head *devices = dm_table_get_devices(t);
935
struct dm_dev_internal *dd;
937
list_for_each_entry(dd, devices, list)
938
if (bdev_get_integrity(dd->dm_dev.bdev))
939
return blk_integrity_register(dm_disk(md), NULL);
995
struct gendisk *template_disk = NULL;
997
template_disk = dm_table_get_integrity_disk(t, false);
1001
if (!blk_integrity_is_initialized(dm_disk(md))) {
1002
t->integrity_supported = 1;
1003
return blk_integrity_register(dm_disk(md), NULL);
1007
* If DM device already has an initalized integrity
1008
* profile the new profile should not conflict.
1010
if (blk_integrity_is_initialized(template_disk) &&
1011
blk_integrity_compare(dm_disk(md), template_disk) < 0) {
1012
DMWARN("%s: conflict with existing integrity profile: "
1013
"%s profile mismatch",
1014
dm_device_name(t->md),
1015
template_disk->disk_name);
1019
/* Preserve existing initialized integrity profile */
1020
t->integrity_supported = 1;
1093
1173
* Set the integrity profile for this device if all devices used have
1094
* matching profiles.
1174
* matching profiles. We're quite deep in the resume path but still
1175
* don't know if all devices (particularly DM devices this device
1176
* may be stacked on) have matching profiles. Even if the profiles
1177
* don't match we have no way to fail (to resume) at this point.
1096
1179
static void dm_table_set_integrity(struct dm_table *t)
1098
struct list_head *devices = dm_table_get_devices(t);
1099
struct dm_dev_internal *prev = NULL, *dd = NULL;
1181
struct gendisk *template_disk = NULL;
1101
1183
if (!blk_get_integrity(dm_disk(t->md)))
1104
list_for_each_entry(dd, devices, list) {
1106
blk_integrity_compare(prev->dm_dev.bdev->bd_disk,
1107
dd->dm_dev.bdev->bd_disk) < 0) {
1108
DMWARN("%s: integrity not set: %s and %s mismatch",
1109
dm_device_name(t->md),
1110
prev->dm_dev.bdev->bd_disk->disk_name,
1111
dd->dm_dev.bdev->bd_disk->disk_name);
1186
template_disk = dm_table_get_integrity_disk(t, true);
1187
if (!template_disk &&
1188
blk_integrity_is_initialized(dm_disk(t->md))) {
1189
DMWARN("%s: device no longer has a valid integrity profile",
1190
dm_device_name(t->md));
1117
if (!prev || !bdev_get_integrity(prev->dm_dev.bdev))
1120
1193
blk_integrity_register(dm_disk(t->md),
1121
bdev_get_integrity(prev->dm_dev.bdev));
1126
blk_integrity_register(dm_disk(t->md), NULL);
1194
blk_get_integrity(template_disk));
1131
1197
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
1278
void dm_table_unplug_all(struct dm_table *t)
1280
struct dm_dev_internal *dd;
1281
struct list_head *devices = dm_table_get_devices(t);
1282
struct dm_target_callbacks *cb;
1284
list_for_each_entry(dd, devices, list) {
1285
struct request_queue *q = bdev_get_queue(dd->dm_dev.bdev);
1286
char b[BDEVNAME_SIZE];
1291
DMWARN_LIMIT("%s: Cannot unplug nonexistent device %s",
1292
dm_device_name(t->md),
1293
bdevname(dd->dm_dev.bdev, b));
1296
list_for_each_entry(cb, &t->target_callbacks, list)
1301
1344
struct mapped_device *dm_table_get_md(struct dm_table *t)