Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360311
b: refs/heads/master
c: 58f77a2
h: refs/heads/master
i:
  360309: c247dc1
  360307: 26003a5
  360303: 98e7d95
v: v3
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed Mar 1, 2013
1 parent 96b6fb8 commit df63824
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3daec3b447bcb894c5725e433f7331f4cdae5b0b
refs/heads/master: 58f77a2196ee65510885426e65049880be841193
25 changes: 13 additions & 12 deletions trunk/drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,20 @@ static void requeue_io(struct thin_c *tc)
* target.
*/

static bool block_size_is_power_of_two(struct pool *pool)
{
return pool->sectors_per_block_shift >= 0;
}

static dm_block_t get_bio_block(struct thin_c *tc, struct bio *bio)
{
struct pool *pool = tc->pool;
sector_t block_nr = bio->bi_sector;

if (tc->pool->sectors_per_block_shift < 0)
(void) sector_div(block_nr, tc->pool->sectors_per_block);
if (block_size_is_power_of_two(pool))
block_nr >>= pool->sectors_per_block_shift;
else
block_nr >>= tc->pool->sectors_per_block_shift;
(void) sector_div(block_nr, pool->sectors_per_block);

return block_nr;
}
Expand All @@ -348,12 +354,12 @@ static void remap(struct thin_c *tc, struct bio *bio, dm_block_t block)
sector_t bi_sector = bio->bi_sector;

bio->bi_bdev = tc->pool_dev->bdev;
if (tc->pool->sectors_per_block_shift < 0)
bio->bi_sector = (block * pool->sectors_per_block) +
sector_div(bi_sector, pool->sectors_per_block);
else
if (block_size_is_power_of_two(pool))
bio->bi_sector = (block << pool->sectors_per_block_shift) |
(bi_sector & (pool->sectors_per_block - 1));
else
bio->bi_sector = (block * pool->sectors_per_block) +
sector_div(bi_sector, pool->sectors_per_block);
}

static void remap_to_origin(struct thin_c *tc, struct bio *bio)
Expand Down Expand Up @@ -2425,11 +2431,6 @@ static int pool_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
}

static bool block_size_is_power_of_two(struct pool *pool)
{
return pool->sectors_per_block_shift >= 0;
}

static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
{
struct pool *pool = pt->pool;
Expand Down

0 comments on commit df63824

Please sign in to comment.