md/raid1: extend spinlock to protect raid1_end_read_request against inconsistencies
authorNeilBrown <neilb@suse.com>
Mon, 27 Jul 2015 01:48:52 +0000 (11:48 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Aug 2015 03:51:41 +0000 (20:51 -0700)
commitc4a6d3f3491a55269ee1e8d99f6fa7bab15cc011
treef30f1b0ee2d80bbd53391c32d10643f47474e174
parent2a4cb7b52d728b1f6b76e73ea0277f422da1ffac
md/raid1: extend spinlock to protect raid1_end_read_request against inconsistencies

commit 423f04d63cf421ea436bcc5be02543d549ce4b28 upstream.

raid1_end_read_request() assumes that the In_sync bits are consistent
with the ->degaded count.
raid1_spare_active updates the In_sync bit before the ->degraded count
and so exposes an inconsistency, as does error()
So extend the spinlock in raid1_spare_active() and error() to hide those
inconsistencies.

This should probably be part of
  Commit: 34cab6f42003 ("md/raid1: fix test for 'was read error from
  last working device'.")
as it addresses the same issue.  It fixes the same bug and should go
to -stable for same reasons.

Fixes: 76073054c95b ("md/raid1: clean up read_balance.")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/raid1.c