dm cache: fix truncation bug when copying a block to/from >2TB fast device
authorHeinz Mauelshagen <heinzm@redhat.com>
Tue, 11 Mar 2014 23:40:05 +0000 (00:40 +0100)
committerJiri Slaby <jslaby@suse.cz>
Mon, 24 Mar 2014 08:44:59 +0000 (09:44 +0100)
commit67f1830fcdaefd65371bdd1bba38ca29cf7c2bbf
treea613923c919f09cfa38072efd04ce645806c817a
parentb07b194d5cdc0f8cf63bf0039574afef416fafce
dm cache: fix truncation bug when copying a block to/from >2TB fast device

commit 8b9d96666529a979acf4825391efcc7c8a3e9f12 upstream.

During demotion or promotion to a cache's >2TB fast device we must not
truncate the cache block's associated sector to 32bits.  The 32bit
temporary result of from_cblock() caused a 32bit multiplication when
calculating the sector of the fast device in issue_copy_real().

Use an intermediate 64bit type to store the 32bit from_cblock() to allow
for proper 64bit multiplication.

Here is an example of how this bug manifests on an ext4 filesystem:

 EXT4-fs error (device dm-0): ext4_mb_generate_buddy:756: group 17136, 32768 clusters in bitmap, 30688 in gd; block bitmap corrupt.
 JBD2: Spotted dirty metadata buffer (dev = dm-0, blocknr = 0). There's a risk of filesystem corruption in case of system crash.

Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/md/dm-cache-target.c