md/raid10: always set reshape_safe when initializing reshape_position.
authorNeilBrown <neilb@suse.com>
Mon, 6 Jul 2015 07:37:49 +0000 (17:37 +1000)
committerJiri Slaby <jslaby@suse.cz>
Wed, 30 Sep 2015 09:13:09 +0000 (11:13 +0200)
commitc7af5eb41f18b5fc4629e754ff855f93ee88e301
tree66ca9bbd1e78b66a7f0e3cb56b7489b451cc7636
parentcefcb16c7246e9f30572bbb5fc3760127c7b4e79
md/raid10: always set reshape_safe when initializing reshape_position.

commit 299b0685e31c9f3dcc2d58ee3beca761a40b44b3 upstream.

'reshape_position' tracks where in the reshape we have reached.
'reshape_safe' tracks where in the reshape we have safely recorded
in the metadata.

These are compared to determine when to update the metadata.
So it is important that reshape_safe is initialised properly.
Currently it isn't.  When starting a reshape from the beginning
it usually has the correct value by luck.  But when reducing the
number of devices in a RAID10, it has the wrong value and this leads
to the metadata not being updated correctly.
This can lead to corruption if the reshape is not allowed to complete.

This patch is suitable for any -stable kernel which supports RAID10
reshape, which is 3.5 and later.

Fixes: 3ea7daa5d7fd ("md/raid10: add reshape support")
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/md/raid10.c