dm-table: pass device's length to device_area_is_valid
PATCH 1/1 dm-table: pass device's length to device_area_is_valid
The length associated with the specified device must be passed to device_area_is_valid().
This fixes a regression in the dm-stripe target where the size of the target (ti->len) was used rather than stripe_width (ti->len/#stripes). The resulting error was:
device-mapper: table: 254:0: sdb too small for target
Signed-off-by Mike Snitzer <[email protected]>
--- drivers/md/dm-crypt.c | 2 +- drivers/md/dm-delay.c | 4 ++-- drivers/md/dm-linear.c | 2 +- drivers/md/dm-mpath.c | 2 +- drivers/md/dm-raid1.c | 2 +- drivers/md/dm-stripe.c | 3 ++- drivers/md/dm-table.c | 6 +++--- include/linux/device-mapper.h | 4 ++-- 8 files changed, 13 insertions(+), 12 deletions(-)
drivers/md/dm-crypt.c +1 -1
@@ -1318,7 +1318,7 @@ static int crypt_iterate_devices(struct dm_target *ti, {struct crypt_config *cc = ti->private; -return fn (ti, cc->dev, cc->start, data); +return fn (ti, cc->dev, cc->start, ti->len, data); }static struct target_type crypt_target = {
drivers/md/dm-delay.c +2 -2
@@ -324,12 +324,12 @@ static int delay_iterate_devices(struct dm_target *ti,struct delay_c *dc = ti->private;int ret =0 ; - ret =fn (ti, dc->dev_read, dc->start_read, data); + ret =fn (ti, dc->dev_read, dc->start_read, ti->len, data);if (ret) goto out;if (dc->dev_write) - ret =fn (ti, dc->dev_write, dc->start_write, data); + ret =fn (ti, dc->dev_write, dc->start_write, ti->len, data); out:return ret;
drivers/md/dm-linear.c +1 -1
@@ -139,7 +139,7 @@ static int linear_iterate_devices(struct dm_target *ti, {struct linear_c *lc = ti->private; -return fn (ti, lc->dev, lc->start, data); +return fn (ti, lc->dev, lc->start, ti->len, data); }static struct target_type linear_target = {
drivers/md/dm-mpath.c +1 -1
@@ -1453,7 +1453,7 @@ static int multipath_iterate_devices(struct dm_target *ti,list_for_each_entry (pg, &m->priority_groups, list) {list_for_each_entry (p, &pg->pgpaths, list) { - ret =fn (ti, p->path.dev, ti->begin, data); + ret =fn (ti, p->path.dev, ti->begin, ti->len, data);if (ret) goto out; }
drivers/md/dm-raid1.c +1 -1
@@ -1292,7 +1292,7 @@ static int mirror_iterate_devices(struct dm_target *ti,for (i =0 ; !ret && i < ms->nr_mirrors; i++) ret =fn (ti, ms->mirror[i].dev, - ms->mirror[i].offset, data); + ms->mirror[i].offset, ti->len, data);return ret; }
drivers/md/dm-stripe.c +2 -1
@@ -322,7 +322,8 @@ static int stripe_iterate_devices(struct dm_target *ti,do ret =fn (ti, sc->stripe[i].dev, - sc->stripe[i].physical_start, data); + sc->stripe[i].physical_start, + sc->stripe_width, data);while (!ret && ++i < sc->stripes);return ret;
drivers/md/dm-table.c +3 -3
@@ -346,7 +346,7 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)* If possible, this checks an area of a destination device is valid. */ static int device_area_is_valid (struct dm_target *ti,struct dm_dev *dev, -sector_t start,void *data) +sector_t start,sector_t len,void *data) {struct queue_limits *limits = data;struct block_device *bdev = dev->bdev;
@@ -359,7 +359,7 @@ static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev,if (!dev_size)return 1 ; -if ((start >= dev_size) || (start + ti->len > dev_size)) { +if ((start >= dev_size) || (start + len > dev_size)) {DMWARN ("%s: %s too small for target" ,dm_device_name (ti->table->md),bdevname (bdev, b));return 0 ;
@@ -482,7 +482,7 @@ static int __table_get_device(struct dm_table *t, struct dm_target *ti,#define min_not_zero (l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))int dm_set_device_limits (struct dm_target *ti,struct dm_dev *dev, -sector_t start,void *data) +sector_t start,sector_t len,void *data) {struct queue_limits *limits = data;struct block_device *bdev = dev->bdev;
include/linux/device-mapper.h +2 -2
@@ -84,7 +84,7 @@ typedef int (*dm_merge_fn) (struct dm_target *ti, struct bvec_merge_data *bvm,typedef int (*iterate_devices_callout_fn ) (struct dm_target *ti,struct dm_dev *dev, -sector_t physical_start, +sector_t start,sector_t len,void *data); typedef int (*dm_iterate_devices_fn) (struct dm_target *ti,
@@ -104,7 +104,7 @@ void dm_error(const char *message);* Combine device limits. */ int dm_set_device_limits (struct dm_target *ti,struct dm_dev *dev, -sector_t start,void *data); +sector_t start,sector_t len,void *data);struct dm_dev {struct block_device *bdev;