]> git.ipfire.org Git - people/ms/linux.git/commit
dm cache: fix race affecting dirty block count
authorAnssi Hannula <anssi.hannula@iki.fi>
Fri, 1 Aug 2014 15:55:47 +0000 (11:55 -0400)
committerJiri Slaby <jslaby@suse.cz>
Tue, 19 Aug 2014 12:23:37 +0000 (14:23 +0200)
commit49cbb95e7c78ca45aad2d985fc7f186ec6020dbc
tree145db3cfdbdb3d057d35de6c8c73d4f9f3fcffc9
parent9ee4fa038c195fc4ccd45aedaafbc8fd489ec33b
dm cache: fix race affecting dirty block count

commit 44fa816bb778edbab6b6ddaaf24908dd6295937e upstream.

nr_dirty is updated without locking, causing it to drift so that it is
non-zero (either a small positive integer, or a very large one when an
underflow occurs) even when there are no actual dirty blocks.  This was
due to a race between the workqueue and map function accessing nr_dirty
in parallel without proper protection.

People were seeing under runs due to a race on increment/decrement of
nr_dirty, see: https://lkml.org/lkml/2014/6/3/648

Fix this by using an atomic_t for nr_dirty.

Reported-by: roma1390@gmail.com
Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
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-target.c