Skip to content

Commit 9bb38bc

Browse files
zhangyi089kawasaki
authored andcommitted
dm: add BLK_FEAT_WRITE_ZEROES_UNMAP support
Set the BLK_FEAT_WRITE_ZEROES_UNMAP feature on stacking queue limits by default. This feature shall be disabled if any underlying device does not support it. Signed-off-by: Zhang Yi <[email protected]> Reviewed-by: Benjamin Marzinski <[email protected]>
1 parent 84dca0f commit 9bb38bc

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/md/dm-table.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ int dm_split_args(int *argc, char ***argvp, char *input)
599599
static void dm_set_stacking_limits(struct queue_limits *limits)
600600
{
601601
blk_set_stacking_limits(limits);
602-
limits->features |= BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT | BLK_FEAT_POLL;
602+
limits->features |= BLK_FEAT_IO_STAT | BLK_FEAT_NOWAIT | BLK_FEAT_POLL |
603+
BLK_FEAT_WRITE_ZEROES_UNMAP;
603604
}
604605

605606
/*
@@ -1851,8 +1852,10 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
18511852
limits->discard_alignment = 0;
18521853
}
18531854

1854-
if (!dm_table_supports_write_zeroes(t))
1855+
if (!dm_table_supports_write_zeroes(t)) {
18551856
limits->max_write_zeroes_sectors = 0;
1857+
limits->features &= ~BLK_FEAT_WRITE_ZEROES_UNMAP;
1858+
}
18561859

18571860
if (!dm_table_supports_secure_erase(t))
18581861
limits->max_secure_erase_sectors = 0;

drivers/md/dm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,7 @@ void disable_write_zeroes(struct mapped_device *md)
10961096

10971097
/* device doesn't really support WRITE ZEROES, disable it */
10981098
limits->max_write_zeroes_sectors = 0;
1099+
limits->features &= ~BLK_FEAT_WRITE_ZEROES_UNMAP;
10991100
}
11001101

11011102
static bool swap_bios_limit(struct dm_target *ti, struct bio *bio)

0 commit comments

Comments
 (0)