Skip to content

Commit

Permalink
dm table: allow targets to support discards internally
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed May 29, 2011
1 parent 139f37f commit 4c25932
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,14 +1346,18 @@ bool dm_table_supports_discards(struct dm_table *t)
return 0;

/*
* Ensure that at least one underlying device supports discards.
* Unless any target used by the table set discards_supported,
* require at least one underlying device to support discards.
* t->devices includes internal dm devices such as mirror logs
* so we need to use iterate_devices here, which targets
* supporting discard must provide.
*/
while (i < dm_table_get_num_targets(t)) {
ti = dm_table_get_target(t, i++);

if (ti->discards_supported)
return 1;

if (ti->type->iterate_devices &&
ti->type->iterate_devices(ti, device_discard_capable, NULL))
return 1;
Expand Down
6 changes: 6 additions & 0 deletions include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ struct dm_target {

/* Used to provide an error string from the ctr */
char *error;

/*
* Set if this target needs to receive discards regardless of
* whether or not its underlying devices have support.
*/
unsigned discards_supported:1;
};

/* Each target can link one of these into the table */
Expand Down

0 comments on commit 4c25932

Please sign in to comment.