dm cache: share cache-metadata object across inactive and active DM tables
authorJoe Thornber <ejt@redhat.com>
Fri, 23 Jan 2015 10:00:07 +0000 (10:00 +0000)
committerJiri Slaby <jslaby@suse.cz>
Thu, 29 Jan 2015 14:44:59 +0000 (15:44 +0100)
commita3d35a1cfa10472d5c73df43badda7618407c4f6
tree9a0f65faf1b35d25a46db8bcc3158f5488af9252
parentc47613fde69549c125f2b20663004ce118c8e3d7
dm cache: share cache-metadata object across inactive and active DM tables

commit 9b1cc9f251affdd27f29fe46d0989ba76c33faf6 upstream.

If a DM table is reloaded with an inactive table when the device is not
suspended (normal procedure for LVM2), then there will be two dm-bufio
objects that can diverge.  This can lead to a situation where the
inactive table uses bufio to read metadata at the same time the active
table writes metadata -- resulting in the inactive table having stale
metadata buffers once it is promoted to the active table slot.

Fix this by using reference counting and a global list of cache metadata
objects to ensure there is only one metadata object per metadata device.

Signed-off-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-metadata.c