From: NeilBrown Date: Mon, 27 Mar 2006 09:18:18 +0000 (-0800) Subject: [PATCH] md: Fix md grow/size code to correctly find the maximum available space X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ddeeae51f2f197b4fafcba117ee8191b49d843e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/md/md.c b/drivers/md/md.c index 92fd0104fa04..147efcb1e8ca 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3575,6 +3575,7 @@ static int update_size(mddev_t *mddev, unsigned long size) mdk_rdev_t * rdev; int rv; struct list_head *tmp; + int fit = (size == 0); if (mddev->pers->resize == NULL) return -EINVAL; @@ -3592,7 +3593,6 @@ static int update_size(mddev_t *mddev, unsigned long size) return -EBUSY; ITERATE_RDEV(mddev,rdev,tmp) { sector_t avail; - int fit = (size == 0); if (rdev->sb_offset > rdev->data_offset) avail = (rdev->sb_offset*2) - rdev->data_offset; else