md/raid1: Don't use next_resync to determine how far resync has progressed
authorNeilBrown <neilb@suse.de>
Wed, 10 Sep 2014 05:56:57 +0000 (15:56 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 5 Oct 2014 21:52:23 +0000 (14:52 -0700)
commitff96e1acf2b7d3e8b86374ec1b5d30a2194e43d1
tree938bb9bd7cba554b80096d8c7e4b3abbff8022be
parent9dcea9a8c1440e9db950634c89030f511704dfe0
md/raid1: Don't use next_resync to determine how far resync has progressed

commit 235549605eb7f1c5a37cef8b09d12e6d412c5cd6 upstream.

next_resync is (approximately) the location for the next resync request.
However it does *not* reliably determine the earliest location
at which resync might be happening.
This is because resync requests can complete out of order, and
we only limit the number of current requests, not the distance
from the earliest pending request to the latest.

mddev->curr_resync_completed is a reliable indicator of the earliest
position at which resync could be happening.   It is updated less
frequently, but is actually reliable which is more important.

So use it to determine if a write request is before the region
being resynced and so safe from conflict.

This error can allow resync IO to interfere with normal IO which
could lead to data corruption. Hence: stable.

Fixes: 79ef3a8aa1cb1523cc231c9a90a278333c21f761
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/raid1.c