Commit 8ddeeae51f2f197b4fafcba117ee8191b49d843e

Authored by NeilBrown
Committed by Linus Torvalds
1 parent f6344757a9

[PATCH] md: Fix md grow/size code to correctly find the maximum available space

An md array can be asked to change the amount of each device that it is using,
and in particular can be asked to use the maximum available space.  This
currently only works if the first device is not larger than the rest.  As
'size' gets changed and so 'fit' becomes wrong.  So check if a 'fit' is
required early and don't corrupt it.

Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -3575,6 +3575,7 @@
3575 3575 mdk_rdev_t * rdev;
3576 3576 int rv;
3577 3577 struct list_head *tmp;
  3578 + int fit = (size == 0);
3578 3579  
3579 3580 if (mddev->pers->resize == NULL)
3580 3581 return -EINVAL;
... ... @@ -3592,7 +3593,6 @@
3592 3593 return -EBUSY;
3593 3594 ITERATE_RDEV(mddev,rdev,tmp) {
3594 3595 sector_t avail;
3595   - int fit = (size == 0);
3596 3596 if (rdev->sb_offset > rdev->data_offset)
3597 3597 avail = (rdev->sb_offset*2) - rdev->data_offset;
3598 3598 else