• Home
  • Raw
  • Download

Lines Matching full:conf

67 static void allow_barrier(struct r10conf *conf);
68 static void lower_barrier(struct r10conf *conf);
69 static int _enough(struct r10conf *conf, int previous, int ignore);
70 static int enough(struct r10conf *conf, int ignore);
75 static void end_reshape(struct r10conf *conf);
93 struct r10conf *conf = data; in r10bio_pool_alloc() local
94 int size = offsetof(struct r10bio, devs[conf->copies]); in r10bio_pool_alloc()
118 struct r10conf *conf = data; in r10buf_pool_alloc() local
125 r10_bio = r10bio_pool_alloc(gfp_flags, conf); in r10buf_pool_alloc()
129 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in r10buf_pool_alloc()
130 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in r10buf_pool_alloc()
131 nalloc = conf->copies; /* resync */ in r10buf_pool_alloc()
136 if (!conf->have_replacement) in r10buf_pool_alloc()
152 if (!conf->have_replacement) in r10buf_pool_alloc()
174 &conf->mddev->recovery)) { in r10buf_pool_alloc()
206 rbio_pool_free(r10_bio, conf); in r10buf_pool_alloc()
212 struct r10conf *conf = data; in r10buf_pool_free() local
217 for (j = conf->copies; j--; ) { in r10buf_pool_free()
234 rbio_pool_free(r10bio, conf); in r10buf_pool_free()
237 static void put_all_bios(struct r10conf *conf, struct r10bio *r10_bio) in put_all_bios() argument
241 for (i = 0; i < conf->copies; i++) { in put_all_bios()
255 struct r10conf *conf = r10_bio->mddev->private; in free_r10bio() local
257 put_all_bios(conf, r10_bio); in free_r10bio()
258 mempool_free(r10_bio, &conf->r10bio_pool); in free_r10bio()
263 struct r10conf *conf = r10_bio->mddev->private; in put_buf() local
265 mempool_free(r10_bio, &conf->r10buf_pool); in put_buf()
267 lower_barrier(conf); in put_buf()
274 struct r10conf *conf = mddev->private; in reschedule_retry() local
276 spin_lock_irqsave(&conf->device_lock, flags); in reschedule_retry()
277 list_add(&r10_bio->retry_list, &conf->retry_list); in reschedule_retry()
278 conf->nr_queued ++; in reschedule_retry()
279 spin_unlock_irqrestore(&conf->device_lock, flags); in reschedule_retry()
282 wake_up(&conf->wait_barrier); in reschedule_retry()
295 struct r10conf *conf = r10_bio->mddev->private; in raid_end_bio_io() local
305 allow_barrier(conf); in raid_end_bio_io()
315 struct r10conf *conf = r10_bio->mddev->private; in update_head_pos() local
317 conf->mirrors[r10_bio->devs[slot].devnum].head_position = in update_head_pos()
324 static int find_bio_disk(struct r10conf *conf, struct r10bio *r10_bio, in find_bio_disk() argument
330 for (slot = 0; slot < conf->copies; slot++) { in find_bio_disk()
339 BUG_ON(slot == conf->copies); in find_bio_disk()
355 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_read_request() local
381 if (!_enough(conf, test_bit(R10BIO_Previous, &r10_bio->state), in raid10_end_read_request()
387 rdev_dec_pending(rdev, conf->mddev); in raid10_end_read_request()
394 mdname(conf->mddev), in raid10_end_read_request()
432 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_write_request() local
440 dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in raid10_end_write_request()
443 rdev = conf->mirrors[dev].replacement; in raid10_end_write_request()
447 rdev = conf->mirrors[dev].rdev; in raid10_end_write_request()
531 rdev_dec_pending(rdev, conf->mddev); in raid10_end_write_request()
624 static void raid10_find_phys(struct r10conf *conf, struct r10bio *r10bio) in raid10_find_phys() argument
626 struct geom *geo = &conf->geo; in raid10_find_phys()
628 if (conf->reshape_progress != MaxSector && in raid10_find_phys()
629 ((r10bio->sector >= conf->reshape_progress) != in raid10_find_phys()
630 conf->mddev->reshape_backwards)) { in raid10_find_phys()
632 geo = &conf->prev; in raid10_find_phys()
639 static sector_t raid10_find_virt(struct r10conf *conf, sector_t sector, int dev) in raid10_find_virt() argument
642 /* Never use conf->prev as this is only called during resync in raid10_find_virt()
645 struct geom *geo = &conf->geo; in raid10_find_virt()
703 static struct md_rdev *read_balance(struct r10conf *conf, in read_balance() argument
717 struct geom *geo = &conf->geo; in read_balance()
719 raid10_find_phys(conf, r10_bio); in read_balance()
735 if ((conf->mddev->recovery_cp < MaxSector in read_balance()
736 && (this_sector + sectors >= conf->next_resync)) || in read_balance()
737 (mddev_is_clustered(conf->mddev) && in read_balance()
738 md_cluster_ops->area_resyncing(conf->mddev, READ, this_sector, in read_balance()
742 for (slot = 0; slot < conf->copies ; slot++) { in read_balance()
752 rdev = rcu_dereference(conf->mirrors[disk].replacement); in read_balance()
762 rdev = rcu_dereference(conf->mirrors[disk].rdev); in read_balance()
830 conf->mirrors[disk].head_position); in read_balance()
838 if (slot >= conf->copies) { in read_balance()
859 static void flush_pending_writes(struct r10conf *conf) in flush_pending_writes() argument
864 spin_lock_irq(&conf->device_lock); in flush_pending_writes()
866 if (conf->pending_bio_list.head) { in flush_pending_writes()
870 bio = bio_list_get(&conf->pending_bio_list); in flush_pending_writes()
871 conf->pending_count = 0; in flush_pending_writes()
872 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
888 md_bitmap_unplug(conf->mddev->bitmap); in flush_pending_writes()
889 wake_up(&conf->wait_barrier); in flush_pending_writes()
909 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
934 static void raise_barrier(struct r10conf *conf, int force) in raise_barrier() argument
936 BUG_ON(force && !conf->barrier); in raise_barrier()
937 spin_lock_irq(&conf->resync_lock); in raise_barrier()
940 wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting, in raise_barrier()
941 conf->resync_lock); in raise_barrier()
944 conf->barrier++; in raise_barrier()
947 wait_event_lock_irq(conf->wait_barrier, in raise_barrier()
948 !atomic_read(&conf->nr_pending) && conf->barrier < RESYNC_DEPTH, in raise_barrier()
949 conf->resync_lock); in raise_barrier()
951 spin_unlock_irq(&conf->resync_lock); in raise_barrier()
954 static void lower_barrier(struct r10conf *conf) in lower_barrier() argument
957 spin_lock_irqsave(&conf->resync_lock, flags); in lower_barrier()
958 conf->barrier--; in lower_barrier()
959 spin_unlock_irqrestore(&conf->resync_lock, flags); in lower_barrier()
960 wake_up(&conf->wait_barrier); in lower_barrier()
963 static void wait_barrier(struct r10conf *conf) in wait_barrier() argument
965 spin_lock_irq(&conf->resync_lock); in wait_barrier()
966 if (conf->barrier) { in wait_barrier()
968 conf->nr_waiting++; in wait_barrier()
978 raid10_log(conf->mddev, "wait barrier"); in wait_barrier()
979 wait_event_lock_irq(conf->wait_barrier, in wait_barrier()
980 !conf->barrier || in wait_barrier()
981 (atomic_read(&conf->nr_pending) && in wait_barrier()
988 (conf->mddev->thread->tsk == current && in wait_barrier()
990 &conf->mddev->recovery) && in wait_barrier()
991 conf->nr_queued > 0), in wait_barrier()
992 conf->resync_lock); in wait_barrier()
993 conf->nr_waiting--; in wait_barrier()
994 if (!conf->nr_waiting) in wait_barrier()
995 wake_up(&conf->wait_barrier); in wait_barrier()
997 atomic_inc(&conf->nr_pending); in wait_barrier()
998 spin_unlock_irq(&conf->resync_lock); in wait_barrier()
1001 static void allow_barrier(struct r10conf *conf) in allow_barrier() argument
1003 if ((atomic_dec_and_test(&conf->nr_pending)) || in allow_barrier()
1004 (conf->array_freeze_pending)) in allow_barrier()
1005 wake_up(&conf->wait_barrier); in allow_barrier()
1008 static void freeze_array(struct r10conf *conf, int extra) in freeze_array() argument
1022 spin_lock_irq(&conf->resync_lock); in freeze_array()
1023 conf->array_freeze_pending++; in freeze_array()
1024 conf->barrier++; in freeze_array()
1025 conf->nr_waiting++; in freeze_array()
1026 wait_event_lock_irq_cmd(conf->wait_barrier, in freeze_array()
1027 atomic_read(&conf->nr_pending) == conf->nr_queued+extra, in freeze_array()
1028 conf->resync_lock, in freeze_array()
1029 flush_pending_writes(conf)); in freeze_array()
1031 conf->array_freeze_pending--; in freeze_array()
1032 spin_unlock_irq(&conf->resync_lock); in freeze_array()
1035 static void unfreeze_array(struct r10conf *conf) in unfreeze_array() argument
1038 spin_lock_irq(&conf->resync_lock); in unfreeze_array()
1039 conf->barrier--; in unfreeze_array()
1040 conf->nr_waiting--; in unfreeze_array()
1041 wake_up(&conf->wait_barrier); in unfreeze_array()
1042 spin_unlock_irq(&conf->resync_lock); in unfreeze_array()
1066 struct r10conf *conf = mddev->private; in raid10_unplug() local
1070 spin_lock_irq(&conf->device_lock); in raid10_unplug()
1071 bio_list_merge(&conf->pending_bio_list, &plug->pending); in raid10_unplug()
1072 conf->pending_count += plug->pending_cnt; in raid10_unplug()
1073 spin_unlock_irq(&conf->device_lock); in raid10_unplug()
1074 wake_up(&conf->wait_barrier); in raid10_unplug()
1083 wake_up(&conf->wait_barrier); in raid10_unplug()
1110 static void regular_request_wait(struct mddev *mddev, struct r10conf *conf, in regular_request_wait() argument
1113 wait_barrier(conf); in regular_request_wait()
1115 bio->bi_iter.bi_sector < conf->reshape_progress && in regular_request_wait()
1116 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { in regular_request_wait()
1117 raid10_log(conf->mddev, "wait reshape"); in regular_request_wait()
1118 allow_barrier(conf); in regular_request_wait()
1119 wait_event(conf->wait_barrier, in regular_request_wait()
1120 conf->reshape_progress <= bio->bi_iter.bi_sector || in regular_request_wait()
1121 conf->reshape_progress >= bio->bi_iter.bi_sector + in regular_request_wait()
1123 wait_barrier(conf); in regular_request_wait()
1130 struct r10conf *conf = mddev->private; in raid10_read_request() local
1145 * we must use the one in conf. in raid10_read_request()
1158 err_rdev = rcu_dereference(conf->mirrors[disk].rdev); in raid10_read_request()
1169 regular_request_wait(mddev, conf, bio, r10_bio->sectors); in raid10_read_request()
1170 rdev = read_balance(conf, r10_bio, &max_sectors); in raid10_read_request()
1187 gfp, &conf->bio_split); in raid10_read_request()
1189 allow_barrier(conf); in raid10_read_request()
1191 wait_barrier(conf); in raid10_read_request()
1231 struct r10conf *conf = mddev->private; in raid10_write_one_disk() local
1237 rdev = conf->mirrors[devnum].replacement; in raid10_write_one_disk()
1241 rdev = conf->mirrors[devnum].rdev; in raid10_write_one_disk()
1244 rdev = conf->mirrors[devnum].rdev; in raid10_write_one_disk()
1258 &conf->mirrors[devnum].rdev->flags) in raid10_write_one_disk()
1259 && enough(conf, devnum)) in raid10_write_one_disk()
1263 if (conf->mddev->gendisk) in raid10_write_one_disk()
1265 mbio, disk_devt(conf->mddev->gendisk), in raid10_write_one_disk()
1281 spin_lock_irqsave(&conf->device_lock, flags); in raid10_write_one_disk()
1282 bio_list_add(&conf->pending_bio_list, mbio); in raid10_write_one_disk()
1283 conf->pending_count++; in raid10_write_one_disk()
1284 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_write_one_disk()
1292 struct r10conf *conf = mddev->private; in raid10_write_request() local
1304 prepare_to_wait(&conf->wait_barrier, in raid10_write_request()
1311 finish_wait(&conf->wait_barrier, &w); in raid10_write_request()
1315 regular_request_wait(mddev, conf, bio, sectors); in raid10_write_request()
1318 ? (bio->bi_iter.bi_sector < conf->reshape_safe && in raid10_write_request()
1319 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) in raid10_write_request()
1320 : (bio->bi_iter.bi_sector + sectors > conf->reshape_safe && in raid10_write_request()
1321 bio->bi_iter.bi_sector < conf->reshape_progress))) { in raid10_write_request()
1323 mddev->reshape_position = conf->reshape_progress; in raid10_write_request()
1327 raid10_log(conf->mddev, "wait reshape metadata"); in raid10_write_request()
1331 conf->reshape_safe = mddev->reshape_position; in raid10_write_request()
1334 if (conf->pending_count >= max_queued_requests) { in raid10_write_request()
1337 wait_event(conf->wait_barrier, in raid10_write_request()
1338 conf->pending_count < max_queued_requests); in raid10_write_request()
1351 raid10_find_phys(conf, r10_bio); in raid10_write_request()
1357 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1361 rrdev = rcu_dereference(conf->mirrors[d].replacement); in raid10_write_request()
1367 rdev = rcu_dereference(conf->mirrors[d].rdev); in raid10_write_request()
1452 rdev_dec_pending(conf->mirrors[d].rdev, mddev); in raid10_write_request()
1457 rdev = conf->mirrors[d].replacement; in raid10_write_request()
1461 rdev = conf->mirrors[d].rdev; in raid10_write_request()
1466 allow_barrier(conf); in raid10_write_request()
1467 raid10_log(conf->mddev, "wait rdev %d blocked", blocked_rdev->raid_disk); in raid10_write_request()
1469 wait_barrier(conf); in raid10_write_request()
1478 GFP_NOIO, &conf->bio_split); in raid10_write_request()
1480 allow_barrier(conf); in raid10_write_request()
1482 wait_barrier(conf); in raid10_write_request()
1490 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1501 struct r10conf *conf = mddev->private; in __make_request() local
1504 r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO); in __make_request()
1513 memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * conf->copies); in __make_request()
1523 struct r10conf *conf = mddev->private; in raid10_make_request() local
1524 sector_t chunk_mask = (conf->geo.chunk_mask & conf->prev.chunk_mask); in raid10_make_request()
1541 && (conf->geo.near_copies < conf->geo.raid_disks in raid10_make_request()
1542 || conf->prev.near_copies < in raid10_make_request()
1543 conf->prev.raid_disks))) in raid10_make_request()
1550 wake_up(&conf->wait_barrier); in raid10_make_request()
1556 struct r10conf *conf = mddev->private; in raid10_status() local
1559 if (conf->geo.near_copies < conf->geo.raid_disks) in raid10_status()
1561 if (conf->geo.near_copies > 1) in raid10_status()
1562 seq_printf(seq, " %d near-copies", conf->geo.near_copies); in raid10_status()
1563 if (conf->geo.far_copies > 1) { in raid10_status()
1564 if (conf->geo.far_offset) in raid10_status()
1565 seq_printf(seq, " %d offset-copies", conf->geo.far_copies); in raid10_status()
1567 seq_printf(seq, " %d far-copies", conf->geo.far_copies); in raid10_status()
1568 if (conf->geo.far_set_size != conf->geo.raid_disks) in raid10_status()
1569 seq_printf(seq, " %d devices per set", conf->geo.far_set_size); in raid10_status()
1571 seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks, in raid10_status()
1572 conf->geo.raid_disks - mddev->degraded); in raid10_status()
1574 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_status()
1575 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in raid10_status()
1587 static int _enough(struct r10conf *conf, int previous, int ignore) in _enough() argument
1593 disks = conf->prev.raid_disks; in _enough()
1594 ncopies = conf->prev.near_copies; in _enough()
1596 disks = conf->geo.raid_disks; in _enough()
1597 ncopies = conf->geo.near_copies; in _enough()
1602 int n = conf->copies; in _enough()
1608 (rdev = rcu_dereference(conf->mirrors[this].rdev)) && in _enough()
1623 static int enough(struct r10conf *conf, int ignore) in enough() argument
1630 return _enough(conf, 0, ignore) && in enough()
1631 _enough(conf, 1, ignore); in enough()
1637 struct r10conf *conf = mddev->private; in raid10_error() local
1646 spin_lock_irqsave(&conf->device_lock, flags); in raid10_error()
1648 && !enough(conf, rdev->raid_disk)) { in raid10_error()
1652 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
1665 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
1669 mdname(mddev), conf->geo.raid_disks - mddev->degraded); in raid10_error()
1672 static void print_conf(struct r10conf *conf) in print_conf() argument
1677 pr_debug("RAID10 conf printout:\n"); in print_conf()
1678 if (!conf) { in print_conf()
1679 pr_debug("(!conf)\n"); in print_conf()
1682 pr_debug(" --- wd:%d rd:%d\n", conf->geo.raid_disks - conf->mddev->degraded, in print_conf()
1683 conf->geo.raid_disks); in print_conf()
1687 for (i = 0; i < conf->geo.raid_disks; i++) { in print_conf()
1689 rdev = conf->mirrors[i].rdev; in print_conf()
1698 static void close_sync(struct r10conf *conf) in close_sync() argument
1700 wait_barrier(conf); in close_sync()
1701 allow_barrier(conf); in close_sync()
1703 mempool_exit(&conf->r10buf_pool); in close_sync()
1709 struct r10conf *conf = mddev->private; in raid10_spare_active() local
1718 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_spare_active()
1719 tmp = conf->mirrors + i; in raid10_spare_active()
1746 spin_lock_irqsave(&conf->device_lock, flags); in raid10_spare_active()
1748 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_spare_active()
1750 print_conf(conf); in raid10_spare_active()
1756 struct r10conf *conf = mddev->private; in raid10_add_disk() local
1760 int last = conf->geo.raid_disks - 1; in raid10_add_disk()
1767 if (rdev->saved_raid_disk < 0 && !_enough(conf, 1, -1)) in raid10_add_disk()
1777 rdev->saved_raid_disk < conf->geo.raid_disks && in raid10_add_disk()
1778 conf->mirrors[rdev->saved_raid_disk].rdev == NULL) in raid10_add_disk()
1783 struct raid10_info *p = &conf->mirrors[mirror]; in raid10_add_disk()
1797 conf->fullsync = 1; in raid10_add_disk()
1811 conf->fullsync = 1; in raid10_add_disk()
1818 print_conf(conf); in raid10_add_disk()
1824 struct r10conf *conf = mddev->private; in raid10_remove_disk() local
1830 print_conf(conf); in raid10_remove_disk()
1833 p = conf->mirrors + number; in raid10_remove_disk()
1852 number < conf->geo.raid_disks && in raid10_remove_disk()
1853 enough(conf, -1)) { in raid10_remove_disk()
1882 print_conf(conf); in raid10_remove_disk()
1888 struct r10conf *conf = r10_bio->mddev->private; in __end_sync_read() local
1897 &conf->mirrors[d].rdev->corrected_errors); in __end_sync_read()
1902 rdev_dec_pending(conf->mirrors[d].rdev, conf->mddev); in __end_sync_read()
1915 struct r10conf *conf = r10_bio->mddev->private; in end_sync_read() local
1916 int d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); in end_sync_read()
1960 struct r10conf *conf = mddev->private; in end_sync_write() local
1968 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_sync_write()
1970 rdev = conf->mirrors[d].replacement; in end_sync_write()
1972 rdev = conf->mirrors[d].rdev; in end_sync_write()
2013 struct r10conf *conf = mddev->private; in sync_request_write() local
2022 for (i=0; i<conf->copies; i++) in sync_request_write()
2026 if (i == conf->copies) in sync_request_write()
2037 for (i=0 ; i < conf->copies ; i++) { in sync_request_write()
2051 rdev = conf->mirrors[d].rdev; in sync_request_write()
2097 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in sync_request_write()
2099 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(tbio)); in sync_request_write()
2101 if (test_bit(FailFast, &conf->mirrors[d].rdev->flags)) in sync_request_write()
2103 tbio->bi_iter.bi_sector += conf->mirrors[d].rdev->data_offset; in sync_request_write()
2104 bio_set_dev(tbio, conf->mirrors[d].rdev->bdev); in sync_request_write()
2111 for (i = 0; i < conf->copies; i++) { in sync_request_write()
2122 md_sync_acct(conf->mirrors[d].replacement->bdev, in sync_request_write()
2154 struct r10conf *conf = mddev->private; in fix_recovery_read_error() local
2172 rdev = conf->mirrors[dr].rdev; in fix_recovery_read_error()
2180 rdev = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2202 if (rdev != conf->mirrors[dw].rdev) { in fix_recovery_read_error()
2204 struct md_rdev *rdev2 = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2212 conf->mirrors[dw].recovery_disabled in fix_recovery_read_error()
2229 struct r10conf *conf = mddev->private; in recovery_request_write() local
2256 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in recovery_request_write()
2257 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); in recovery_request_write()
2261 atomic_inc(&conf->mirrors[d].replacement->nr_pending); in recovery_request_write()
2262 md_sync_acct(conf->mirrors[d].replacement->bdev, in recovery_request_write()
2336 static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10bio *r10_bio) in fix_read_error() argument
2347 rdev = conf->mirrors[d].rdev; in fix_read_error()
2385 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2397 conf->tmppage, in fix_read_error()
2405 if (sl == conf->copies) in fix_read_error()
2416 rdev = conf->mirrors[dn].rdev; in fix_read_error()
2437 sl = conf->copies; in fix_read_error()
2440 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2451 s, conf->tmppage, WRITE) in fix_read_error()
2473 sl = conf->copies; in fix_read_error()
2476 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2487 s, conf->tmppage, in fix_read_error()
2525 struct r10conf *conf = mddev->private; in narrow_write_error() local
2526 struct md_rdev *rdev = conf->mirrors[r10_bio->devs[i].devnum].rdev; in narrow_write_error()
2586 struct r10conf *conf = mddev->private; in handle_read_error() local
2604 freeze_array(conf, 1); in handle_read_error()
2605 fix_read_error(conf, mddev, r10_bio); in handle_read_error()
2606 unfreeze_array(conf); in handle_read_error()
2611 allow_barrier(conf); in handle_read_error()
2616 static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio) in handle_write_completed() argument
2629 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
2631 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
2645 md_error(conf->mddev, rdev); in handle_write_completed()
2647 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
2662 md_error(conf->mddev, rdev); in handle_write_completed()
2668 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
2671 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
2677 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2681 md_error(conf->mddev, rdev); in handle_write_completed()
2685 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2688 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
2694 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2698 spin_lock_irq(&conf->device_lock); in handle_write_completed()
2699 list_add(&r10_bio->retry_list, &conf->bio_end_io_list); in handle_write_completed()
2700 conf->nr_queued++; in handle_write_completed()
2701 spin_unlock_irq(&conf->device_lock); in handle_write_completed()
2706 wake_up(&conf->wait_barrier); in handle_write_completed()
2707 md_wakeup_thread(conf->mddev->thread); in handle_write_completed()
2722 struct r10conf *conf = mddev->private; in raid10d() local
2723 struct list_head *head = &conf->retry_list; in raid10d()
2728 if (!list_empty_careful(&conf->bio_end_io_list) && in raid10d()
2731 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
2733 while (!list_empty(&conf->bio_end_io_list)) { in raid10d()
2734 list_move(conf->bio_end_io_list.prev, &tmp); in raid10d()
2735 conf->nr_queued--; in raid10d()
2738 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
2756 flush_pending_writes(conf); in raid10d()
2758 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
2760 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
2765 conf->nr_queued--; in raid10d()
2766 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
2769 conf = mddev->private; in raid10d()
2772 handle_write_completed(conf, r10_bio); in raid10d()
2791 static int init_resync(struct r10conf *conf) in init_resync() argument
2796 BUG_ON(mempool_initialized(&conf->r10buf_pool)); in init_resync()
2797 conf->have_replacement = 0; in init_resync()
2798 for (i = 0; i < conf->geo.raid_disks; i++) in init_resync()
2799 if (conf->mirrors[i].replacement) in init_resync()
2800 conf->have_replacement = 1; in init_resync()
2801 ret = mempool_init(&conf->r10buf_pool, buffs, in init_resync()
2802 r10buf_pool_alloc, r10buf_pool_free, conf); in init_resync()
2805 conf->next_resync = 0; in init_resync()
2809 static struct r10bio *raid10_alloc_init_r10buf(struct r10conf *conf) in raid10_alloc_init_r10buf() argument
2811 struct r10bio *r10bio = mempool_alloc(&conf->r10buf_pool, GFP_NOIO); in raid10_alloc_init_r10buf()
2817 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in raid10_alloc_init_r10buf()
2818 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in raid10_alloc_init_r10buf()
2819 nalloc = conf->copies; /* resync */ in raid10_alloc_init_r10buf()
2842 static void raid10_set_cluster_sync_high(struct r10conf *conf) in raid10_set_cluster_sync_high() argument
2859 chunks = conf->geo.raid_disks / conf->geo.near_copies; in raid10_set_cluster_sync_high()
2860 if (conf->geo.raid_disks % conf->geo.near_copies == 0) in raid10_set_cluster_sync_high()
2864 window_size = (chunks + extra_chunk) * conf->mddev->chunk_sectors; in raid10_set_cluster_sync_high()
2872 conf->cluster_sync_high = conf->cluster_sync_low + window_size; in raid10_set_cluster_sync_high()
2910 struct r10conf *conf = mddev->private; in raid10_sync_request() local
2919 sector_t chunk_mask = conf->geo.chunk_mask; in raid10_sync_request()
2932 conf->fullsync == 0) { in raid10_sync_request()
2937 if (!mempool_initialized(&conf->r10buf_pool)) in raid10_sync_request()
2938 if (init_resync(conf)) in raid10_sync_request()
2947 conf->cluster_sync_low = 0; in raid10_sync_request()
2948 conf->cluster_sync_high = 0; in raid10_sync_request()
2960 end_reshape(conf); in raid10_sync_request()
2961 close_sync(conf); in raid10_sync_request()
2969 else for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
2971 raid10_find_virt(conf, mddev->curr_resync, i); in raid10_sync_request()
2977 if ((!mddev->bitmap || conf->fullsync) in raid10_sync_request()
2978 && conf->have_replacement in raid10_sync_request()
2984 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
2986 rcu_dereference(conf->mirrors[i].replacement); in raid10_sync_request()
2992 conf->fullsync = 0; in raid10_sync_request()
2995 close_sync(conf); in raid10_sync_request()
3003 if (chunks_skipped >= conf->geo.raid_disks) { in raid10_sync_request()
3017 if (conf->geo.near_copies < conf->geo.raid_disks && in raid10_sync_request()
3025 if (conf->nr_waiting) in raid10_sync_request()
3049 for (i = 0 ; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3056 struct raid10_info *mirror = &conf->mirrors[i]; in raid10_sync_request()
3078 sect = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3096 !conf->fullsync) { in raid10_sync_request()
3109 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3111 raise_barrier(conf, rb2 != NULL); in raid10_sync_request()
3121 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3127 for (j = 0; j < conf->geo.raid_disks; j++) { in raid10_sync_request()
3129 conf->mirrors[j].rdev); in raid10_sync_request()
3140 for (j=0; j<conf->copies;j++) { in raid10_sync_request()
3145 rcu_dereference(conf->mirrors[d].rdev); in raid10_sync_request()
3181 for (k=0; k<conf->copies; k++) in raid10_sync_request()
3184 BUG_ON(k == conf->copies); in raid10_sync_request()
3225 if (j == conf->copies) { in raid10_sync_request()
3233 for (k = 0; k < conf->copies; k++) in raid10_sync_request()
3276 for (; j < conf->copies; j++) { in raid10_sync_request()
3278 if (conf->mirrors[d].rdev && in raid10_sync_request()
3280 &conf->mirrors[d].rdev->flags)) in raid10_sync_request()
3310 (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); in raid10_sync_request()
3314 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, in raid10_sync_request()
3322 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3327 raise_barrier(conf, 0); in raid10_sync_request()
3328 conf->next_resync = sector_nr; in raid10_sync_request()
3333 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3336 for (i = 0; i < conf->copies; i++) { in raid10_sync_request()
3348 rdev = rcu_dereference(conf->mirrors[d].rdev); in raid10_sync_request()
3378 rdev = rcu_dereference(conf->mirrors[d].replacement); in raid10_sync_request()
3403 for (i=0; i<conf->copies; i++) { in raid10_sync_request()
3406 rdev_dec_pending(conf->mirrors[d].rdev, in raid10_sync_request()
3411 conf->mirrors[d].replacement, in raid10_sync_request()
3447 if (conf->cluster_sync_high < sector_nr + nr_sectors) { in raid10_sync_request()
3448 conf->cluster_sync_low = mddev->curr_resync_completed; in raid10_sync_request()
3449 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3452 conf->cluster_sync_low, in raid10_sync_request()
3453 conf->cluster_sync_high); in raid10_sync_request()
3460 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3466 sect_va1 = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3468 if (conf->cluster_sync_high < sect_va1 + nr_sectors) { in raid10_sync_request()
3474 sect_va2 = raid10_find_virt(conf, in raid10_sync_request()
3477 if (conf->cluster_sync_low == 0 || in raid10_sync_request()
3478 conf->cluster_sync_low > sect_va2) in raid10_sync_request()
3479 conf->cluster_sync_low = sect_va2; in raid10_sync_request()
3483 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3485 conf->cluster_sync_low, in raid10_sync_request()
3486 conf->cluster_sync_high); in raid10_sync_request()
3530 struct r10conf *conf = mddev->private; in raid10_size() local
3533 raid_disks = min(conf->geo.raid_disks, in raid10_size()
3534 conf->prev.raid_disks); in raid10_size()
3536 sectors = conf->dev_sectors; in raid10_size()
3538 size = sectors >> conf->geo.chunk_shift; in raid10_size()
3539 sector_div(size, conf->geo.far_copies); in raid10_size()
3541 sector_div(size, conf->geo.near_copies); in raid10_size()
3543 return size << conf->geo.chunk_shift; in raid10_size()
3546 static void calc_sectors(struct r10conf *conf, sector_t size) in calc_sectors() argument
3549 * actually be used, and set conf->dev_sectors and in calc_sectors()
3550 * conf->stride in calc_sectors()
3553 size = size >> conf->geo.chunk_shift; in calc_sectors()
3554 sector_div(size, conf->geo.far_copies); in calc_sectors()
3555 size = size * conf->geo.raid_disks; in calc_sectors()
3556 sector_div(size, conf->geo.near_copies); in calc_sectors()
3559 size = size * conf->copies; in calc_sectors()
3564 size = DIV_ROUND_UP_SECTOR_T(size, conf->geo.raid_disks); in calc_sectors()
3566 conf->dev_sectors = size << conf->geo.chunk_shift; in calc_sectors()
3568 if (conf->geo.far_offset) in calc_sectors()
3569 conf->geo.stride = 1 << conf->geo.chunk_shift; in calc_sectors()
3571 sector_div(size, conf->geo.far_copies); in calc_sectors()
3572 conf->geo.stride = size << conf->geo.chunk_shift; in calc_sectors()
3633 static void raid10_free_conf(struct r10conf *conf) in raid10_free_conf() argument
3635 if (!conf) in raid10_free_conf()
3638 mempool_exit(&conf->r10bio_pool); in raid10_free_conf()
3639 kfree(conf->mirrors); in raid10_free_conf()
3640 kfree(conf->mirrors_old); in raid10_free_conf()
3641 kfree(conf->mirrors_new); in raid10_free_conf()
3642 safe_put_page(conf->tmppage); in raid10_free_conf()
3643 bioset_exit(&conf->bio_split); in raid10_free_conf()
3644 kfree(conf); in raid10_free_conf()
3649 struct r10conf *conf = NULL; in setup_conf() local
3669 conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL); in setup_conf()
3670 if (!conf) in setup_conf()
3674 conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), in setup_conf()
3677 if (!conf->mirrors) in setup_conf()
3680 conf->tmppage = alloc_page(GFP_KERNEL); in setup_conf()
3681 if (!conf->tmppage) in setup_conf()
3684 conf->geo = geo; in setup_conf()
3685 conf->copies = copies; in setup_conf()
3686 err = mempool_init(&conf->r10bio_pool, NR_RAID_BIOS, r10bio_pool_alloc, in setup_conf()
3687 rbio_pool_free, conf); in setup_conf()
3691 err = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0); in setup_conf()
3695 calc_sectors(conf, mddev->dev_sectors); in setup_conf()
3697 conf->prev = conf->geo; in setup_conf()
3698 conf->reshape_progress = MaxSector; in setup_conf()
3700 if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) { in setup_conf()
3704 conf->reshape_progress = mddev->reshape_position; in setup_conf()
3705 if (conf->prev.far_offset) in setup_conf()
3706 conf->prev.stride = 1 << conf->prev.chunk_shift; in setup_conf()
3709 conf->prev.stride = conf->dev_sectors; in setup_conf()
3711 conf->reshape_safe = conf->reshape_progress; in setup_conf()
3712 spin_lock_init(&conf->device_lock); in setup_conf()
3713 INIT_LIST_HEAD(&conf->retry_list); in setup_conf()
3714 INIT_LIST_HEAD(&conf->bio_end_io_list); in setup_conf()
3716 spin_lock_init(&conf->resync_lock); in setup_conf()
3717 init_waitqueue_head(&conf->wait_barrier); in setup_conf()
3718 atomic_set(&conf->nr_pending, 0); in setup_conf()
3721 conf->thread = md_register_thread(raid10d, mddev, "raid10"); in setup_conf()
3722 if (!conf->thread) in setup_conf()
3725 conf->mddev = mddev; in setup_conf()
3726 return conf; in setup_conf()
3729 raid10_free_conf(conf); in setup_conf()
3733 static void raid10_set_io_opt(struct r10conf *conf) in raid10_set_io_opt() argument
3735 int raid_disks = conf->geo.raid_disks; in raid10_set_io_opt()
3737 if (!(conf->geo.raid_disks % conf->geo.near_copies)) in raid10_set_io_opt()
3738 raid_disks /= conf->geo.near_copies; in raid10_set_io_opt()
3739 blk_queue_io_opt(conf->mddev->queue, (conf->mddev->chunk_sectors << 9) * in raid10_set_io_opt()
3745 struct r10conf *conf; in raid10_run() local
3758 conf = setup_conf(mddev); in raid10_run()
3759 if (IS_ERR(conf)) in raid10_run()
3760 return PTR_ERR(conf); in raid10_run()
3761 mddev->private = conf; in raid10_run()
3763 conf = mddev->private; in raid10_run()
3764 if (!conf) in raid10_run()
3767 mddev->thread = conf->thread; in raid10_run()
3768 conf->thread = NULL; in raid10_run()
3770 if (mddev_is_clustered(conf->mddev)) { in raid10_run()
3788 raid10_set_io_opt(conf); in raid10_run()
3797 if (disk_idx >= conf->geo.raid_disks && in raid10_run()
3798 disk_idx >= conf->prev.raid_disks) in raid10_run()
3800 disk = conf->mirrors + disk_idx; in raid10_run()
3839 if (!enough(conf, -1)) { in raid10_run()
3845 if (conf->reshape_progress != MaxSector) { in raid10_run()
3847 if (conf->geo.far_copies != 1 && in raid10_run()
3848 conf->geo.far_offset == 0) in raid10_run()
3850 if (conf->prev.far_copies != 1 && in raid10_run()
3851 conf->prev.far_offset == 0) in raid10_run()
3857 i < conf->geo.raid_disks in raid10_run()
3858 || i < conf->prev.raid_disks; in raid10_run()
3861 disk = conf->mirrors + i; in raid10_run()
3876 conf->fullsync = 1; in raid10_run()
3882 conf->fullsync = 1; in raid10_run()
3892 mdname(mddev), conf->geo.raid_disks - mddev->degraded, in raid10_run()
3893 conf->geo.raid_disks); in raid10_run()
3897 mddev->dev_sectors = conf->dev_sectors; in raid10_run()
3906 if (conf->reshape_progress != MaxSector) { in raid10_run()
3909 before_length = ((1 << conf->prev.chunk_shift) * in raid10_run()
3910 conf->prev.far_copies); in raid10_run()
3911 after_length = ((1 << conf->geo.chunk_shift) * in raid10_run()
3912 conf->geo.far_copies); in raid10_run()
3919 conf->offset_diff = min_offset_diff; in raid10_run()
3935 raid10_free_conf(conf); in raid10_run()
3948 struct r10conf *conf = mddev->private; in raid10_quiesce() local
3951 raise_barrier(conf, 0); in raid10_quiesce()
3953 lower_barrier(conf); in raid10_quiesce()
3970 struct r10conf *conf = mddev->private; in raid10_resize() local
3976 if (conf->geo.far_copies > 1 && !conf->geo.far_offset) in raid10_resize()
3995 calc_sectors(conf, sectors); in raid10_resize()
3996 mddev->dev_sectors = conf->dev_sectors; in raid10_resize()
4004 struct r10conf *conf; in raid10_takeover_raid0() local
4024 conf = setup_conf(mddev); in raid10_takeover_raid0()
4025 if (!IS_ERR(conf)) { in raid10_takeover_raid0()
4031 conf->barrier = 1; in raid10_takeover_raid0()
4034 return conf; in raid10_takeover_raid0()
4075 struct r10conf *conf = mddev->private; in raid10_check_reshape() local
4078 if (conf->geo.far_copies != 1 && !conf->geo.far_offset) in raid10_check_reshape()
4081 if (setup_geo(&geo, mddev, geo_start) != conf->copies) in raid10_check_reshape()
4092 if (!enough(conf, -1)) in raid10_check_reshape()
4095 kfree(conf->mirrors_new); in raid10_check_reshape()
4096 conf->mirrors_new = NULL; in raid10_check_reshape()
4099 conf->mirrors_new = in raid10_check_reshape()
4103 if (!conf->mirrors_new) in raid10_check_reshape()
4122 static int calc_degraded(struct r10conf *conf) in calc_degraded() argument
4130 for (i = 0; i < conf->prev.raid_disks; i++) { in calc_degraded()
4131 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in calc_degraded()
4142 if (conf->geo.raid_disks == conf->prev.raid_disks) in calc_degraded()
4146 for (i = 0; i < conf->geo.raid_disks; i++) { in calc_degraded()
4147 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in calc_degraded()
4156 if (conf->geo.raid_disks <= conf->prev.raid_disks) in calc_degraded()
4182 struct r10conf *conf = mddev->private; in raid10_start_reshape() local
4190 if (setup_geo(&new, mddev, geo_start) != conf->copies) in raid10_start_reshape()
4193 before_length = ((1 << conf->prev.chunk_shift) * in raid10_start_reshape()
4194 conf->prev.far_copies); in raid10_start_reshape()
4195 after_length = ((1 << conf->geo.chunk_shift) * in raid10_start_reshape()
4196 conf->geo.far_copies); in raid10_start_reshape()
4221 conf->offset_diff = min_offset_diff; in raid10_start_reshape()
4222 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4223 if (conf->mirrors_new) { in raid10_start_reshape()
4224 memcpy(conf->mirrors_new, conf->mirrors, in raid10_start_reshape()
4225 sizeof(struct raid10_info)*conf->prev.raid_disks); in raid10_start_reshape()
4227 kfree(conf->mirrors_old); in raid10_start_reshape()
4228 conf->mirrors_old = conf->mirrors; in raid10_start_reshape()
4229 conf->mirrors = conf->mirrors_new; in raid10_start_reshape()
4230 conf->mirrors_new = NULL; in raid10_start_reshape()
4232 setup_geo(&conf->geo, mddev, geo_start); in raid10_start_reshape()
4237 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4243 conf->reshape_progress = size; in raid10_start_reshape()
4245 conf->reshape_progress = 0; in raid10_start_reshape()
4246 conf->reshape_safe = conf->reshape_progress; in raid10_start_reshape()
4247 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4254 newsize = raid10_size(mddev, 0, conf->geo.raid_disks); in raid10_start_reshape()
4296 conf->prev.raid_disks) in raid10_start_reshape()
4304 } else if (rdev->raid_disk >= conf->prev.raid_disks in raid10_start_reshape()
4314 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4315 mddev->degraded = calc_degraded(conf); in raid10_start_reshape()
4316 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4317 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4318 mddev->reshape_position = conf->reshape_progress; in raid10_start_reshape()
4333 conf->reshape_checkpoint = jiffies; in raid10_start_reshape()
4340 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4341 conf->geo = conf->prev; in raid10_start_reshape()
4342 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4346 conf->reshape_progress = MaxSector; in raid10_start_reshape()
4347 conf->reshape_safe = MaxSector; in raid10_start_reshape()
4349 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4414 * (conf->offset_diff - always positive) allows a bit of slack, in reshape_request()
4424 struct r10conf *conf = mddev->private; in reshape_request() local
4440 conf->reshape_progress < raid10_size(mddev, 0, 0)) { in reshape_request()
4442 - conf->reshape_progress); in reshape_request()
4444 conf->reshape_progress > 0) in reshape_request()
4445 sector_nr = conf->reshape_progress; in reshape_request()
4462 next = first_dev_address(conf->reshape_progress - 1, in reshape_request()
4463 &conf->geo); in reshape_request()
4468 safe = last_dev_address(conf->reshape_safe - 1, in reshape_request()
4469 &conf->prev); in reshape_request()
4471 if (next + conf->offset_diff < safe) in reshape_request()
4474 last = conf->reshape_progress - 1; in reshape_request()
4475 sector_nr = last & ~(sector_t)(conf->geo.chunk_mask in reshape_request()
4476 & conf->prev.chunk_mask); in reshape_request()
4483 next = last_dev_address(conf->reshape_progress, &conf->geo); in reshape_request()
4488 safe = first_dev_address(conf->reshape_safe, &conf->prev); in reshape_request()
4493 if (next > safe + conf->offset_diff) in reshape_request()
4496 sector_nr = conf->reshape_progress; in reshape_request()
4497 last = sector_nr | (conf->geo.chunk_mask in reshape_request()
4498 & conf->prev.chunk_mask); in reshape_request()
4505 time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) { in reshape_request()
4507 wait_barrier(conf); in reshape_request()
4508 mddev->reshape_position = conf->reshape_progress; in reshape_request()
4511 - conf->reshape_progress; in reshape_request()
4513 mddev->curr_resync_completed = conf->reshape_progress; in reshape_request()
4514 conf->reshape_checkpoint = jiffies; in reshape_request()
4520 allow_barrier(conf); in reshape_request()
4523 conf->reshape_safe = mddev->reshape_position; in reshape_request()
4524 allow_barrier(conf); in reshape_request()
4527 raise_barrier(conf, 0); in reshape_request()
4530 r10_bio = raid10_alloc_init_r10buf(conf); in reshape_request()
4532 raise_barrier(conf, 1); in reshape_request()
4538 rdev = read_balance(conf, r10_bio, &max_sectors); in reshape_request()
4546 mempool_free(r10_bio, &conf->r10buf_pool); in reshape_request()
4570 if (mddev_is_clustered(mddev) && conf->cluster_sync_high <= sector_nr) { in reshape_request()
4574 conf->cluster_sync_low = sector_nr; in reshape_request()
4575 conf->cluster_sync_high = sector_nr + CLUSTER_RESYNC_WINDOW_SECTORS; in reshape_request()
4584 if (sb_reshape_pos < conf->cluster_sync_low) in reshape_request()
4585 conf->cluster_sync_low = sb_reshape_pos; in reshape_request()
4588 md_cluster_ops->resync_info_update(mddev, conf->cluster_sync_low, in reshape_request()
4589 conf->cluster_sync_high); in reshape_request()
4593 __raid10_find_phys(&conf->geo, r10_bio); in reshape_request()
4599 for (s = 0; s < conf->copies*2; s++) { in reshape_request()
4604 rdev2 = rcu_dereference(conf->mirrors[d].replacement); in reshape_request()
4607 rdev2 = rcu_dereference(conf->mirrors[d].rdev); in reshape_request()
4653 lower_barrier(conf); in reshape_request()
4659 conf->reshape_progress -= sectors_done; in reshape_request()
4661 conf->reshape_progress += sectors_done; in reshape_request()
4676 struct r10conf *conf = mddev->private; in reshape_request_write() local
4690 for (s = 0; s < conf->copies*2; s++) { in reshape_request_write()
4696 rdev = rcu_dereference(conf->mirrors[d].replacement); in reshape_request_write()
4699 rdev = rcu_dereference(conf->mirrors[d].rdev); in reshape_request_write()
4716 static void end_reshape(struct r10conf *conf) in end_reshape() argument
4718 if (test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) in end_reshape()
4721 spin_lock_irq(&conf->device_lock); in end_reshape()
4722 conf->prev = conf->geo; in end_reshape()
4723 md_finish_reshape(conf->mddev); in end_reshape()
4725 conf->reshape_progress = MaxSector; in end_reshape()
4726 conf->reshape_safe = MaxSector; in end_reshape()
4727 spin_unlock_irq(&conf->device_lock); in end_reshape()
4729 if (conf->mddev->queue) in end_reshape()
4730 raid10_set_io_opt(conf); in end_reshape()
4731 conf->fullsync = 0; in end_reshape()
4736 struct r10conf *conf = mddev->private; in raid10_update_reshape_pos() local
4742 conf->reshape_progress = mddev->reshape_position; in raid10_update_reshape_pos()
4752 struct r10conf *conf = mddev->private; in handle_reshape_read_error() local
4758 r10b = kmalloc(struct_size(r10b, devs, conf->copies), GFP_NOIO); in handle_reshape_read_error()
4768 __raid10_find_phys(&conf->prev, r10b); in handle_reshape_read_error()
4781 struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev); in handle_reshape_read_error()
4802 if (slot >= conf->copies) in handle_reshape_read_error()
4826 struct r10conf *conf = mddev->private; in end_reshape_write() local
4832 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_reshape_write()
4834 rdev = conf->mirrors[d].replacement; in end_reshape_write()
4837 rdev = conf->mirrors[d].rdev; in end_reshape_write()
4860 struct r10conf *conf = mddev->private; in raid10_finish_reshape() local
4874 for (d = conf->geo.raid_disks ; in raid10_finish_reshape()
4875 d < conf->geo.raid_disks - mddev->delta_disks; in raid10_finish_reshape()
4877 struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev); in raid10_finish_reshape()
4880 rdev = rcu_dereference(conf->mirrors[d].replacement); in raid10_finish_reshape()
4887 mddev->chunk_sectors = 1 << conf->geo.chunk_shift; in raid10_finish_reshape()