From: NeilBrown Date: Sat, 28 Oct 2006 17:38:30 +0000 (-0700) Subject: [PATCH] md: simplify checking of available size when resizing an array X-Git-Tag: v2.6.19-rc4~61 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01ab5662f573fe3a6bcefa200f15ab3069cec8a3;p=linux-2.6 [PATCH] md: simplify checking of available size when resizing an array When "mdadm --grow --size=xxx" is used to resize an array (use more or less of each device), we check the new siza against the available space in each device. We already have that number recorded in rdev->size, so calculating it is pointless (and wrong in one obscure case). 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 c40ce9f9cc..50ab4a936e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -4045,11 +4045,8 @@ static int update_size(mddev_t *mddev, unsigned long size) return -EBUSY; ITERATE_RDEV(mddev,rdev,tmp) { sector_t avail; - if (rdev->sb_offset > rdev->data_offset) - avail = (rdev->sb_offset*2) - rdev->data_offset; - else - avail = get_capacity(rdev->bdev->bd_disk) - - rdev->data_offset; + avail = rdev->size * 2; + if (fit && (size == 0 || size > avail/2)) size = avail/2; if (avail < ((sector_t)size << 1))