Commit 60e356f3 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer

dm-snapshot: fix performance degradation due to small hash size

LVM2, since version 2.02.96, creates origin with zero size, then loads
the snapshot driver and then loads the origin.  Consequently, the
snapshot driver sees the origin size zero and sets the hash size to the
lower bound 64.  Such small hash table causes performance degradation.

This patch changes it so that the hash size is determined by the size of
snapshot volume, not minimum of origin and snapshot size.  It doesn't
make sense to set the snapshot size significantly larger than the origin
size, so we do not need to take origin size into account when
calculating the hash size.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
parent 5ea330a7
...@@ -725,17 +725,16 @@ static int calc_max_buckets(void) ...@@ -725,17 +725,16 @@ static int calc_max_buckets(void)
*/ */
static int init_hash_tables(struct dm_snapshot *s) static int init_hash_tables(struct dm_snapshot *s)
{ {
sector_t hash_size, cow_dev_size, origin_dev_size, max_buckets; sector_t hash_size, cow_dev_size, max_buckets;
/* /*
* Calculate based on the size of the original volume or * Calculate based on the size of the original volume or
* the COW volume... * the COW volume...
*/ */
cow_dev_size = get_dev_size(s->cow->bdev); cow_dev_size = get_dev_size(s->cow->bdev);
origin_dev_size = get_dev_size(s->origin->bdev);
max_buckets = calc_max_buckets(); max_buckets = calc_max_buckets();
hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift; hash_size = cow_dev_size >> s->store->chunk_shift;
hash_size = min(hash_size, max_buckets); hash_size = min(hash_size, max_buckets);
if (hash_size < 64) if (hash_size < 64)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment