aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-09-04 15:40:22 -0400
committerAlasdair G Kergon <agk@redhat.com>2009-09-04 15:40:22 -0400
commitf6a1ed10864b7540fa758bbccf3433fe17070329 (patch)
treee0b8f1c02f0527e0870dee2977f311695856f8a5 /drivers/md
parent8811f46c1f9386fc7017150de9d52359e5b1826e (diff)
dm table: fix queue_limit checking device iterator
The logic to check for valid device areas is inverted relative to proper use with iterate_devices. The iterate_devices method calls its callback for every underlying device in the target. If any callback returns non-zero, iterate_devices exits immediately. But the callback device_area_is_valid() returns 0 on error and 1 on success. The overall effect without is that an error is issued only if every device is invalid. This patch renames device_area_is_valid to device_area_is_invalid and inverts the logic so that one invalid device is sufficient to raise an error. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-table.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index d952b344191..aa60526075d 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -343,10 +343,10 @@ static void close_dev(struct dm_dev_internal *d, struct mapped_device *md)
343} 343}
344 344
345/* 345/*
346 * If possible, this checks an area of a destination device is valid. 346 * If possible, this checks an area of a destination device is invalid.
347 */ 347 */
348static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev, 348static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
349 sector_t start, sector_t len, void *data) 349 sector_t start, sector_t len, void *data)
350{ 350{
351 struct queue_limits *limits = data; 351 struct queue_limits *limits = data;
352 struct block_device *bdev = dev->bdev; 352 struct block_device *bdev = dev->bdev;
@@ -357,16 +357,16 @@ static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev,
357 char b[BDEVNAME_SIZE]; 357 char b[BDEVNAME_SIZE];
358 358
359 if (!dev_size) 359 if (!dev_size)
360 return 1; 360 return 0;
361 361
362 if ((start >= dev_size) || (start + len > dev_size)) { 362 if ((start >= dev_size) || (start + len > dev_size)) {
363 DMWARN("%s: %s too small for target", 363 DMWARN("%s: %s too small for target",
364 dm_device_name(ti->table->md), bdevname(bdev, b)); 364 dm_device_name(ti->table->md), bdevname(bdev, b));
365 return 0; 365 return 1;
366 } 366 }
367 367
368 if (logical_block_size_sectors <= 1) 368 if (logical_block_size_sectors <= 1)
369 return 1; 369 return 0;
370 370
371 if (start & (logical_block_size_sectors - 1)) { 371 if (start & (logical_block_size_sectors - 1)) {
372 DMWARN("%s: start=%llu not aligned to h/w " 372 DMWARN("%s: start=%llu not aligned to h/w "
@@ -374,7 +374,7 @@ static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev,
374 dm_device_name(ti->table->md), 374 dm_device_name(ti->table->md),
375 (unsigned long long)start, 375 (unsigned long long)start,
376 limits->logical_block_size, bdevname(bdev, b)); 376 limits->logical_block_size, bdevname(bdev, b));
377 return 0; 377 return 1;
378 } 378 }
379 379
380 if (len & (logical_block_size_sectors - 1)) { 380 if (len & (logical_block_size_sectors - 1)) {
@@ -383,10 +383,10 @@ static int device_area_is_valid(struct dm_target *ti, struct dm_dev *dev,
383 dm_device_name(ti->table->md), 383 dm_device_name(ti->table->md),
384 (unsigned long long)len, 384 (unsigned long long)len,
385 limits->logical_block_size, bdevname(bdev, b)); 385 limits->logical_block_size, bdevname(bdev, b));
386 return 0; 386 return 1;
387 } 387 }
388 388
389 return 1; 389 return 0;
390} 390}
391 391
392/* 392/*
@@ -1000,8 +1000,8 @@ int dm_calculate_queue_limits(struct dm_table *table,
1000 * Check each device area is consistent with the target's 1000 * Check each device area is consistent with the target's
1001 * overall queue limits. 1001 * overall queue limits.
1002 */ 1002 */
1003 if (!ti->type->iterate_devices(ti, device_area_is_valid, 1003 if (ti->type->iterate_devices(ti, device_area_is_invalid,
1004 &ti_limits)) 1004 &ti_limits))
1005 return -EINVAL; 1005 return -EINVAL;
1006 1006
1007combine_limits: 1007combine_limits: