dm snapshot: cope with chunk size larger than origin
commit8419ee8215942d6bf3814391730421a4897fc410
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 10 Dec 2009 23:51:54 +0000 (10 23:51 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 18 Dec 2009 22:05:02 +0000 (18 14:05 -0800)
tree3b0e37fc5e7b30e25e72ee2a62bb5b06131203e5
parent0bca4a5b78ad922624e9a76a7e86453f1fec7239
dm snapshot: cope with chunk size larger than origin

commit 8e87b9b81b3c370f7e53c1ab6e1c3519ef37a644 upstream.

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.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/md/dm-snap.c