diff options
author | Mike Snitzer <snitzer@redhat.com> | 2011-05-29 07:52:55 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2011-05-29 07:52:55 -0400 |
commit | 4c2593270133708698d4b8cea2dab469479ad13b (patch) | |
tree | f408edef9145b2f9553cbb2142347fc79023c4ff | |
parent | 139f37f5e14cd883eee2a8a36289f544b5390a44 (diff) |
dm table: allow targets to support discards internally
Permit a target to support discards regardless of whether or not all its
underlying devices do.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm-table.c | 6 | ||||
-rw-r--r-- | include/linux/device-mapper.h | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index cb8380c9767f..215e112d153e 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
@@ -1346,7 +1346,8 @@ bool dm_table_supports_discards(struct dm_table *t) | |||
1346 | return 0; | 1346 | return 0; |
1347 | 1347 | ||
1348 | /* | 1348 | /* |
1349 | * Ensure that at least one underlying device supports discards. | 1349 | * Unless any target used by the table set discards_supported, |
1350 | * require at least one underlying device to support discards. | ||
1350 | * t->devices includes internal dm devices such as mirror logs | 1351 | * t->devices includes internal dm devices such as mirror logs |
1351 | * so we need to use iterate_devices here, which targets | 1352 | * so we need to use iterate_devices here, which targets |
1352 | * supporting discard must provide. | 1353 | * supporting discard must provide. |
@@ -1354,6 +1355,9 @@ bool dm_table_supports_discards(struct dm_table *t) | |||
1354 | while (i < dm_table_get_num_targets(t)) { | 1355 | while (i < dm_table_get_num_targets(t)) { |
1355 | ti = dm_table_get_target(t, i++); | 1356 | ti = dm_table_get_target(t, i++); |
1356 | 1357 | ||
1358 | if (ti->discards_supported) | ||
1359 | return 1; | ||
1360 | |||
1357 | if (ti->type->iterate_devices && | 1361 | if (ti->type->iterate_devices && |
1358 | ti->type->iterate_devices(ti, device_discard_capable, NULL)) | 1362 | ti->type->iterate_devices(ti, device_discard_capable, NULL)) |
1359 | return 1; | 1363 | return 1; |
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 32a4423710f5..4427e0454051 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h | |||
@@ -191,6 +191,12 @@ struct dm_target { | |||
191 | 191 | ||
192 | /* Used to provide an error string from the ctr */ | 192 | /* Used to provide an error string from the ctr */ |
193 | char *error; | 193 | char *error; |
194 | |||
195 | /* | ||
196 | * Set if this target needs to receive discards regardless of | ||
197 | * whether or not its underlying devices have support. | ||
198 | */ | ||
199 | unsigned discards_supported:1; | ||
194 | }; | 200 | }; |
195 | 201 | ||
196 | /* Each target can link one of these into the table */ | 202 | /* Each target can link one of these into the table */ |