aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2012-03-13 11:26:52 -0400
committerIngo Molnar <mingo@elte.hu>2012-03-13 11:26:52 -0400
commit47258cf3c4aa5d56e678bafe0dd0d03ddd980b88 (patch)
tree4856f0fb1185ba97f320a7ed6fb63bf136708a42 /drivers/md
parentc308b56b5398779cd3da0f62ab26b0453494c3d4 (diff)
parentfde7d9049e55ab85a390be7f415d74c9f62dd0f9 (diff)
Merge tag 'v3.3-rc7' into sched/core
Merge reason: merge back final fixes, prepare for the merge window. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-flakey.c2
-rw-r--r--drivers/md/dm-io.c23
-rw-r--r--drivers/md/dm-ioctl.c2
-rw-r--r--drivers/md/dm-raid.c17
-rw-r--r--drivers/md/dm-thin-metadata.c25
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c38
7 files changed, 77 insertions, 32 deletions
diff --git a/drivers/md/dm-flakey.c b/drivers/md/dm-flakey.c
index 9fb18c14782..b280c433e4a 100644
--- a/drivers/md/dm-flakey.c
+++ b/drivers/md/dm-flakey.c
@@ -323,7 +323,7 @@ static int flakey_end_io(struct dm_target *ti, struct bio *bio,
323 * Corrupt successful READs while in down state. 323 * Corrupt successful READs while in down state.
324 * If flags were specified, only corrupt those that match. 324 * If flags were specified, only corrupt those that match.
325 */ 325 */
326 if (!error && bio_submitted_while_down && 326 if (fc->corrupt_bio_byte && !error && bio_submitted_while_down &&
327 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) && 327 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
328 all_corrupt_bio_flags_match(bio, fc)) 328 all_corrupt_bio_flags_match(bio, fc))
329 corrupt_bio_data(bio, fc); 329 corrupt_bio_data(bio, fc);
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index ad2eba40e31..ea5dd289fe2 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -296,6 +296,8 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
296 unsigned offset; 296 unsigned offset;
297 unsigned num_bvecs; 297 unsigned num_bvecs;
298 sector_t remaining = where->count; 298 sector_t remaining = where->count;
299 struct request_queue *q = bdev_get_queue(where->bdev);
300 sector_t discard_sectors;
299 301
300 /* 302 /*
301 * where->count may be zero if rw holds a flush and we need to 303 * where->count may be zero if rw holds a flush and we need to
@@ -305,9 +307,12 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
305 /* 307 /*
306 * Allocate a suitably sized-bio. 308 * Allocate a suitably sized-bio.
307 */ 309 */
308 num_bvecs = dm_sector_div_up(remaining, 310 if (rw & REQ_DISCARD)
309 (PAGE_SIZE >> SECTOR_SHIFT)); 311 num_bvecs = 1;
310 num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev), num_bvecs); 312 else
313 num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev),
314 dm_sector_div_up(remaining, (PAGE_SIZE >> SECTOR_SHIFT)));
315
311 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios); 316 bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io->client->bios);
312 bio->bi_sector = where->sector + (where->count - remaining); 317 bio->bi_sector = where->sector + (where->count - remaining);
313 bio->bi_bdev = where->bdev; 318 bio->bi_bdev = where->bdev;
@@ -315,10 +320,14 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where,
315 bio->bi_destructor = dm_bio_destructor; 320 bio->bi_destructor = dm_bio_destructor;
316 store_io_and_region_in_bio(bio, io, region); 321 store_io_and_region_in_bio(bio, io, region);
317 322
318 /* 323 if (rw & REQ_DISCARD) {
319 * Try and add as many pages as possible. 324 discard_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
320 */ 325 bio->bi_size = discard_sectors << SECTOR_SHIFT;
321 while (remaining) { 326 remaining -= discard_sectors;
327 } else while (remaining) {
328 /*
329 * Try and add as many pages as possible.
330 */
322 dp->get_page(dp, &page, &len, &offset); 331 dp->get_page(dp, &page, &len, &offset);
323 len = min(len, to_bytes(remaining)); 332 len = min(len, to_bytes(remaining));
324 if (!bio_add_page(bio, page, len, offset)) 333 if (!bio_add_page(bio, page, len, offset))
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 31c2dc25886..1ce84ed0b76 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1437,7 +1437,7 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
1437 1437
1438 if (!argc) { 1438 if (!argc) {
1439 DMWARN("Empty message received."); 1439 DMWARN("Empty message received.");
1440 goto out; 1440 goto out_argv;
1441 } 1441 }
1442 1442
1443 table = dm_get_live_table(md); 1443 table = dm_get_live_table(md);
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 86cb7e5d83d..787022c1818 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -668,7 +668,14 @@ static int super_load(struct md_rdev *rdev, struct md_rdev *refdev)
668 return ret; 668 return ret;
669 669
670 sb = page_address(rdev->sb_page); 670 sb = page_address(rdev->sb_page);
671 if (sb->magic != cpu_to_le32(DM_RAID_MAGIC)) { 671
672 /*
673 * Two cases that we want to write new superblocks and rebuild:
674 * 1) New device (no matching magic number)
675 * 2) Device specified for rebuild (!In_sync w/ offset == 0)
676 */
677 if ((sb->magic != cpu_to_le32(DM_RAID_MAGIC)) ||
678 (!test_bit(In_sync, &rdev->flags) && !rdev->recovery_offset)) {
672 super_sync(rdev->mddev, rdev); 679 super_sync(rdev->mddev, rdev);
673 680
674 set_bit(FirstUse, &rdev->flags); 681 set_bit(FirstUse, &rdev->flags);
@@ -745,11 +752,8 @@ static int super_init_validation(struct mddev *mddev, struct md_rdev *rdev)
745 */ 752 */
746 rdev_for_each(r, t, mddev) { 753 rdev_for_each(r, t, mddev) {
747 if (!test_bit(In_sync, &r->flags)) { 754 if (!test_bit(In_sync, &r->flags)) {
748 if (!test_bit(FirstUse, &r->flags)) 755 DMINFO("Device %d specified for rebuild: "
749 DMERR("Superblock area of " 756 "Clearing superblock", r->raid_disk);
750 "rebuild device %d should have been "
751 "cleared.", r->raid_disk);
752 set_bit(FirstUse, &r->flags);
753 rebuilds++; 757 rebuilds++;
754 } else if (test_bit(FirstUse, &r->flags)) 758 } else if (test_bit(FirstUse, &r->flags))
755 new_devs++; 759 new_devs++;
@@ -971,6 +975,7 @@ static int raid_ctr(struct dm_target *ti, unsigned argc, char **argv)
971 975
972 INIT_WORK(&rs->md.event_work, do_table_event); 976 INIT_WORK(&rs->md.event_work, do_table_event);
973 ti->private = rs; 977 ti->private = rs;
978 ti->num_flush_requests = 1;
974 979
975 mutex_lock(&rs->md.reconfig_mutex); 980 mutex_lock(&rs->md.reconfig_mutex);
976 ret = md_run(&rs->md); 981 ret = md_run(&rs->md);
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 59c4f0446ff..237571af77f 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -385,6 +385,7 @@ static int init_pmd(struct dm_pool_metadata *pmd,
385 data_sm = dm_sm_disk_create(tm, nr_blocks); 385 data_sm = dm_sm_disk_create(tm, nr_blocks);
386 if (IS_ERR(data_sm)) { 386 if (IS_ERR(data_sm)) {
387 DMERR("sm_disk_create failed"); 387 DMERR("sm_disk_create failed");
388 dm_tm_unlock(tm, sblock);
388 r = PTR_ERR(data_sm); 389 r = PTR_ERR(data_sm);
389 goto bad; 390 goto bad;
390 } 391 }
@@ -789,6 +790,11 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
789 return 0; 790 return 0;
790} 791}
791 792
793/*
794 * __open_device: Returns @td corresponding to device with id @dev,
795 * creating it if @create is set and incrementing @td->open_count.
796 * On failure, @td is undefined.
797 */
792static int __open_device(struct dm_pool_metadata *pmd, 798static int __open_device(struct dm_pool_metadata *pmd,
793 dm_thin_id dev, int create, 799 dm_thin_id dev, int create,
794 struct dm_thin_device **td) 800 struct dm_thin_device **td)
@@ -799,10 +805,16 @@ static int __open_device(struct dm_pool_metadata *pmd,
799 struct disk_device_details details_le; 805 struct disk_device_details details_le;
800 806
801 /* 807 /*
802 * Check the device isn't already open. 808 * If the device is already open, return it.
803 */ 809 */
804 list_for_each_entry(td2, &pmd->thin_devices, list) 810 list_for_each_entry(td2, &pmd->thin_devices, list)
805 if (td2->id == dev) { 811 if (td2->id == dev) {
812 /*
813 * May not create an already-open device.
814 */
815 if (create)
816 return -EEXIST;
817
806 td2->open_count++; 818 td2->open_count++;
807 *td = td2; 819 *td = td2;
808 return 0; 820 return 0;
@@ -817,6 +829,9 @@ static int __open_device(struct dm_pool_metadata *pmd,
817 if (r != -ENODATA || !create) 829 if (r != -ENODATA || !create)
818 return r; 830 return r;
819 831
832 /*
833 * Create new device.
834 */
820 changed = 1; 835 changed = 1;
821 details_le.mapped_blocks = 0; 836 details_le.mapped_blocks = 0;
822 details_le.transaction_id = cpu_to_le64(pmd->trans_id); 837 details_le.transaction_id = cpu_to_le64(pmd->trans_id);
@@ -882,12 +897,10 @@ static int __create_thin(struct dm_pool_metadata *pmd,
882 897
883 r = __open_device(pmd, dev, 1, &td); 898 r = __open_device(pmd, dev, 1, &td);
884 if (r) { 899 if (r) {
885 __close_device(td);
886 dm_btree_remove(&pmd->tl_info, pmd->root, &key, &pmd->root); 900 dm_btree_remove(&pmd->tl_info, pmd->root, &key, &pmd->root);
887 dm_btree_del(&pmd->bl_info, dev_root); 901 dm_btree_del(&pmd->bl_info, dev_root);
888 return r; 902 return r;
889 } 903 }
890 td->changed = 1;
891 __close_device(td); 904 __close_device(td);
892 905
893 return r; 906 return r;
@@ -967,14 +980,14 @@ static int __create_snap(struct dm_pool_metadata *pmd,
967 goto bad; 980 goto bad;
968 981
969 r = __set_snapshot_details(pmd, td, origin, pmd->time); 982 r = __set_snapshot_details(pmd, td, origin, pmd->time);
983 __close_device(td);
984
970 if (r) 985 if (r)
971 goto bad; 986 goto bad;
972 987
973 __close_device(td);
974 return 0; 988 return 0;
975 989
976bad: 990bad:
977 __close_device(td);
978 dm_btree_remove(&pmd->tl_info, pmd->root, &key, &pmd->root); 991 dm_btree_remove(&pmd->tl_info, pmd->root, &key, &pmd->root);
979 dm_btree_remove(&pmd->details_info, pmd->details_root, 992 dm_btree_remove(&pmd->details_info, pmd->details_root,
980 &key, &pmd->details_root); 993 &key, &pmd->details_root);
@@ -1211,6 +1224,8 @@ static int __remove(struct dm_thin_device *td, dm_block_t block)
1211 if (r) 1224 if (r)
1212 return r; 1225 return r;
1213 1226
1227 td->mapped_blocks--;
1228 td->changed = 1;
1214 pmd->need_commit = 1; 1229 pmd->need_commit = 1;
1215 1230
1216 return 0; 1231 return 0;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a368db2431a..a0b225eb4ac 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -624,7 +624,7 @@ int md_raid1_congested(struct mddev *mddev, int bits)
624 return 1; 624 return 1;
625 625
626 rcu_read_lock(); 626 rcu_read_lock();
627 for (i = 0; i < conf->raid_disks; i++) { 627 for (i = 0; i < conf->raid_disks * 2; i++) {
628 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); 628 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
629 if (rdev && !test_bit(Faulty, &rdev->flags)) { 629 if (rdev && !test_bit(Faulty, &rdev->flags)) {
630 struct request_queue *q = bdev_get_queue(rdev->bdev); 630 struct request_queue *q = bdev_get_queue(rdev->bdev);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 6e8aa213f0d..58c44d6453a 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -67,6 +67,7 @@ static int max_queued_requests = 1024;
67 67
68static void allow_barrier(struct r10conf *conf); 68static void allow_barrier(struct r10conf *conf);
69static void lower_barrier(struct r10conf *conf); 69static void lower_barrier(struct r10conf *conf);
70static int enough(struct r10conf *conf, int ignore);
70 71
71static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data) 72static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
72{ 73{
@@ -347,6 +348,19 @@ static void raid10_end_read_request(struct bio *bio, int error)
347 * wait for the 'master' bio. 348 * wait for the 'master' bio.
348 */ 349 */
349 set_bit(R10BIO_Uptodate, &r10_bio->state); 350 set_bit(R10BIO_Uptodate, &r10_bio->state);
351 } else {
352 /* If all other devices that store this block have
353 * failed, we want to return the error upwards rather
354 * than fail the last device. Here we redefine
355 * "uptodate" to mean "Don't want to retry"
356 */
357 unsigned long flags;
358 spin_lock_irqsave(&conf->device_lock, flags);
359 if (!enough(conf, rdev->raid_disk))
360 uptodate = 1;
361 spin_unlock_irqrestore(&conf->device_lock, flags);
362 }
363 if (uptodate) {
350 raid_end_bio_io(r10_bio); 364 raid_end_bio_io(r10_bio);
351 rdev_dec_pending(rdev, conf->mddev); 365 rdev_dec_pending(rdev, conf->mddev);
352 } else { 366 } else {
@@ -2052,6 +2066,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
2052 "md/raid10:%s: %s: Failing raid device\n", 2066 "md/raid10:%s: %s: Failing raid device\n",
2053 mdname(mddev), b); 2067 mdname(mddev), b);
2054 md_error(mddev, conf->mirrors[d].rdev); 2068 md_error(mddev, conf->mirrors[d].rdev);
2069 r10_bio->devs[r10_bio->read_slot].bio = IO_BLOCKED;
2055 return; 2070 return;
2056 } 2071 }
2057 2072
@@ -2105,8 +2120,11 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
2105 rdev, 2120 rdev,
2106 r10_bio->devs[r10_bio->read_slot].addr 2121 r10_bio->devs[r10_bio->read_slot].addr
2107 + sect, 2122 + sect,
2108 s, 0)) 2123 s, 0)) {
2109 md_error(mddev, rdev); 2124 md_error(mddev, rdev);
2125 r10_bio->devs[r10_bio->read_slot].bio
2126 = IO_BLOCKED;
2127 }
2110 break; 2128 break;
2111 } 2129 }
2112 2130
@@ -2299,17 +2317,20 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
2299 * This is all done synchronously while the array is 2317 * This is all done synchronously while the array is
2300 * frozen. 2318 * frozen.
2301 */ 2319 */
2320 bio = r10_bio->devs[slot].bio;
2321 bdevname(bio->bi_bdev, b);
2322 bio_put(bio);
2323 r10_bio->devs[slot].bio = NULL;
2324
2302 if (mddev->ro == 0) { 2325 if (mddev->ro == 0) {
2303 freeze_array(conf); 2326 freeze_array(conf);
2304 fix_read_error(conf, mddev, r10_bio); 2327 fix_read_error(conf, mddev, r10_bio);
2305 unfreeze_array(conf); 2328 unfreeze_array(conf);
2306 } 2329 } else
2330 r10_bio->devs[slot].bio = IO_BLOCKED;
2331
2307 rdev_dec_pending(rdev, mddev); 2332 rdev_dec_pending(rdev, mddev);
2308 2333
2309 bio = r10_bio->devs[slot].bio;
2310 bdevname(bio->bi_bdev, b);
2311 r10_bio->devs[slot].bio =
2312 mddev->ro ? IO_BLOCKED : NULL;
2313read_more: 2334read_more:
2314 rdev = read_balance(conf, r10_bio, &max_sectors); 2335 rdev = read_balance(conf, r10_bio, &max_sectors);
2315 if (rdev == NULL) { 2336 if (rdev == NULL) {
@@ -2318,13 +2339,10 @@ read_more:
2318 mdname(mddev), b, 2339 mdname(mddev), b,
2319 (unsigned long long)r10_bio->sector); 2340 (unsigned long long)r10_bio->sector);
2320 raid_end_bio_io(r10_bio); 2341 raid_end_bio_io(r10_bio);
2321 bio_put(bio);
2322 return; 2342 return;
2323 } 2343 }
2324 2344
2325 do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC); 2345 do_sync = (r10_bio->master_bio->bi_rw & REQ_SYNC);
2326 if (bio)
2327 bio_put(bio);
2328 slot = r10_bio->read_slot; 2346 slot = r10_bio->read_slot;
2329 printk_ratelimited( 2347 printk_ratelimited(
2330 KERN_ERR 2348 KERN_ERR
@@ -2360,7 +2378,6 @@ read_more:
2360 mbio->bi_phys_segments++; 2378 mbio->bi_phys_segments++;
2361 spin_unlock_irq(&conf->device_lock); 2379 spin_unlock_irq(&conf->device_lock);
2362 generic_make_request(bio); 2380 generic_make_request(bio);
2363 bio = NULL;
2364 2381
2365 r10_bio = mempool_alloc(conf->r10bio_pool, 2382 r10_bio = mempool_alloc(conf->r10bio_pool,
2366 GFP_NOIO); 2383 GFP_NOIO);
@@ -3243,7 +3260,6 @@ static int run(struct mddev *mddev)
3243 disk->rdev = rdev; 3260 disk->rdev = rdev;
3244 } 3261 }
3245 3262
3246 disk->rdev = rdev;
3247 disk_stack_limits(mddev->gendisk, rdev->bdev, 3263 disk_stack_limits(mddev->gendisk, rdev->bdev,
3248 rdev->data_offset << 9); 3264 rdev->data_offset << 9);
3249 /* as we don't honour merge_bvec_fn, we must never risk 3265 /* as we don't honour merge_bvec_fn, we must never risk