aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2011-08-02 07:32:01 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-08-02 07:32:01 -0400
commit936688d7eb0f39be96c5791be1a04994cc8d6aa0 (patch)
tree4001f52284d39f5353174096e76b357f52ee2fb7 /drivers/md
parent283a8328ca5b987e547848de8ff0e28edcfb9e08 (diff)
dm table: fix discard support
Remove 'discards_supported' from the dm_table structure. The same information can be easily discovered from the table's target(s) in dm_table_supports_discards(). Before this fix dm_table_supports_discards() would skip checking the individual targets' 'discards_supported' flag if any one target in the table didn't set num_discard_requests > 0. Now the per-target 'discards_supported' flag is effective at insuring the final DM device advertises discard support. But, to be clear, targets that don't support discards (!num_discard_requests) will not receive discard requests. Also DMWARN if a target sets 'discards_supported' override but forgets to set 'num_discard_requests'. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-table.c15
-rw-r--r--drivers/md/dm.c3
2 files changed, 9 insertions, 9 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index bfe9c2333cea..3909fa259f55 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -54,7 +54,6 @@ struct dm_table {
54 sector_t *highs; 54 sector_t *highs;
55 struct dm_target *targets; 55 struct dm_target *targets;
56 56
57 unsigned discards_supported:1;
58 unsigned integrity_supported:1; 57 unsigned integrity_supported:1;
59 58
60 /* 59 /*
@@ -209,7 +208,6 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
209 INIT_LIST_HEAD(&t->devices); 208 INIT_LIST_HEAD(&t->devices);
210 INIT_LIST_HEAD(&t->target_callbacks); 209 INIT_LIST_HEAD(&t->target_callbacks);
211 atomic_set(&t->holders, 0); 210 atomic_set(&t->holders, 0);
212 t->discards_supported = 1;
213 211
214 if (!num_targets) 212 if (!num_targets)
215 num_targets = KEYS_PER_NODE; 213 num_targets = KEYS_PER_NODE;
@@ -791,8 +789,9 @@ int dm_table_add_target(struct dm_table *t, const char *type,
791 789
792 t->highs[t->num_targets++] = tgt->begin + tgt->len - 1; 790 t->highs[t->num_targets++] = tgt->begin + tgt->len - 1;
793 791
794 if (!tgt->num_discard_requests) 792 if (!tgt->num_discard_requests && tgt->discards_supported)
795 t->discards_supported = 0; 793 DMWARN("%s: %s: ignoring discards_supported because num_discard_requests is zero.",
794 dm_device_name(t->md), type);
796 795
797 return 0; 796 return 0;
798 797
@@ -1359,19 +1358,19 @@ bool dm_table_supports_discards(struct dm_table *t)
1359 struct dm_target *ti; 1358 struct dm_target *ti;
1360 unsigned i = 0; 1359 unsigned i = 0;
1361 1360
1362 if (!t->discards_supported)
1363 return 0;
1364
1365 /* 1361 /*
1366 * Unless any target used by the table set discards_supported, 1362 * Unless any target used by the table set discards_supported,
1367 * require at least one underlying device to support discards. 1363 * require at least one underlying device to support discards.
1368 * t->devices includes internal dm devices such as mirror logs 1364 * t->devices includes internal dm devices such as mirror logs
1369 * so we need to use iterate_devices here, which targets 1365 * so we need to use iterate_devices here, which targets
1370 * supporting discard must provide. 1366 * supporting discard selectively must provide.
1371 */ 1367 */
1372 while (i < dm_table_get_num_targets(t)) { 1368 while (i < dm_table_get_num_targets(t)) {
1373 ti = dm_table_get_target(t, i++); 1369 ti = dm_table_get_target(t, i++);
1374 1370
1371 if (!ti->num_discard_requests)
1372 continue;
1373
1375 if (ti->discards_supported) 1374 if (ti->discards_supported)
1376 return 1; 1375 return 1;
1377 1376
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 41abc6dd481b..aeb0fa1ccfe4 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1179,7 +1179,8 @@ static int __clone_and_map_discard(struct clone_info *ci)
1179 1179
1180 /* 1180 /*
1181 * Even though the device advertised discard support, 1181 * Even though the device advertised discard support,
1182 * reconfiguration might have changed that since the 1182 * that does not mean every target supports it, and
1183 * reconfiguration might also have changed that since the
1183 * check was performed. 1184 * check was performed.
1184 */ 1185 */
1185 if (!ti->num_discard_requests) 1186 if (!ti->num_discard_requests)