aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2012-07-27 10:08:03 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 10:08:03 -0400
commit4929630901100fdbfa19186ecf5ea2706f57719b (patch)
treed12aaec9ccae4fb91eb55271fc8f987db0bbce96 /drivers
parent7acf0277cea0f2da89ffffcc9892bea23f618e63 (diff)
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: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-thin.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index f21d318d98f0..828649256902 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1238,15 +1238,10 @@ static void process_discard(struct thin_c *tc, struct bio *bio)
1238 } 1238 }
1239 } else { 1239 } else {
1240 /* 1240 /*
1241 * This path is hit if people are ignoring 1241 * The DM core makes sure that the discard doesn't span
1242 * limits->discard_granularity. It ignores any 1242 * a block boundary. So we submit the discard of a
1243 * part of the discard that is in a subsequent 1243 * partial block appropriately.
1244 * block.
1245 */ 1244 */
1246 sector_t offset = bio->bi_sector - (block * pool->sectors_per_block);
1247 unsigned remaining = (pool->sectors_per_block - offset) << SECTOR_SHIFT;
1248 bio->bi_size = min(bio->bi_size, remaining);
1249
1250 cell_release_singleton(cell, bio); 1245 cell_release_singleton(cell, bio);
1251 cell_release_singleton(cell2, bio); 1246 cell_release_singleton(cell2, bio);
1252 if ((!lookup_result.shared) && pool->pf.discard_passdown) 1247 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 2504
2510 /* 2505 /*
2511 * This is just a hint, and not enforced. We have to cope with 2506 * This is just a hint, and not enforced. We have to cope with
2512 * bios that overlap 2 blocks. 2507 * bios that cover a block partially. A discard that spans a block
2508 * boundary is not sent to this target.
2513 */ 2509 */
2514 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; 2510 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
2515 limits->discard_zeroes_data = pool->pf.zero_new_blocks; 2511 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 ti->discards_supported = 1; 2648 ti->discards_supported = 1;
2653 ti->num_discard_requests = 1; 2649 ti->num_discard_requests = 1;
2654 ti->discard_zeroes_data_unsupported = 1; 2650 ti->discard_zeroes_data_unsupported = 1;
2651 /* Discard requests must be split on a block boundary */
2652 ti->split_discard_requests = 1;
2655 } 2653 }
2656 2654
2657 dm_put(pool_md); 2655 dm_put(pool_md);