diff options
author | NeilBrown <neilb@suse.de> | 2005-11-09 00:39:31 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-09 10:56:38 -0500 |
commit | b2d444d7ad975d555bb919601bcdc0e58975a40e (patch) | |
tree | 963a29258af95f05dd28d9de0180ac9ef533aeed /drivers/md/raid1.c | |
parent | ba22dcbf106338a5c46d6979f9b19564faae3d49 (diff) |
[PATCH] md: convert 'faulty' and 'in_sync' fields to bits in 'flags' field
This has the advantage of removing the confusion caused by 'rdev_t' and
'mddev_t' both having 'in_sync' fields.
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/raid1.c')
-rw-r--r-- | drivers/md/raid1.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index f12fc288f25d..fb6b866c28f5 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -417,11 +417,11 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) | |||
417 | new_disk = 0; | 417 | new_disk = 0; |
418 | 418 | ||
419 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); | 419 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); |
420 | !rdev || !rdev->in_sync | 420 | !rdev || !test_bit(In_sync, &rdev->flags) |
421 | || test_bit(WriteMostly, &rdev->flags); | 421 | || test_bit(WriteMostly, &rdev->flags); |
422 | rdev = rcu_dereference(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 && test_bit(In_sync, &rdev->flags)) |
425 | wonly_disk = new_disk; | 425 | wonly_disk = new_disk; |
426 | 426 | ||
427 | if (new_disk == conf->raid_disks - 1) { | 427 | if (new_disk == conf->raid_disks - 1) { |
@@ -435,11 +435,11 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) | |||
435 | 435 | ||
436 | /* make sure the disk is operational */ | 436 | /* make sure the disk is operational */ |
437 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); | 437 | for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); |
438 | !rdev || !rdev->in_sync || | 438 | !rdev || !test_bit(In_sync, &rdev->flags) || |
439 | test_bit(WriteMostly, &rdev->flags); | 439 | test_bit(WriteMostly, &rdev->flags); |
440 | rdev = rcu_dereference(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 && test_bit(In_sync, &rdev->flags)) |
443 | wonly_disk = new_disk; | 443 | wonly_disk = new_disk; |
444 | 444 | ||
445 | if (new_disk <= 0) | 445 | if (new_disk <= 0) |
@@ -477,7 +477,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) | |||
477 | rdev = rcu_dereference(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 | !test_bit(In_sync, &rdev->flags) || |
481 | test_bit(WriteMostly, &rdev->flags)) | 481 | test_bit(WriteMostly, &rdev->flags)) |
482 | continue; | 482 | continue; |
483 | 483 | ||
@@ -500,7 +500,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) | |||
500 | if (!rdev) | 500 | if (!rdev) |
501 | goto retry; | 501 | goto retry; |
502 | atomic_inc(&rdev->nr_pending); | 502 | atomic_inc(&rdev->nr_pending); |
503 | if (!rdev->in_sync) { | 503 | if (!test_bit(In_sync, &rdev->flags)) { |
504 | /* cannot risk returning a device that failed | 504 | /* cannot risk returning a device that failed |
505 | * before we inc'ed nr_pending | 505 | * before we inc'ed nr_pending |
506 | */ | 506 | */ |
@@ -523,7 +523,7 @@ static void unplug_slaves(mddev_t *mddev) | |||
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 = rcu_dereference(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 && !test_bit(Faulty, &rdev->flags) && 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 | ||
529 | atomic_inc(&rdev->nr_pending); | 529 | atomic_inc(&rdev->nr_pending); |
@@ -557,7 +557,7 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk, | |||
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 = rcu_dereference(conf->mirrors[i].rdev); | 559 | mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); |
560 | if (rdev && !rdev->faulty) { | 560 | if (rdev && !test_bit(Faulty, &rdev->flags)) { |
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); |
563 | 563 | ||
@@ -729,9 +729,9 @@ static int make_request(request_queue_t *q, struct bio * bio) | |||
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=rcu_dereference(conf->mirrors[i].rdev)) != NULL && | 731 | if ((rdev=rcu_dereference(conf->mirrors[i].rdev)) != NULL && |
732 | !rdev->faulty) { | 732 | !test_bit(Faulty, &rdev->flags)) { |
733 | atomic_inc(&rdev->nr_pending); | 733 | atomic_inc(&rdev->nr_pending); |
734 | if (rdev->faulty) { | 734 | if (test_bit(Faulty, &rdev->flags)) { |
735 | atomic_dec(&rdev->nr_pending); | 735 | atomic_dec(&rdev->nr_pending); |
736 | r1_bio->bios[i] = NULL; | 736 | r1_bio->bios[i] = NULL; |
737 | } else | 737 | } else |
@@ -824,7 +824,7 @@ static void status(struct seq_file *seq, mddev_t *mddev) | |||
824 | for (i = 0; i < conf->raid_disks; i++) | 824 | for (i = 0; i < conf->raid_disks; i++) |
825 | seq_printf(seq, "%s", | 825 | seq_printf(seq, "%s", |
826 | conf->mirrors[i].rdev && | 826 | conf->mirrors[i].rdev && |
827 | conf->mirrors[i].rdev->in_sync ? "U" : "_"); | 827 | test_bit(In_sync, &conf->mirrors[i].rdev->flags) ? "U" : "_"); |
828 | seq_printf(seq, "]"); | 828 | seq_printf(seq, "]"); |
829 | } | 829 | } |
830 | 830 | ||
@@ -840,14 +840,14 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
840 | * next level up know. | 840 | * next level up know. |
841 | * else mark the drive as failed | 841 | * else mark the drive as failed |
842 | */ | 842 | */ |
843 | if (rdev->in_sync | 843 | if (test_bit(In_sync, &rdev->flags) |
844 | && conf->working_disks == 1) | 844 | && conf->working_disks == 1) |
845 | /* | 845 | /* |
846 | * Don't fail the drive, act as though we were just a | 846 | * Don't fail the drive, act as though we were just a |
847 | * normal single drive | 847 | * normal single drive |
848 | */ | 848 | */ |
849 | return; | 849 | return; |
850 | if (rdev->in_sync) { | 850 | if (test_bit(In_sync, &rdev->flags)) { |
851 | mddev->degraded++; | 851 | mddev->degraded++; |
852 | conf->working_disks--; | 852 | conf->working_disks--; |
853 | /* | 853 | /* |
@@ -855,8 +855,8 @@ static void error(mddev_t *mddev, mdk_rdev_t *rdev) | |||
855 | */ | 855 | */ |
856 | set_bit(MD_RECOVERY_ERR, &mddev->recovery); | 856 | set_bit(MD_RECOVERY_ERR, &mddev->recovery); |
857 | } | 857 | } |
858 | rdev->in_sync = 0; | 858 | clear_bit(In_sync, &rdev->flags); |
859 | rdev->faulty = 1; | 859 | set_bit(Faulty, &rdev->flags); |
860 | mddev->sb_dirty = 1; | 860 | mddev->sb_dirty = 1; |
861 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" | 861 | printk(KERN_ALERT "raid1: Disk failure on %s, disabling device. \n" |
862 | " Operation continuing on %d devices\n", | 862 | " Operation continuing on %d devices\n", |
@@ -881,7 +881,7 @@ static void print_conf(conf_t *conf) | |||
881 | tmp = conf->mirrors + i; | 881 | tmp = conf->mirrors + i; |
882 | if (tmp->rdev) | 882 | if (tmp->rdev) |
883 | printk(" disk %d, wo:%d, o:%d, dev:%s\n", | 883 | printk(" disk %d, wo:%d, o:%d, dev:%s\n", |
884 | i, !tmp->rdev->in_sync, !tmp->rdev->faulty, | 884 | i, !test_bit(In_sync, &tmp->rdev->flags), !test_bit(Faulty, &tmp->rdev->flags), |
885 | bdevname(tmp->rdev->bdev,b)); | 885 | bdevname(tmp->rdev->bdev,b)); |
886 | } | 886 | } |
887 | } | 887 | } |
@@ -913,11 +913,11 @@ static int raid1_spare_active(mddev_t *mddev) | |||
913 | for (i = 0; i < conf->raid_disks; i++) { | 913 | for (i = 0; i < conf->raid_disks; i++) { |
914 | tmp = conf->mirrors + i; | 914 | tmp = conf->mirrors + i; |
915 | if (tmp->rdev | 915 | if (tmp->rdev |
916 | && !tmp->rdev->faulty | 916 | && !test_bit(Faulty, &tmp->rdev->flags) |
917 | && !tmp->rdev->in_sync) { | 917 | && !test_bit(In_sync, &tmp->rdev->flags)) { |
918 | conf->working_disks++; | 918 | conf->working_disks++; |
919 | mddev->degraded--; | 919 | mddev->degraded--; |
920 | tmp->rdev->in_sync = 1; | 920 | set_bit(In_sync, &tmp->rdev->flags); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | 923 | ||
@@ -972,7 +972,7 @@ static int raid1_remove_disk(mddev_t *mddev, int number) | |||
972 | print_conf(conf); | 972 | print_conf(conf); |
973 | rdev = p->rdev; | 973 | rdev = p->rdev; |
974 | if (rdev) { | 974 | if (rdev) { |
975 | if (rdev->in_sync || | 975 | if (test_bit(In_sync, &rdev->flags) || |
976 | atomic_read(&rdev->nr_pending)) { | 976 | atomic_read(&rdev->nr_pending)) { |
977 | err = -EBUSY; | 977 | err = -EBUSY; |
978 | goto abort; | 978 | goto abort; |
@@ -1282,11 +1282,11 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1282 | /* make sure disk is operational */ | 1282 | /* make sure disk is operational */ |
1283 | wonly = disk; | 1283 | wonly = disk; |
1284 | while (conf->mirrors[disk].rdev == NULL || | 1284 | while (conf->mirrors[disk].rdev == NULL || |
1285 | !conf->mirrors[disk].rdev->in_sync || | 1285 | !test_bit(In_sync, &conf->mirrors[disk].rdev->flags) || |
1286 | test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags) | 1286 | test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags) |
1287 | ) { | 1287 | ) { |
1288 | if (conf->mirrors[disk].rdev && | 1288 | if (conf->mirrors[disk].rdev && |
1289 | conf->mirrors[disk].rdev->in_sync) | 1289 | test_bit(In_sync, &conf->mirrors[disk].rdev->flags)) |
1290 | wonly = disk; | 1290 | wonly = disk; |
1291 | if (disk <= 0) | 1291 | if (disk <= 0) |
1292 | disk = conf->raid_disks; | 1292 | disk = conf->raid_disks; |
@@ -1333,10 +1333,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1333 | bio->bi_rw = READ; | 1333 | bio->bi_rw = READ; |
1334 | bio->bi_end_io = end_sync_read; | 1334 | bio->bi_end_io = end_sync_read; |
1335 | } else if (conf->mirrors[i].rdev == NULL || | 1335 | } else if (conf->mirrors[i].rdev == NULL || |
1336 | conf->mirrors[i].rdev->faulty) { | 1336 | test_bit(Faulty, &conf->mirrors[i].rdev->flags)) { |
1337 | still_degraded = 1; | 1337 | still_degraded = 1; |
1338 | continue; | 1338 | continue; |
1339 | } else if (!conf->mirrors[i].rdev->in_sync || | 1339 | } else if (!test_bit(In_sync, &conf->mirrors[i].rdev->flags) || |
1340 | sector_nr + RESYNC_SECTORS > mddev->recovery_cp) { | 1340 | sector_nr + RESYNC_SECTORS > mddev->recovery_cp) { |
1341 | bio->bi_rw = WRITE; | 1341 | bio->bi_rw = WRITE; |
1342 | bio->bi_end_io = end_sync_write; | 1342 | bio->bi_end_io = end_sync_write; |
@@ -1478,7 +1478,7 @@ static int run(mddev_t *mddev) | |||
1478 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); | 1478 | blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); |
1479 | 1479 | ||
1480 | disk->head_position = 0; | 1480 | disk->head_position = 0; |
1481 | if (!rdev->faulty && rdev->in_sync) | 1481 | if (!test_bit(Faulty, &rdev->flags) && test_bit(In_sync, &rdev->flags)) |
1482 | conf->working_disks++; | 1482 | conf->working_disks++; |
1483 | } | 1483 | } |
1484 | conf->raid_disks = mddev->raid_disks; | 1484 | conf->raid_disks = mddev->raid_disks; |
@@ -1518,7 +1518,7 @@ static int run(mddev_t *mddev) | |||
1518 | */ | 1518 | */ |
1519 | for (j = 0; j < conf->raid_disks && | 1519 | for (j = 0; j < conf->raid_disks && |
1520 | (!conf->mirrors[j].rdev || | 1520 | (!conf->mirrors[j].rdev || |
1521 | !conf->mirrors[j].rdev->in_sync) ; j++) | 1521 | !test_bit(In_sync, &conf->mirrors[j].rdev->flags)) ; j++) |
1522 | /* nothing */; | 1522 | /* nothing */; |
1523 | conf->last_used = j; | 1523 | conf->last_used = j; |
1524 | 1524 | ||