From 3b8da9a43946f14fd490aab93aff757b231b97a8 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 12 Jul 2008 10:37:50 +1000 Subject: [PATCH] --- yaml --- r: 104280 b: refs/heads/master c: d7027458d68b2f1752a28016dcf2ffd0a7e8f567 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/md.txt | 2 +- trunk/drivers/md/md.c | 17 ++++++++--------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index 9df569ed322d..b609d4bacc9b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7e93a89251d4ed7bd4475db62616ccd03ddfd01a +refs/heads/master: d7027458d68b2f1752a28016dcf2ffd0a7e8f567 diff --git a/trunk/Documentation/md.txt b/trunk/Documentation/md.txt index e06cc59437e4..1da9d1b1793f 100644 --- a/trunk/Documentation/md.txt +++ b/trunk/Documentation/md.txt @@ -347,7 +347,7 @@ Each directory contains: for storage of data. This will normally be the same as the component_size. This can be written while assembling an array. If a value less than the current component_size is - written, component_size will be reduced to this value. + written, it will be rejected. An active md device will also contain and entry for each active device diff --git a/trunk/drivers/md/md.c b/trunk/drivers/md/md.c index 5590cb54b584..95466bb089ab 100644 --- a/trunk/drivers/md/md.c +++ b/trunk/drivers/md/md.c @@ -2101,16 +2101,17 @@ static int overlaps(sector_t s1, sector_t l1, sector_t s2, sector_t l2) static ssize_t rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) { - char *e; - unsigned long long size = simple_strtoull(buf, &e, 10); + unsigned long long size; unsigned long long oldsize = rdev->size; mddev_t *my_mddev = rdev->mddev; - if (e==buf || (*e && *e != '\n')) + if (strict_strtoull(buf, 10, &size) < 0) + return -EINVAL; + if (size < my_mddev->size) return -EINVAL; if (my_mddev->pers && rdev->raid_disk >= 0) { - if (rdev->mddev->persistent) { - size = super_types[rdev->mddev->major_version]. + if (my_mddev->persistent) { + size = super_types[my_mddev->major_version]. rdev_size_change(rdev, size); if (!size) return -EBUSY; @@ -2118,12 +2119,12 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) size = (rdev->bdev->bd_inode->i_size >> 10); size -= rdev->data_offset/2; } - if (size < rdev->mddev->size) + if (size < my_mddev->size) return -EINVAL; /* component must fit device */ } rdev->size = size; - if (size > oldsize && rdev->mddev->external) { + if (size > oldsize && my_mddev->external) { /* need to check that all other rdevs with the same ->bdev * do not overlap. We need to unlock the mddev to avoid * a deadlock. We have already changed rdev->size, and if @@ -2165,8 +2166,6 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len) return -EBUSY; } } - if (size < my_mddev->size || my_mddev->size == 0) - my_mddev->size = size; return len; }