Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 104275
b: refs/heads/master
c: d71f9f8
h: refs/heads/master
i:
  104273: 285b9c4
  104271: 6612efb
v: v3
  • Loading branch information
Andre Noll authored and Neil Brown committed Jul 11, 2008
1 parent fc580de commit 26d2073
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: df5b20cf68f9c90204c5fd36b7b090635cee3cdf
refs/heads/master: d71f9f88d74166dcdef743a057f9222d64d2d509
36 changes: 18 additions & 18 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -2890,7 +2890,7 @@ size_show(mddev_t *mddev, char *page)
return sprintf(page, "%llu\n", (unsigned long long)mddev->size);
}

static int update_size(mddev_t *mddev, unsigned long size);
static int update_size(mddev_t *mddev, sector_t num_sectors);

static ssize_t
size_store(mddev_t *mddev, const char *buf, size_t len)
Expand All @@ -2907,7 +2907,7 @@ size_store(mddev_t *mddev, const char *buf, size_t len)
return -EINVAL;

if (mddev->pers) {
err = update_size(mddev, size);
err = update_size(mddev, size * 2);
md_update_sb(mddev, 1);
} else {
if (mddev->size == 0 ||
Expand Down Expand Up @@ -4617,37 +4617,37 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
return 0;
}

static int update_size(mddev_t *mddev, unsigned long size)
static int update_size(mddev_t *mddev, sector_t num_sectors)
{
mdk_rdev_t * rdev;
int rv;
struct list_head *tmp;
int fit = (size == 0);
int fit = (num_sectors == 0);

if (mddev->pers->resize == NULL)
return -EINVAL;
/* The "size" is the amount of each device that is used.
* This can only make sense for arrays with redundancy.
* linear and raid0 always use whatever space is available
* We can only consider changing the size if no resync
* or reconstruction is happening, and if the new size
* is acceptable. It must fit before the sb_offset or,
* if that is <data_offset, it must fit before the
* size of each device.
* If size is zero, we find the largest size that fits.
/* The "num_sectors" is the number of sectors of each device that
* is used. This can only make sense for arrays with redundancy.
* linear and raid0 always use whatever space is available. We can only
* consider changing this number if no resync or reconstruction is
* happening, and if the new size is acceptable. It must fit before the
* sb_offset or, if that is <data_offset, it must fit before the size
* of each device. If num_sectors is zero, we find the largest size
* that fits.
*/
if (mddev->sync_thread)
return -EBUSY;
rdev_for_each(rdev, tmp, mddev) {
sector_t avail;
avail = rdev->size * 2;

if (fit && (size == 0 || size > avail/2))
size = avail/2;
if (avail < ((sector_t)size << 1))
if (fit && (num_sectors == 0 || num_sectors > avail))
num_sectors = avail;
if (avail < num_sectors)
return -ENOSPC;
}
rv = mddev->pers->resize(mddev, (sector_t)size *2);
rv = mddev->pers->resize(mddev, num_sectors);
if (!rv) {
struct block_device *bdev;

Expand Down Expand Up @@ -4729,7 +4729,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
return mddev->pers->reconfig(mddev, info->layout, -1);
}
if (info->size >= 0 && mddev->size != info->size)
rv = update_size(mddev, info->size);
rv = update_size(mddev, (sector_t)info->size * 2);

if (mddev->raid_disks != info->raid_disks)
rv = update_raid_disks(mddev, info->raid_disks);
Expand Down

0 comments on commit 26d2073

Please sign in to comment.