aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorSuzanne Wood <suzannew@cs.pdx.edu>2005-11-09 00:39:27 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:37 -0500
commitd6065f7bf8bec170c9c56524a250093ce73ca5d9 (patch)
tree336c7db10aa8cee48386171e3de7569fca01dcfd /drivers/md
parent9d88883e68f404d5581bd391713ceef470ea53a9 (diff)
[PATCH] md: provide proper rcu_dereference / rcu_assign_pointer annotations in md
Acked-by: <paulmck@us.ibm.com> Signed-off-by: Suzanne Wood <suzannew@cs.pdx.edu> Signed-off-by: Neil Brown <neilb@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/multipath.c8
-rw-r--r--drivers/md/raid1.c20
-rw-r--r--drivers/md/raid10.c30
-rw-r--r--drivers/md/raid5.c8
-rw-r--r--drivers/md/raid6main.c8
5 files changed, 38 insertions, 36 deletions
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index c06f4474192b..ae2c5fd6105d 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -63,7 +63,7 @@ static int multipath_map (multipath_conf_t *conf)
63 63
64 rcu_read_lock(); 64 rcu_read_lock();
65 for (i = 0; i < disks; i++) { 65 for (i = 0; i < disks; i++) {
66 mdk_rdev_t *rdev = conf->multipaths[i].rdev; 66 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
67 if (rdev && rdev->in_sync) { 67 if (rdev && rdev->in_sync) {
68 atomic_inc(&rdev->nr_pending); 68 atomic_inc(&rdev->nr_pending);
69 rcu_read_unlock(); 69 rcu_read_unlock();
@@ -139,7 +139,7 @@ static void unplug_slaves(mddev_t *mddev)
139 139
140 rcu_read_lock(); 140 rcu_read_lock();
141 for (i=0; i<mddev->raid_disks; i++) { 141 for (i=0; i<mddev->raid_disks; i++) {
142 mdk_rdev_t *rdev = conf->multipaths[i].rdev; 142 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
143 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 143 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
144 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 144 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
145 145
@@ -224,7 +224,7 @@ static int multipath_issue_flush(request_queue_t *q, struct gendisk *disk,
224 224
225 rcu_read_lock(); 225 rcu_read_lock();
226 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 226 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
227 mdk_rdev_t *rdev = conf->multipaths[i].rdev; 227 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
228 if (rdev && !rdev->faulty) { 228 if (rdev && !rdev->faulty) {
229 struct block_device *bdev = rdev->bdev; 229 struct block_device *bdev = rdev->bdev;
230 request_queue_t *r_queue = bdev_get_queue(bdev); 230 request_queue_t *r_queue = bdev_get_queue(bdev);
@@ -331,7 +331,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
331 conf->working_disks++; 331 conf->working_disks++;
332 rdev->raid_disk = path; 332 rdev->raid_disk = path;
333 rdev->in_sync = 1; 333 rdev->in_sync = 1;
334 p->rdev = rdev; 334 rcu_assign_pointer(p->rdev, rdev);
335 found = 1; 335 found = 1;
336 } 336 }
337 337
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e16f473bcf46..f12fc288f25d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -416,10 +416,10 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
416 /* Choose the first operation device, for consistancy */ 416 /* Choose the first operation device, for consistancy */
417 new_disk = 0; 417 new_disk = 0;
418 418
419 for (rdev = conf->mirrors[new_disk].rdev; 419 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
420 !rdev || !rdev->in_sync 420 !rdev || !rdev->in_sync
421 || test_bit(WriteMostly, &rdev->flags); 421 || test_bit(WriteMostly, &rdev->flags);
422 rdev = conf->mirrors[++new_disk].rdev) { 422 rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) {
423 423
424 if (rdev && rdev->in_sync) 424 if (rdev && rdev->in_sync)
425 wonly_disk = new_disk; 425 wonly_disk = new_disk;
@@ -434,10 +434,10 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
434 434
435 435
436 /* make sure the disk is operational */ 436 /* make sure the disk is operational */
437 for (rdev = conf->mirrors[new_disk].rdev; 437 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
438 !rdev || !rdev->in_sync || 438 !rdev || !rdev->in_sync ||
439 test_bit(WriteMostly, &rdev->flags); 439 test_bit(WriteMostly, &rdev->flags);
440 rdev = conf->mirrors[new_disk].rdev) { 440 rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) {
441 441
442 if (rdev && rdev->in_sync) 442 if (rdev && rdev->in_sync)
443 wonly_disk = new_disk; 443 wonly_disk = new_disk;
@@ -474,7 +474,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
474 disk = conf->raid_disks; 474 disk = conf->raid_disks;
475 disk--; 475 disk--;
476 476
477 rdev = conf->mirrors[disk].rdev; 477 rdev = rcu_dereference(conf->mirrors[disk].rdev);
478 478
479 if (!rdev || 479 if (!rdev ||
480 !rdev->in_sync || 480 !rdev->in_sync ||
@@ -496,7 +496,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
496 496
497 497
498 if (new_disk >= 0) { 498 if (new_disk >= 0) {
499 rdev = conf->mirrors[new_disk].rdev; 499 rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
500 if (!rdev) 500 if (!rdev)
501 goto retry; 501 goto retry;
502 atomic_inc(&rdev->nr_pending); 502 atomic_inc(&rdev->nr_pending);
@@ -522,7 +522,7 @@ static void unplug_slaves(mddev_t *mddev)
522 522
523 rcu_read_lock(); 523 rcu_read_lock();
524 for (i=0; i<mddev->raid_disks; i++) { 524 for (i=0; i<mddev->raid_disks; i++) {
525 mdk_rdev_t *rdev = conf->mirrors[i].rdev; 525 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
526 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 526 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
527 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 527 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
528 528
@@ -556,7 +556,7 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
556 556
557 rcu_read_lock(); 557 rcu_read_lock();
558 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 558 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
559 mdk_rdev_t *rdev = conf->mirrors[i].rdev; 559 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
560 if (rdev && !rdev->faulty) { 560 if (rdev && !rdev->faulty) {
561 struct block_device *bdev = rdev->bdev; 561 struct block_device *bdev = rdev->bdev;
562 request_queue_t *r_queue = bdev_get_queue(bdev); 562 request_queue_t *r_queue = bdev_get_queue(bdev);
@@ -728,7 +728,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
728#endif 728#endif
729 rcu_read_lock(); 729 rcu_read_lock();
730 for (i = 0; i < disks; i++) { 730 for (i = 0; i < disks; i++) {
731 if ((rdev=conf->mirrors[i].rdev) != NULL && 731 if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL &&
732 !rdev->faulty) { 732 !rdev->faulty) {
733 atomic_inc(&rdev->nr_pending); 733 atomic_inc(&rdev->nr_pending);
734 if (rdev->faulty) { 734 if (rdev->faulty) {
@@ -954,7 +954,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
954 found = 1; 954 found = 1;
955 if (rdev->saved_raid_disk != mirror) 955 if (rdev->saved_raid_disk != mirror)
956 conf->fullsync = 1; 956 conf->fullsync = 1;
957 p->rdev = rdev; 957 rcu_assign_pointer(p->rdev, rdev);
958 break; 958 break;
959 } 959 }
960 960
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index bbe40e9cf923..26114f40bde6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -496,6 +496,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
496 int disk, slot, nslot; 496 int disk, slot, nslot;
497 const int sectors = r10_bio->sectors; 497 const int sectors = r10_bio->sectors;
498 sector_t new_distance, current_distance; 498 sector_t new_distance, current_distance;
499 mdk_rdev_t *rdev;
499 500
500 raid10_find_phys(conf, r10_bio); 501 raid10_find_phys(conf, r10_bio);
501 rcu_read_lock(); 502 rcu_read_lock();
@@ -510,8 +511,8 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
510 slot = 0; 511 slot = 0;
511 disk = r10_bio->devs[slot].devnum; 512 disk = r10_bio->devs[slot].devnum;
512 513
513 while (!conf->mirrors[disk].rdev || 514 while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
514 !conf->mirrors[disk].rdev->in_sync) { 515 !rdev->in_sync) {
515 slot++; 516 slot++;
516 if (slot == conf->copies) { 517 if (slot == conf->copies) {
517 slot = 0; 518 slot = 0;
@@ -527,8 +528,8 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
527 /* make sure the disk is operational */ 528 /* make sure the disk is operational */
528 slot = 0; 529 slot = 0;
529 disk = r10_bio->devs[slot].devnum; 530 disk = r10_bio->devs[slot].devnum;
530 while (!conf->mirrors[disk].rdev || 531 while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
531 !conf->mirrors[disk].rdev->in_sync) { 532 !rdev->in_sync) {
532 slot ++; 533 slot ++;
533 if (slot == conf->copies) { 534 if (slot == conf->copies) {
534 disk = -1; 535 disk = -1;
@@ -547,11 +548,11 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
547 int ndisk = r10_bio->devs[nslot].devnum; 548 int ndisk = r10_bio->devs[nslot].devnum;
548 549
549 550
550 if (!conf->mirrors[ndisk].rdev || 551 if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL ||
551 !conf->mirrors[ndisk].rdev->in_sync) 552 !rdev->in_sync)
552 continue; 553 continue;
553 554
554 if (!atomic_read(&conf->mirrors[ndisk].rdev->nr_pending)) { 555 if (!atomic_read(&rdev->nr_pending)) {
555 disk = ndisk; 556 disk = ndisk;
556 slot = nslot; 557 slot = nslot;
557 break; 558 break;
@@ -569,7 +570,7 @@ rb_out:
569 r10_bio->read_slot = slot; 570 r10_bio->read_slot = slot;
570/* conf->next_seq_sect = this_sector + sectors;*/ 571/* conf->next_seq_sect = this_sector + sectors;*/
571 572
572 if (disk >= 0 && conf->mirrors[disk].rdev) 573 if (disk >= 0 && (rdev=rcu_dereference(conf->mirrors[disk].rdev))!= NULL)
573 atomic_inc(&conf->mirrors[disk].rdev->nr_pending); 574 atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
574 rcu_read_unlock(); 575 rcu_read_unlock();
575 576
@@ -583,7 +584,7 @@ static void unplug_slaves(mddev_t *mddev)
583 584
584 rcu_read_lock(); 585 rcu_read_lock();
585 for (i=0; i<mddev->raid_disks; i++) { 586 for (i=0; i<mddev->raid_disks; i++) {
586 mdk_rdev_t *rdev = conf->mirrors[i].rdev; 587 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
587 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 588 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
588 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 589 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
589 590
@@ -614,7 +615,7 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
614 615
615 rcu_read_lock(); 616 rcu_read_lock();
616 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 617 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
617 mdk_rdev_t *rdev = conf->mirrors[i].rdev; 618 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
618 if (rdev && !rdev->faulty) { 619 if (rdev && !rdev->faulty) {
619 struct block_device *bdev = rdev->bdev; 620 struct block_device *bdev = rdev->bdev;
620 request_queue_t *r_queue = bdev_get_queue(bdev); 621 request_queue_t *r_queue = bdev_get_queue(bdev);
@@ -768,9 +769,10 @@ static int make_request(request_queue_t *q, struct bio * bio)
768 rcu_read_lock(); 769 rcu_read_lock();
769 for (i = 0; i < conf->copies; i++) { 770 for (i = 0; i < conf->copies; i++) {
770 int d = r10_bio->devs[i].devnum; 771 int d = r10_bio->devs[i].devnum;
771 if (conf->mirrors[d].rdev && 772 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[d].rdev);
772 !conf->mirrors[d].rdev->faulty) { 773 if (rdev &&
773 atomic_inc(&conf->mirrors[d].rdev->nr_pending); 774 !rdev->faulty) {
775 atomic_inc(&rdev->nr_pending);
774 r10_bio->devs[i].bio = bio; 776 r10_bio->devs[i].bio = bio;
775 } else 777 } else
776 r10_bio->devs[i].bio = NULL; 778 r10_bio->devs[i].bio = NULL;
@@ -980,7 +982,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
980 p->head_position = 0; 982 p->head_position = 0;
981 rdev->raid_disk = mirror; 983 rdev->raid_disk = mirror;
982 found = 1; 984 found = 1;
983 p->rdev = rdev; 985 rcu_assign_pointer(p->rdev, rdev);
984 break; 986 break;
985 } 987 }
986 988
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ce154553aca5..061d265ed94e 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -1374,7 +1374,7 @@ static void handle_stripe(struct stripe_head *sh)
1374 bi->bi_end_io = raid5_end_read_request; 1374 bi->bi_end_io = raid5_end_read_request;
1375 1375
1376 rcu_read_lock(); 1376 rcu_read_lock();
1377 rdev = conf->disks[i].rdev; 1377 rdev = rcu_dereference(conf->disks[i].rdev);
1378 if (rdev && rdev->faulty) 1378 if (rdev && rdev->faulty)
1379 rdev = NULL; 1379 rdev = NULL;
1380 if (rdev) 1380 if (rdev)
@@ -1448,7 +1448,7 @@ static void unplug_slaves(mddev_t *mddev)
1448 1448
1449 rcu_read_lock(); 1449 rcu_read_lock();
1450 for (i=0; i<mddev->raid_disks; i++) { 1450 for (i=0; i<mddev->raid_disks; i++) {
1451 mdk_rdev_t *rdev = conf->disks[i].rdev; 1451 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1452 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 1452 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
1453 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 1453 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
1454 1454
@@ -1493,7 +1493,7 @@ static int raid5_issue_flush(request_queue_t *q, struct gendisk *disk,
1493 1493
1494 rcu_read_lock(); 1494 rcu_read_lock();
1495 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 1495 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
1496 mdk_rdev_t *rdev = conf->disks[i].rdev; 1496 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1497 if (rdev && !rdev->faulty) { 1497 if (rdev && !rdev->faulty) {
1498 struct block_device *bdev = rdev->bdev; 1498 struct block_device *bdev = rdev->bdev;
1499 request_queue_t *r_queue = bdev_get_queue(bdev); 1499 request_queue_t *r_queue = bdev_get_queue(bdev);
@@ -2165,7 +2165,7 @@ static int raid5_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2165 found = 1; 2165 found = 1;
2166 if (rdev->saved_raid_disk != disk) 2166 if (rdev->saved_raid_disk != disk)
2167 conf->fullsync = 1; 2167 conf->fullsync = 1;
2168 p->rdev = rdev; 2168 rcu_assign_pointer(p->rdev, rdev);
2169 break; 2169 break;
2170 } 2170 }
2171 print_raid5_conf(conf); 2171 print_raid5_conf(conf);
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 775786947701..84f3ee01e4c8 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1464,7 +1464,7 @@ static void handle_stripe(struct stripe_head *sh)
1464 bi->bi_end_io = raid6_end_read_request; 1464 bi->bi_end_io = raid6_end_read_request;
1465 1465
1466 rcu_read_lock(); 1466 rcu_read_lock();
1467 rdev = conf->disks[i].rdev; 1467 rdev = rcu_dereference(conf->disks[i].rdev);
1468 if (rdev && rdev->faulty) 1468 if (rdev && rdev->faulty)
1469 rdev = NULL; 1469 rdev = NULL;
1470 if (rdev) 1470 if (rdev)
@@ -1538,7 +1538,7 @@ static void unplug_slaves(mddev_t *mddev)
1538 1538
1539 rcu_read_lock(); 1539 rcu_read_lock();
1540 for (i=0; i<mddev->raid_disks; i++) { 1540 for (i=0; i<mddev->raid_disks; i++) {
1541 mdk_rdev_t *rdev = conf->disks[i].rdev; 1541 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1542 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) { 1542 if (rdev && !rdev->faulty && atomic_read(&rdev->nr_pending)) {
1543 request_queue_t *r_queue = bdev_get_queue(rdev->bdev); 1543 request_queue_t *r_queue = bdev_get_queue(rdev->bdev);
1544 1544
@@ -1583,7 +1583,7 @@ static int raid6_issue_flush(request_queue_t *q, struct gendisk *disk,
1583 1583
1584 rcu_read_lock(); 1584 rcu_read_lock();
1585 for (i=0; i<mddev->raid_disks && ret == 0; i++) { 1585 for (i=0; i<mddev->raid_disks && ret == 0; i++) {
1586 mdk_rdev_t *rdev = conf->disks[i].rdev; 1586 mdk_rdev_t *rdev = rcu_dereference(conf->disks[i].rdev);
1587 if (rdev && !rdev->faulty) { 1587 if (rdev && !rdev->faulty) {
1588 struct block_device *bdev = rdev->bdev; 1588 struct block_device *bdev = rdev->bdev;
1589 request_queue_t *r_queue = bdev_get_queue(bdev); 1589 request_queue_t *r_queue = bdev_get_queue(bdev);
@@ -2154,7 +2154,7 @@ static int raid6_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2154 found = 1; 2154 found = 1;
2155 if (rdev->saved_raid_disk != disk) 2155 if (rdev->saved_raid_disk != disk)
2156 conf->fullsync = 1; 2156 conf->fullsync = 1;
2157 p->rdev = rdev; 2157 rcu_assign_pointer(p->rdev, rdev);
2158 break; 2158 break;
2159 } 2159 }
2160 print_raid6_conf(conf); 2160 print_raid6_conf(conf);