md: fix calculation of stacking limits on level change.
authorNeilBrown <neilb@suse.de>
Thu, 14 Nov 2013 04:16:15 +0000 (15:16 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Dec 2013 19:05:54 +0000 (11:05 -0800)
commit2befeea454107590a5f6db1e5839cadfa599eb34
tree36a04e813aefa3573f6248f58ea53549369e300a
parent0524a6bf9f76d51cfb1d96622bffedf1219990fb
md: fix calculation of stacking limits on level change.

commit 02e5f5c0a0f726e66e3d8506ea1691e344277969 upstream.

The various ->run routines of md personalities assume that the 'queue'
has been initialised by the blk_set_stacking_limits() call in
md_alloc().

However when the level is changed (by level_store()) the ->run routine
for the new level is called for an array which has already had the
stacking limits modified.  This can result in incorrect final
settings.

So call blk_set_stacking_limits() before ->run in level_store().

A specific consequence of this bug is that it causes
discard_granularity to be set incorrectly when reshaping a RAID4 to a
RAID0.

This is suitable for any -stable kernel since 3.3 in which
blk_set_stacking_limits() was introduced.

Reported-and-tested-by: "Baldysiak, Pawel" <pawel.baldysiak@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/md.c