diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-14 21:01:23 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-03-14 21:01:23 -0400 |
commit | 0c01b45257168bc21af88618c75e6aed5b0e6b6d (patch) | |
tree | af389b0f47c1f8b520e826fc79cb714dab630099 | |
parent | c60f7d5a8e7c639de5d9dfe07e1e91d302d506e4 (diff) | |
parent | e893fba90c09f9b57fb97daae204ea9cc2c52fa5 (diff) |
Merge tag 'dm-3.14-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device-mapper fixes form Mike Snitzer:
"Two small fixes for the DM cache target:
- fix corruption with >2TB fast device due to truncation bug
- fix access beyond end of origin device due to a partial block"
* tag 'dm-3.14-fixes-4' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm cache: fix access beyond end of origin device
dm cache: fix truncation bug when copying a block to/from >2TB fast device
-rw-r--r-- | drivers/md/dm-cache-target.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 1af70145fab9..074b9c8e4cf0 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
@@ -979,12 +979,13 @@ static void issue_copy_real(struct dm_cache_migration *mg) | |||
979 | int r; | 979 | int r; |
980 | struct dm_io_region o_region, c_region; | 980 | struct dm_io_region o_region, c_region; |
981 | struct cache *cache = mg->cache; | 981 | struct cache *cache = mg->cache; |
982 | sector_t cblock = from_cblock(mg->cblock); | ||
982 | 983 | ||
983 | o_region.bdev = cache->origin_dev->bdev; | 984 | o_region.bdev = cache->origin_dev->bdev; |
984 | o_region.count = cache->sectors_per_block; | 985 | o_region.count = cache->sectors_per_block; |
985 | 986 | ||
986 | c_region.bdev = cache->cache_dev->bdev; | 987 | c_region.bdev = cache->cache_dev->bdev; |
987 | c_region.sector = from_cblock(mg->cblock) * cache->sectors_per_block; | 988 | c_region.sector = cblock * cache->sectors_per_block; |
988 | c_region.count = cache->sectors_per_block; | 989 | c_region.count = cache->sectors_per_block; |
989 | 990 | ||
990 | if (mg->writeback || mg->demote) { | 991 | if (mg->writeback || mg->demote) { |
@@ -2464,20 +2465,18 @@ static int cache_map(struct dm_target *ti, struct bio *bio) | |||
2464 | bool discarded_block; | 2465 | bool discarded_block; |
2465 | struct dm_bio_prison_cell *cell; | 2466 | struct dm_bio_prison_cell *cell; |
2466 | struct policy_result lookup_result; | 2467 | struct policy_result lookup_result; |
2467 | struct per_bio_data *pb; | 2468 | struct per_bio_data *pb = init_per_bio_data(bio, pb_data_size); |
2468 | 2469 | ||
2469 | if (from_oblock(block) > from_oblock(cache->origin_blocks)) { | 2470 | if (unlikely(from_oblock(block) >= from_oblock(cache->origin_blocks))) { |
2470 | /* | 2471 | /* |
2471 | * This can only occur if the io goes to a partial block at | 2472 | * This can only occur if the io goes to a partial block at |
2472 | * the end of the origin device. We don't cache these. | 2473 | * the end of the origin device. We don't cache these. |
2473 | * Just remap to the origin and carry on. | 2474 | * Just remap to the origin and carry on. |
2474 | */ | 2475 | */ |
2475 | remap_to_origin_clear_discard(cache, bio, block); | 2476 | remap_to_origin(cache, bio); |
2476 | return DM_MAPIO_REMAPPED; | 2477 | return DM_MAPIO_REMAPPED; |
2477 | } | 2478 | } |
2478 | 2479 | ||
2479 | pb = init_per_bio_data(bio, pb_data_size); | ||
2480 | |||
2481 | if (bio->bi_rw & (REQ_FLUSH | REQ_FUA | REQ_DISCARD)) { | 2480 | if (bio->bi_rw & (REQ_FLUSH | REQ_FUA | REQ_DISCARD)) { |
2482 | defer_bio(cache, bio); | 2481 | defer_bio(cache, bio); |
2483 | return DM_MAPIO_SUBMITTED; | 2482 | return DM_MAPIO_SUBMITTED; |