Skip to content

Commit 13f6fac

Browse files
author
Mike Snitzer
committed
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: Mike Snitzer <[email protected]>
1 parent 3664ff8 commit 13f6fac

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

drivers/md/dm.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,21 +1614,23 @@ static blk_status_t __process_abnormal_io(struct clone_info *ci,
16141614
{
16151615
unsigned int num_bios = 0;
16161616
unsigned int max_granularity = 0;
1617+
struct queue_limits *limits = dm_get_queue_limits(ti->table->md);
16171618

16181619
switch (bio_op(ci->bio)) {
16191620
case REQ_OP_DISCARD:
16201621
num_bios = ti->num_discard_bios;
1621-
if (ti->max_discard_granularity) {
1622-
struct queue_limits *limits =
1623-
dm_get_queue_limits(ti->table->md);
1622+
if (ti->max_discard_granularity)
16241623
max_granularity = limits->max_discard_sectors;
1625-
}
16261624
break;
16271625
case REQ_OP_SECURE_ERASE:
16281626
num_bios = ti->num_secure_erase_bios;
1627+
if (ti->max_secure_erase_granularity)
1628+
max_granularity = limits->max_secure_erase_sectors;
16291629
break;
16301630
case REQ_OP_WRITE_ZEROES:
16311631
num_bios = ti->num_write_zeroes_bios;
1632+
if (ti->max_write_zeroes_granularity)
1633+
max_granularity = limits->max_write_zeroes_sectors;
16321634
break;
16331635
default:
16341636
break;

include/linux/device-mapper.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,23 @@ struct dm_target {
359359
bool discards_supported:1;
360360

361361
/*
362-
* Set if this target requires that discards be split on both
363-
* 'discard_granularity' and 'max_discard_sectors' boundaries.
362+
* Set if this target requires that discards be split on
363+
* 'max_discard_sectors' boundaries.
364364
*/
365365
bool max_discard_granularity:1;
366366

367+
/*
368+
* Set if this target requires that secure_erases be split on
369+
* 'max_secure_erase_sectors' boundaries.
370+
*/
371+
bool max_secure_erase_granularity:1;
372+
373+
/*
374+
* Set if this target requires that write_zeroes be split on
375+
* 'max_write_zeroes_sectors' boundaries.
376+
*/
377+
bool max_write_zeroes_granularity:1;
378+
367379
/*
368380
* Set if we need to limit the number of in-flight bios when swapping.
369381
*/

0 commit comments

Comments
 (0)