dm-buffered: fix discard Use dm_bufio_forget_buffers instead of dm_bufio_forget. Fix calculation of "end". Signed-off-by: Mikulas Patocka --- drivers/md/dm-buffered-target.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) Index: linux-2.6/drivers/md/dm-buffered-target.c =================================================================== --- linux-2.6.orig/drivers/md/dm-buffered-target.c +++ linux-2.6/drivers/md/dm-buffered-target.c @@ -158,14 +158,13 @@ static void _io(struct buffered_c *bc, s */ static void _discard_blocks(struct buffered_c *bc, struct bio *bio) { - sector_t block, end, start; + sector_t start, end; start = _to_block(bc, bio->bi_iter.bi_sector); end = _to_block(bc, bio_end_sector(bio)); - for (block = start ; block <= end; block++) { - dm_bufio_forget(bc->bufio, block); - cond_resched(); - } + if (_sector_mod(bc, bio_end_sector(bio))) + end++; + dm_bufio_forget_buffers(bc->bufio, start, end - start); if (bc->discard_passdown) { if (_sector_mod(bc, bio->bi_iter.bi_sector)) @@ -173,7 +172,7 @@ static void _discard_blocks(struct buffe if (_sector_mod(bc, bio_end_sector(bio))) end--; if (end >= start) - dm_bufio_issue_discard(bc->bufio, start, end - start + 1); + dm_bufio_issue_discard(bc->bufio, start, end - start + 1); } }