Commit 13f6facf authored by Mike Snitzer's avatar Mike Snitzer

dm: allow targets to require splitting WRITE_ZEROES and SECURE_ERASE

Introduce max_write_zeroes_granularity and
max_secure_erase_granularity flags in the dm_target struct.

If a target sets these then DM core will split IO of these operation
types accordingly (in terms of max_write_zeroes_sectors and
max_secure_erase_sectors respectively).
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
parent 3664ff82
...@@ -1614,21 +1614,23 @@ static blk_status_t __process_abnormal_io(struct clone_info *ci, ...@@ -1614,21 +1614,23 @@ static blk_status_t __process_abnormal_io(struct clone_info *ci,
{ {
unsigned int num_bios = 0; unsigned int num_bios = 0;
unsigned int max_granularity = 0; unsigned int max_granularity = 0;
struct queue_limits *limits = dm_get_queue_limits(ti->table->md);
switch (bio_op(ci->bio)) { switch (bio_op(ci->bio)) {
case REQ_OP_DISCARD: case REQ_OP_DISCARD:
num_bios = ti->num_discard_bios; num_bios = ti->num_discard_bios;
if (ti->max_discard_granularity) { if (ti->max_discard_granularity)
struct queue_limits *limits =
dm_get_queue_limits(ti->table->md);
max_granularity = limits->max_discard_sectors; max_granularity = limits->max_discard_sectors;
}
break; break;
case REQ_OP_SECURE_ERASE: case REQ_OP_SECURE_ERASE:
num_bios = ti->num_secure_erase_bios; num_bios = ti->num_secure_erase_bios;
if (ti->max_secure_erase_granularity)
max_granularity = limits->max_secure_erase_sectors;
break; break;
case REQ_OP_WRITE_ZEROES: case REQ_OP_WRITE_ZEROES:
num_bios = ti->num_write_zeroes_bios; num_bios = ti->num_write_zeroes_bios;
if (ti->max_write_zeroes_granularity)
max_granularity = limits->max_write_zeroes_sectors;
break; break;
default: default:
break; break;
......
...@@ -359,11 +359,23 @@ struct dm_target { ...@@ -359,11 +359,23 @@ struct dm_target {
bool discards_supported:1; bool discards_supported:1;
/* /*
* Set if this target requires that discards be split on both * Set if this target requires that discards be split on
* 'discard_granularity' and 'max_discard_sectors' boundaries. * 'max_discard_sectors' boundaries.
*/ */
bool max_discard_granularity:1; bool max_discard_granularity:1;
/*
* Set if this target requires that secure_erases be split on
* 'max_secure_erase_sectors' boundaries.
*/
bool max_secure_erase_granularity:1;
/*
* Set if this target requires that write_zeroes be split on
* 'max_write_zeroes_sectors' boundaries.
*/
bool max_write_zeroes_granularity:1;
/* /*
* Set if we need to limit the number of in-flight bios when swapping. * Set if we need to limit the number of in-flight bios when swapping.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment