Commit 75ba82c6 authored by Neil Brown's avatar Neil Brown Committed by Adrian Bunk

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: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
parent e89da8fc
...@@ -3437,6 +3437,7 @@ static int update_size(mddev_t *mddev, unsigned long size) ...@@ -3437,6 +3437,7 @@ static int update_size(mddev_t *mddev, unsigned long size)
mdk_rdev_t * rdev; mdk_rdev_t * rdev;
int rv; int rv;
struct list_head *tmp; struct list_head *tmp;
int fit = (size == 0);
if (mddev->pers->resize == NULL) if (mddev->pers->resize == NULL)
return -EINVAL; return -EINVAL;
...@@ -3454,7 +3455,6 @@ static int update_size(mddev_t *mddev, unsigned long size) ...@@ -3454,7 +3455,6 @@ static int update_size(mddev_t *mddev, unsigned long size)
return -EBUSY; return -EBUSY;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
sector_t avail; sector_t avail;
int fit = (size == 0);
if (rdev->sb_offset > rdev->data_offset) if (rdev->sb_offset > rdev->data_offset)
avail = (rdev->sb_offset*2) - rdev->data_offset; avail = (rdev->sb_offset*2) - rdev->data_offset;
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment