diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2023-04-04 11:19:33 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-04-04 13:30:17 -0400 |
commit | 00065f925efb077ade3e7fea49150d798cf87d05 (patch) | |
tree | 3d94da4faa23e88ee7175947e5236bfa1c041f47 /drivers/md/dm-zero.c | |
parent | 85c938e8914f8f0e276b8e82d4f2e4bcab044e96 (diff) | |
download | linux-stable-00065f925efb077ade3e7fea49150d798cf87d05.tar.gz linux-stable-00065f925efb077ade3e7fea49150d798cf87d05.tar.bz2 linux-stable-00065f925efb077ade3e7fea49150d798cf87d05.zip |
dm zero: add discard support
Add zero_io_hints() and set discard limits so that the zero target
advertises support for discards.
The zero target will ignore discards.
This is useful when the user combines dm-zero with other
discard-supporting targets in the same table; without dm-zero support,
discards would be disabled for the whole combined device.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Diffstat (limited to 'drivers/md/dm-zero.c')
-rw-r--r-- | drivers/md/dm-zero.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c index 2601cd520384..6215d8eb7e41 100644 --- a/drivers/md/dm-zero.c +++ b/drivers/md/dm-zero.c @@ -27,6 +27,7 @@ static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv) * Silently drop discards, avoiding -EOPNOTSUPP. */ ti->num_discard_bios = 1; + ti->discards_supported = true; return 0; } @@ -45,6 +46,7 @@ static int zero_map(struct dm_target *ti, struct bio *bio) zero_fill_bio(bio); break; case REQ_OP_WRITE: + case REQ_OP_DISCARD: /* writes get silently dropped */ break; default: @@ -57,13 +59,21 @@ static int zero_map(struct dm_target *ti, struct bio *bio) return DM_MAPIO_SUBMITTED; } +static void zero_io_hints(struct dm_target *ti, struct queue_limits *limits) +{ + limits->max_discard_sectors = UINT_MAX; + limits->max_hw_discard_sectors = UINT_MAX; + limits->discard_granularity = 512; +} + static struct target_type zero_target = { .name = "zero", - .version = {1, 1, 0}, + .version = {1, 2, 0}, .features = DM_TARGET_NOWAIT, .module = THIS_MODULE, .ctr = zero_ctr, .map = zero_map, + .io_hints = zero_io_hints, }; static int __init dm_zero_init(void) |