Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 334150
b: refs/heads/master
c: 28eed34
h: refs/heads/master
v: v3
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed Oct 12, 2012
1 parent 0a83888 commit 17c6fa1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 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: 0bcf08798eb9fc3cd0fe2e6b74b25f3f57fa8af2
refs/heads/master: 28eed34e7662d7602da6753b0ba2563006b8e7a2
23 changes: 13 additions & 10 deletions trunk/drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,15 +2272,6 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
goto out_flags_changed;
}

/*
* The block layer requires discard_granularity to be a power of 2.
*/
if (pf.discard_enabled && !is_power_of_2(block_size)) {
ti->error = "Discard support must be disabled when the block size is not a power of 2";
r = -EINVAL;
goto out_flags_changed;
}

pt->pool = pool;
pt->ti = ti;
pt->metadata_dev = metadata_dev;
Expand Down Expand Up @@ -2762,6 +2753,11 @@ 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 All @@ -2775,8 +2771,15 @@ static void set_discard_limits(struct pool_c *pt, struct queue_limits *limits)
if (pt->adjusted_pf.discard_passdown) {
data_limits = &bdev_get_queue(pt->data_dev->bdev)->limits;
limits->discard_granularity = data_limits->discard_granularity;
} else
} else if (block_size_is_power_of_two(pool))
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
else
/*
* Use largest power of 2 that is a factor of sectors_per_block
* but at least DATA_DEV_BLOCK_SIZE_MIN_SECTORS.
*/
limits->discard_granularity = max(1 << (ffs(pool->sectors_per_block) - 1),
DATA_DEV_BLOCK_SIZE_MIN_SECTORS) << SECTOR_SHIFT;
}

static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
Expand Down

0 comments on commit 17c6fa1

Please sign in to comment.