NeilBrown 7da9d450ab md/raid5: close recently introduced race in stripe_head management.
As release_stripe and __release_stripe decrement ->count and then
manipulate ->lru both under ->device_lock, it is important that
get_active_stripe() increments ->count and clears ->lru also under
->device_lock.

However we currently list_del_init ->lru under the lock, but increment
the ->count outside the lock.  This can lead to races and list
corruption.

So move the atomic_inc(&sh->count) up inside the ->device_lock
protected region.

Note that we still increment ->count without device lock in the case
where get_free_stripe() was called, and in fact don't take
->device_lock at all in that path.
This is safe because if the stripe_head can be found by
get_free_stripe, then the hash lock assures us the no-one else could
possibly be calling release_stripe() at the same time.

Fixes: 566c09c53455d7c4f1130928ef8071da1a24ea65
Cc: stable@vger.kernel.org (3.13)
Reported-and-tested-by: Ian Kumlien <ian.kumlien@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
2014-01-22 11:45:03 +11:00
..
2013-09-26 15:33:18 -07:00
2013-03-01 22:45:51 +00:00
2013-03-01 22:45:51 +00:00
2012-03-28 18:41:29 +01:00
2013-03-01 22:45:51 +00:00
2013-11-09 18:20:22 -05:00
2013-08-23 09:02:13 -04:00
2012-07-30 17:25:16 -07:00
2013-08-23 09:02:13 -04:00
2013-09-05 20:46:06 -04:00
2013-07-10 23:41:19 +01:00
2007-10-20 02:01:26 +01:00
2013-07-10 23:41:17 +01:00
2013-03-01 22:45:47 +00:00
2013-11-09 18:20:22 -05:00
2013-11-09 18:20:22 -05:00
2013-03-23 14:15:29 -07:00
2013-11-09 18:20:22 -05:00
2013-03-23 14:15:29 -07:00
2013-09-05 20:46:06 -04:00
2013-11-20 13:05:25 -08:00