diff options
author | Neil Brown <neilb@suse.de> | 2008-07-12 10:37:50 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-07-21 14:22:18 +1000 |
commit | d7027458d68b2f1752a28016dcf2ffd0a7e8f567 (patch) | |
tree | 03bb7d75f4951eba4eff21926d1ce71c6d728260 /drivers/md | |
parent | 7e93a89251d4ed7bd4475db62616ccd03ddfd01a (diff) | |
download | linux-d7027458d68b2f1752a28016dcf2ffd0a7e8f567.tar.bz2 |
md: Tidy up rdev_size_store a bit:
- used strict_strtoull in place of simple_strtoull
- use my_mddev in place of rdev->mddev (they have the same value)
and more significantly,
- don't adjust mddev->size to fit, rather reject changes which make
rdev->size smaller than mddev->size
Adjusting mddev->size is a hangover from bind_rdev_to_array which
does a similar thing. But it really is a better design to insist that
mddev->size is set as required, then the rdev->sizes are set to allow
for that. The previous way invites confusion.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5590cb54b584..95466bb089ab 100644 --- a/drivers/md/md.c +++ b/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; } |