diff options
author | Dan Williams <dan.j.williams@intel.com> | 2009-08-01 02:11:41 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2009-08-01 02:11:41 +0200 |
commit | 329c82786932b2fbc56cd57ac0bfc185d83a04c9 (patch) | |
tree | 973e3d1598efe93e20023d0d4a74d0b1b5aa814a /super-intel.c | |
parent | conditionally update uuids in the map file after Create() (diff) | |
download | mdadm-329c82786932b2fbc56cd57ac0bfc185d83a04c9.tar.xz mdadm-329c82786932b2fbc56cd57ac0bfc185d83a04c9.zip |
imsm: fix activate_spare off-by-one
The last sector of an array is calculated by start + size - 1.
Reported-by: Rafal Marszewski <rafal.marszewski@intel.com>
Reported-by: Jarema Bielanski <jarema.bielanski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to '')
-rw-r--r-- | super-intel.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/super-intel.c b/super-intel.c index 56947ded..07e3d46c 100644 --- a/super-intel.c +++ b/super-intel.c @@ -3858,14 +3858,13 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot, int idx = get_imsm_disk_idx(dev, slot); struct imsm_super *mpb = super->anchor; struct imsm_map *map; - unsigned long long esize; unsigned long long pos; struct mdinfo *d; struct extent *ex; int i, j; int found; __u32 array_start; - __u32 blocks; + __u32 array_end; struct dl *dl; for (dl = super->disks; dl; dl = dl->next) { @@ -3917,15 +3916,14 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot, j = 0; pos = 0; array_start = __le32_to_cpu(map->pba_of_lba0); - blocks = __le32_to_cpu(map->blocks_per_member); + array_end = array_start + + __le32_to_cpu(map->blocks_per_member) - 1; do { /* check that we can start at pba_of_lba0 with * blocks_per_member of space */ - esize = ex[j].start - pos; - if (array_start >= pos && - array_start + blocks < ex[j].start) { + if (array_start >= pos && array_end < ex[j].start) { found = 1; break; } @@ -3939,9 +3937,8 @@ static struct dl *imsm_add_spare(struct intel_super *super, int slot, free(ex); if (i < mpb->num_raid_devs) { - dprintf("%x:%x does not have %u at %u\n", - dl->major, dl->minor, - blocks, array_start); + dprintf("%x:%x does not have %u to %u available\n", + dl->major, dl->minor, array_start, array_end); /* No room */ continue; } |