Lines Matching full:disk

356  * Update disk head position estimator based on IRQ completion info.
358 static inline void update_head_pos(int disk, struct r1bio *r1_bio) in update_head_pos() argument
362 conf->mirrors[disk].head_position = in update_head_pos()
367 * Find the disk number which triggered given bio
601 static void update_read_sectors(struct r1conf *conf, int disk, in update_read_sectors() argument
604 struct raid1_info *info = &conf->mirrors[disk]; in update_read_sectors()
617 int disk; in choose_first_rdev() local
619 for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) { in choose_first_rdev()
623 if (r1_bio->bios[disk] == IO_BLOCKED) in choose_first_rdev()
626 rdev = conf->mirrors[disk].rdev; in choose_first_rdev()
630 /* choose the first disk even if it has some bad blocks. */ in choose_first_rdev()
633 update_read_sectors(conf, disk, this_sector, read_len); in choose_first_rdev()
635 return disk; in choose_first_rdev()
654 int disk; in choose_bb_rdev() local
656 for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) { in choose_bb_rdev()
661 if (r1_bio->bios[disk] == IO_BLOCKED) in choose_bb_rdev()
664 rdev = conf->mirrors[disk].rdev; in choose_bb_rdev()
670 /* keep track of the disk with the most readable sectors. */ in choose_bb_rdev()
674 best_disk = disk; in choose_bb_rdev()
693 int disk; in choose_slow_rdev() local
695 for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) { in choose_slow_rdev()
700 if (r1_bio->bios[disk] == IO_BLOCKED) in choose_slow_rdev()
703 rdev = conf->mirrors[disk].rdev; in choose_slow_rdev()
709 /* there are no bad blocks, we can use this disk */ in choose_slow_rdev()
714 update_read_sectors(conf, disk, this_sector, read_len); in choose_slow_rdev()
715 return disk; in choose_slow_rdev()
723 bb_disk = disk; in choose_slow_rdev()
736 static bool is_sequential(struct r1conf *conf, int disk, struct r1bio *r1_bio) in is_sequential() argument
739 return conf->mirrors[disk].next_seq_sect == r1_bio->sector || in is_sequential()
740 conf->mirrors[disk].head_position == r1_bio->sector; in is_sequential()
745 * disk. If yes, choose the idle disk.
747 static bool should_choose_next(struct r1conf *conf, int disk) in should_choose_next() argument
749 struct raid1_info *mirror = &conf->mirrors[disk]; in should_choose_next()
769 /* don't read from slow disk unless have to */ in rdev_readable()
791 int disk; in choose_best_rdev() local
800 for (disk = 0 ; disk < conf->raid_disks * 2 ; disk++) { in choose_best_rdev()
805 if (r1_bio->bios[disk] == IO_BLOCKED) in choose_best_rdev()
808 rdev = conf->mirrors[disk].rdev; in choose_best_rdev()
817 dist = abs(r1_bio->sector - conf->mirrors[disk].head_position); in choose_best_rdev()
819 /* Don't change to another disk for sequential reads */ in choose_best_rdev()
820 if (is_sequential(conf, disk, r1_bio)) { in choose_best_rdev()
821 if (!should_choose_next(conf, disk)) in choose_best_rdev()
822 return disk; in choose_best_rdev()
825 * Add 'pending' to avoid choosing this disk if in choose_best_rdev()
826 * there is other idle disk. in choose_best_rdev()
830 * If there is no other idle disk, this disk in choose_best_rdev()
833 ctl.sequential_disk = disk; in choose_best_rdev()
838 ctl.min_pending_disk = disk; in choose_best_rdev()
843 ctl.closest_dist_disk = disk; in choose_best_rdev()
849 * idle disk, so choose the sequential disk. in choose_best_rdev()
855 * If all disks are rotational, choose the closest disk. If any disk is in choose_best_rdev()
856 * non-rotational, choose the disk with less pending request even the in choose_best_rdev()
857 * disk is rotational, which might/might not be optimal for raids with in choose_best_rdev()
868 * This routine returns the disk from which the requested read should be done.
870 * 1) If resync is in progress, find the first usable disk and use it even if it
874 * disks and disks with bad blocks for now. Only pay attention to key disk
880 * 4) If we are all the way at the end, we have no choice but to use a disk even
888 int disk; in read_balance() local
896 disk = choose_best_rdev(conf, r1_bio); in read_balance()
897 if (disk >= 0) { in read_balance()
899 update_read_sectors(conf, disk, r1_bio->sector, in read_balance()
901 return disk; in read_balance()
905 * If we are here it means we didn't find a perfectly good disk so in read_balance()
909 disk = choose_bb_rdev(conf, r1_bio, max_sectors); in read_balance()
910 if (disk >= 0) in read_balance()
911 return disk; in read_balance()
924 /* flush any pending bitmap writes to disk before proceeding w/ I/O */ in flush_bio_list()
1203 * 1) management command handlers (reshape, remove disk, quiesce). in freeze_array()
1793 pr_crit("md/raid1:%s: Disk failure on %pg, disabling device.\n" in raid1_error()
1815 pr_debug(" disk %d, wo:%d, o:%d, dev:%pg\n", in print_conf()
1886 static bool raid1_add_conf(struct r1conf *conf, struct md_rdev *rdev, int disk, in raid1_add_conf() argument
1889 struct raid1_info *info = conf->mirrors + disk; in raid1_add_conf()
1902 rdev->raid_disk = disk; in raid1_add_conf()
1910 static bool raid1_remove_conf(struct r1conf *conf, int disk) in raid1_remove_conf() argument
1912 struct raid1_info *info = conf->mirrors + disk; in raid1_remove_conf()
1944 * find the disk ... but prefer rdev->saved_raid_disk in raid1_add_disk()
2553 * Badblocks set failed, disk marked Faulty. in narrow_write_error()
2786 int disk = -1; in raid1_sync_request() local
2912 if (disk < 0) in raid1_sync_request()
2913 disk = i; in raid1_sync_request()
2940 if (disk < 0) in raid1_sync_request()
2941 disk = wonly; in raid1_sync_request()
2942 r1_bio->read_disk = disk; in raid1_sync_request()
3083 struct raid1_info *disk; in setup_conf() local
3152 disk = conf->mirrors + i; in setup_conf()
3155 disk[conf->raid_disks].rdev) { in setup_conf()
3157 if (!disk->rdev) { in setup_conf()
3161 disk->rdev = in setup_conf()
3162 disk[conf->raid_disks].rdev; in setup_conf()
3163 disk[conf->raid_disks].rdev = NULL; in setup_conf()
3164 } else if (!test_bit(In_sync, &disk->rdev->flags)) in setup_conf()
3169 if (!disk->rdev || in setup_conf()
3170 !test_bit(In_sync, &disk->rdev->flags)) { in setup_conf()
3171 disk->head_position = 0; in setup_conf()
3172 if (disk->rdev && in setup_conf()
3173 (disk->rdev->saved_raid_disk < 0)) in setup_conf()
3264 * RAID1 needs at least one disk in active in raid1_run()