Commit 49296309 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon

dm thin: split discards on block boundary

This patch sets the variable "ti->split_discard_requests" for the dm thin
target so that device mapper core splits discard requests on a block
boundary.

Consequently, a discard request that spans multiple blocks is never sent
to dm-thin. The patch also removes some code in process_discard that
deals with discards that span multiple blocks.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent 7acf0277
...@@ -1238,15 +1238,10 @@ static void process_discard(struct thin_c *tc, struct bio *bio) ...@@ -1238,15 +1238,10 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
} }
} else { } else {
/* /*
* This path is hit if people are ignoring * The DM core makes sure that the discard doesn't span
* limits->discard_granularity. It ignores any * a block boundary. So we submit the discard of a
* part of the discard that is in a subsequent * partial block appropriately.
* block.
*/ */
sector_t offset = bio->bi_sector - (block * pool->sectors_per_block);
unsigned remaining = (pool->sectors_per_block - offset) << SECTOR_SHIFT;
bio->bi_size = min(bio->bi_size, remaining);
cell_release_singleton(cell, bio); cell_release_singleton(cell, bio);
cell_release_singleton(cell2, bio); cell_release_singleton(cell2, bio);
if ((!lookup_result.shared) && pool->pf.discard_passdown) if ((!lookup_result.shared) && pool->pf.discard_passdown)
...@@ -2509,7 +2504,8 @@ static void set_discard_limits(struct pool *pool, struct queue_limits *limits) ...@@ -2509,7 +2504,8 @@ static void set_discard_limits(struct pool *pool, struct queue_limits *limits)
/* /*
* This is just a hint, and not enforced. We have to cope with * This is just a hint, and not enforced. We have to cope with
* bios that overlap 2 blocks. * bios that cover a block partially. A discard that spans a block
* boundary is not sent to this target.
*/ */
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
limits->discard_zeroes_data = pool->pf.zero_new_blocks; limits->discard_zeroes_data = pool->pf.zero_new_blocks;
...@@ -2652,6 +2648,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -2652,6 +2648,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
ti->discards_supported = 1; ti->discards_supported = 1;
ti->num_discard_requests = 1; ti->num_discard_requests = 1;
ti->discard_zeroes_data_unsupported = 1; ti->discard_zeroes_data_unsupported = 1;
/* Discard requests must be split on a block boundary */
ti->split_discard_requests = 1;
} }
dm_put(pool_md); dm_put(pool_md);
......
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