diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-12-10 18:51:54 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-12-10 18:51:54 -0500 |
commit | 8e87b9b81b3c370f7e53c1ab6e1c3519ef37a644 (patch) | |
tree | 272a8532e12749c6c8419dcab0c341604646c571 | |
parent | 94e76572b5dd37b1f0f4b3742ee8a565daead932 (diff) |
dm snapshot: cope with chunk size larger than origin
Under some special conditions the snapshot hash_size is calculated as zero.
This patch instead sets a minimum value of 64, the same as for the
pending exception table.
rounddown_pow_of_two(0) is an undefined operation (it expands to shift
by -1). init_exception_table with an argument of 0 would fail with -ENOMEM.
The way to trigger the problem is to create a snapshot with a chunk size
that is larger than the origin device.
Cc: stable@kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r-- | drivers/md/dm-snap.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index d135212958f1..8a4a9c838afd 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -553,6 +553,8 @@ static int init_hash_tables(struct dm_snapshot *s) | |||
553 | hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift; | 553 | hash_size = min(origin_dev_size, cow_dev_size) >> s->store->chunk_shift; |
554 | hash_size = min(hash_size, max_buckets); | 554 | hash_size = min(hash_size, max_buckets); |
555 | 555 | ||
556 | if (hash_size < 64) | ||
557 | hash_size = 64; | ||
556 | hash_size = rounddown_pow_of_two(hash_size); | 558 | hash_size = rounddown_pow_of_two(hash_size); |
557 | if (init_exception_table(&s->complete, hash_size, | 559 | if (init_exception_table(&s->complete, hash_size, |
558 | DM_CHUNK_CONSECUTIVE_BITS)) | 560 | DM_CHUNK_CONSECUTIVE_BITS)) |