Lines Matching refs: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);
83 #define cmd_before(conf, cmd) \ argument
85 write_sequnlock_irq(&(conf)->resync_lock); \
88 #define cmd_after(conf) write_seqlock_irq(&(conf)->resync_lock) argument
90 #define wait_event_barrier_cmd(conf, cond, cmd) \ argument
91 wait_event_cmd((conf)->wait_barrier, cond, cmd_before(conf, cmd), \
92 cmd_after(conf))
94 #define wait_event_barrier(conf, cond) \ argument
95 wait_event_barrier_cmd(conf, cond, NULL_CMD)
108 struct r10conf *conf = data; in r10bio_pool_alloc() local
109 int size = offsetof(struct r10bio, devs[conf->geo.raid_disks]); in r10bio_pool_alloc()
133 struct r10conf *conf = data; in r10buf_pool_alloc() local
140 r10_bio = r10bio_pool_alloc(gfp_flags, conf); in r10buf_pool_alloc()
144 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in r10buf_pool_alloc()
145 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in r10buf_pool_alloc()
146 nalloc = conf->copies; /* resync */ in r10buf_pool_alloc()
151 if (!conf->have_replacement) in r10buf_pool_alloc()
168 if (!conf->have_replacement) in r10buf_pool_alloc()
191 &conf->mddev->recovery)) { in r10buf_pool_alloc()
225 rbio_pool_free(r10_bio, conf); in r10buf_pool_alloc()
231 struct r10conf *conf = data; in r10buf_pool_free() local
236 for (j = conf->copies; j--; ) { in r10buf_pool_free()
256 rbio_pool_free(r10bio, conf); in r10buf_pool_free()
259 static void put_all_bios(struct r10conf *conf, struct r10bio *r10_bio) in put_all_bios() argument
263 for (i = 0; i < conf->geo.raid_disks; i++) { in put_all_bios()
277 struct r10conf *conf = r10_bio->mddev->private; in free_r10bio() local
279 put_all_bios(conf, r10_bio); in free_r10bio()
280 mempool_free(r10_bio, &conf->r10bio_pool); in free_r10bio()
285 struct r10conf *conf = r10_bio->mddev->private; in put_buf() local
287 mempool_free(r10_bio, &conf->r10buf_pool); in put_buf()
289 lower_barrier(conf); in put_buf()
292 static void wake_up_barrier(struct r10conf *conf) in wake_up_barrier() argument
294 if (wq_has_sleeper(&conf->wait_barrier)) in wake_up_barrier()
295 wake_up(&conf->wait_barrier); in wake_up_barrier()
302 struct r10conf *conf = mddev->private; in reschedule_retry() local
304 spin_lock_irqsave(&conf->device_lock, flags); in reschedule_retry()
305 list_add(&r10_bio->retry_list, &conf->retry_list); in reschedule_retry()
306 conf->nr_queued ++; in reschedule_retry()
307 spin_unlock_irqrestore(&conf->device_lock, flags); in reschedule_retry()
310 wake_up(&conf->wait_barrier); in reschedule_retry()
323 struct r10conf *conf = r10_bio->mddev->private; in raid_end_bio_io() local
333 allow_barrier(conf); in raid_end_bio_io()
343 struct r10conf *conf = r10_bio->mddev->private; in update_head_pos() local
345 conf->mirrors[r10_bio->devs[slot].devnum].head_position = in update_head_pos()
352 static int find_bio_disk(struct r10conf *conf, struct r10bio *r10_bio, in find_bio_disk() argument
358 for (slot = 0; slot < conf->geo.raid_disks; slot++) { in find_bio_disk()
382 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_read_request() local
408 if (!_enough(conf, test_bit(R10BIO_Previous, &r10_bio->state), in raid10_end_read_request()
414 rdev_dec_pending(rdev, conf->mddev); in raid10_end_read_request()
420 mdname(conf->mddev), in raid10_end_read_request()
458 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_write_request() local
466 dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in raid10_end_write_request()
469 rdev = conf->mirrors[dev].replacement; in raid10_end_write_request()
473 rdev = conf->mirrors[dev].rdev; in raid10_end_write_request()
557 rdev_dec_pending(rdev, conf->mddev); in raid10_end_write_request()
650 static void raid10_find_phys(struct r10conf *conf, struct r10bio *r10bio) in raid10_find_phys() argument
652 struct geom *geo = &conf->geo; in raid10_find_phys()
654 if (conf->reshape_progress != MaxSector && in raid10_find_phys()
655 ((r10bio->sector >= conf->reshape_progress) != in raid10_find_phys()
656 conf->mddev->reshape_backwards)) { in raid10_find_phys()
658 geo = &conf->prev; in raid10_find_phys()
665 static sector_t raid10_find_virt(struct r10conf *conf, sector_t sector, int dev) in raid10_find_virt() argument
671 struct geom *geo = &conf->geo; in raid10_find_virt()
729 static struct md_rdev *read_balance(struct r10conf *conf, in read_balance() argument
743 struct geom *geo = &conf->geo; in read_balance()
745 raid10_find_phys(conf, r10_bio); in read_balance()
761 if ((conf->mddev->recovery_cp < MaxSector in read_balance()
762 && (this_sector + sectors >= conf->next_resync)) || in read_balance()
763 (mddev_is_clustered(conf->mddev) && in read_balance()
764 md_cluster_ops->area_resyncing(conf->mddev, READ, this_sector, in read_balance()
768 for (slot = 0; slot < conf->copies ; slot++) { in read_balance()
778 rdev = rcu_dereference(conf->mirrors[disk].replacement); in read_balance()
788 rdev = rcu_dereference(conf->mirrors[disk].rdev); in read_balance()
856 conf->mirrors[disk].head_position); in read_balance()
864 if (slot >= conf->copies) { in read_balance()
885 static void flush_pending_writes(struct r10conf *conf) in flush_pending_writes() argument
890 spin_lock_irq(&conf->device_lock); in flush_pending_writes()
892 if (conf->pending_bio_list.head) { in flush_pending_writes()
896 bio = bio_list_get(&conf->pending_bio_list); in flush_pending_writes()
897 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
911 raid1_prepare_flush_writes(conf->mddev->bitmap); in flush_pending_writes()
912 wake_up(&conf->wait_barrier); in flush_pending_writes()
923 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
948 static void raise_barrier(struct r10conf *conf, int force) in raise_barrier() argument
950 write_seqlock_irq(&conf->resync_lock); in raise_barrier()
952 if (WARN_ON_ONCE(force && !conf->barrier)) in raise_barrier()
956 wait_event_barrier(conf, force || !conf->nr_waiting); in raise_barrier()
959 WRITE_ONCE(conf->barrier, conf->barrier + 1); in raise_barrier()
962 wait_event_barrier(conf, !atomic_read(&conf->nr_pending) && in raise_barrier()
963 conf->barrier < RESYNC_DEPTH); in raise_barrier()
965 write_sequnlock_irq(&conf->resync_lock); in raise_barrier()
968 static void lower_barrier(struct r10conf *conf) in lower_barrier() argument
972 write_seqlock_irqsave(&conf->resync_lock, flags); in lower_barrier()
973 WRITE_ONCE(conf->barrier, conf->barrier - 1); in lower_barrier()
974 write_sequnlock_irqrestore(&conf->resync_lock, flags); in lower_barrier()
975 wake_up(&conf->wait_barrier); in lower_barrier()
978 static bool stop_waiting_barrier(struct r10conf *conf) in stop_waiting_barrier() argument
984 if (!conf->barrier) in stop_waiting_barrier()
993 if (atomic_read(&conf->nr_pending) && bio_list && in stop_waiting_barrier()
998 thread = rcu_dereference_protected(conf->mddev->thread, true); in stop_waiting_barrier()
1005 WARN_ON_ONCE(atomic_read(&conf->nr_pending) == 0); in stop_waiting_barrier()
1012 static bool wait_barrier_nolock(struct r10conf *conf) in wait_barrier_nolock() argument
1014 unsigned int seq = read_seqbegin(&conf->resync_lock); in wait_barrier_nolock()
1016 if (READ_ONCE(conf->barrier)) in wait_barrier_nolock()
1019 atomic_inc(&conf->nr_pending); in wait_barrier_nolock()
1020 if (!read_seqretry(&conf->resync_lock, seq)) in wait_barrier_nolock()
1023 if (atomic_dec_and_test(&conf->nr_pending)) in wait_barrier_nolock()
1024 wake_up_barrier(conf); in wait_barrier_nolock()
1029 static bool wait_barrier(struct r10conf *conf, bool nowait) in wait_barrier() argument
1033 if (wait_barrier_nolock(conf)) in wait_barrier()
1036 write_seqlock_irq(&conf->resync_lock); in wait_barrier()
1037 if (conf->barrier) { in wait_barrier()
1042 conf->nr_waiting++; in wait_barrier()
1043 raid10_log(conf->mddev, "wait barrier"); in wait_barrier()
1044 wait_event_barrier(conf, stop_waiting_barrier(conf)); in wait_barrier()
1045 conf->nr_waiting--; in wait_barrier()
1047 if (!conf->nr_waiting) in wait_barrier()
1048 wake_up(&conf->wait_barrier); in wait_barrier()
1052 atomic_inc(&conf->nr_pending); in wait_barrier()
1053 write_sequnlock_irq(&conf->resync_lock); in wait_barrier()
1057 static void allow_barrier(struct r10conf *conf) in allow_barrier() argument
1059 if ((atomic_dec_and_test(&conf->nr_pending)) || in allow_barrier()
1060 (conf->array_freeze_pending)) in allow_barrier()
1061 wake_up_barrier(conf); in allow_barrier()
1064 static void freeze_array(struct r10conf *conf, int extra) in freeze_array() argument
1078 write_seqlock_irq(&conf->resync_lock); in freeze_array()
1079 conf->array_freeze_pending++; in freeze_array()
1080 WRITE_ONCE(conf->barrier, conf->barrier + 1); in freeze_array()
1081 conf->nr_waiting++; in freeze_array()
1082 wait_event_barrier_cmd(conf, atomic_read(&conf->nr_pending) == in freeze_array()
1083 conf->nr_queued + extra, flush_pending_writes(conf)); in freeze_array()
1084 conf->array_freeze_pending--; in freeze_array()
1085 write_sequnlock_irq(&conf->resync_lock); in freeze_array()
1088 static void unfreeze_array(struct r10conf *conf) in unfreeze_array() argument
1091 write_seqlock_irq(&conf->resync_lock); in unfreeze_array()
1092 WRITE_ONCE(conf->barrier, conf->barrier - 1); in unfreeze_array()
1093 conf->nr_waiting--; in unfreeze_array()
1094 wake_up(&conf->wait_barrier); in unfreeze_array()
1095 write_sequnlock_irq(&conf->resync_lock); in unfreeze_array()
1112 struct r10conf *conf = mddev->private; in raid10_unplug() local
1116 spin_lock_irq(&conf->device_lock); in raid10_unplug()
1117 bio_list_merge(&conf->pending_bio_list, &plug->pending); in raid10_unplug()
1118 spin_unlock_irq(&conf->device_lock); in raid10_unplug()
1119 wake_up_barrier(conf); in raid10_unplug()
1128 wake_up_barrier(conf); in raid10_unplug()
1146 static bool regular_request_wait(struct mddev *mddev, struct r10conf *conf, in regular_request_wait() argument
1150 if (!wait_barrier(conf, bio->bi_opf & REQ_NOWAIT)) { in regular_request_wait()
1155 bio->bi_iter.bi_sector < conf->reshape_progress && in regular_request_wait()
1156 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { in regular_request_wait()
1157 allow_barrier(conf); in regular_request_wait()
1162 raid10_log(conf->mddev, "wait reshape"); in regular_request_wait()
1163 wait_event(conf->wait_barrier, in regular_request_wait()
1164 conf->reshape_progress <= bio->bi_iter.bi_sector || in regular_request_wait()
1165 conf->reshape_progress >= bio->bi_iter.bi_sector + in regular_request_wait()
1167 wait_barrier(conf, false); in regular_request_wait()
1175 struct r10conf *conf = mddev->private; in raid10_read_request() local
1203 err_rdev = rcu_dereference(conf->mirrors[disk].rdev); in raid10_read_request()
1214 if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors)) in raid10_read_request()
1216 rdev = read_balance(conf, r10_bio, &max_sectors); in raid10_read_request()
1233 gfp, &conf->bio_split); in raid10_read_request()
1235 allow_barrier(conf); in raid10_read_request()
1237 wait_barrier(conf, false); in raid10_read_request()
1277 struct r10conf *conf = mddev->private; in raid10_write_one_disk() local
1283 rdev = conf->mirrors[devnum].replacement; in raid10_write_one_disk()
1287 rdev = conf->mirrors[devnum].rdev; in raid10_write_one_disk()
1290 rdev = conf->mirrors[devnum].rdev; in raid10_write_one_disk()
1303 &conf->mirrors[devnum].rdev->flags) in raid10_write_one_disk()
1304 && enough(conf, devnum)) in raid10_write_one_disk()
1308 if (conf->mddev->gendisk) in raid10_write_one_disk()
1309 trace_block_bio_remap(mbio, disk_devt(conf->mddev->gendisk), in raid10_write_one_disk()
1316 if (!raid1_add_bio_to_plug(mddev, mbio, raid10_unplug, conf->copies)) { in raid10_write_one_disk()
1317 spin_lock_irqsave(&conf->device_lock, flags); in raid10_write_one_disk()
1318 bio_list_add(&conf->pending_bio_list, mbio); in raid10_write_one_disk()
1319 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_write_one_disk()
1346 struct r10conf *conf = mddev->private; in wait_blocked_dev() local
1352 for (i = 0; i < conf->copies; i++) { in wait_blocked_dev()
1355 rdev = dereference_rdev_and_rrdev(&conf->mirrors[i], &rrdev); in wait_blocked_dev()
1398 allow_barrier(conf); in wait_blocked_dev()
1399 raid10_log(conf->mddev, "%s wait rdev %d blocked", in wait_blocked_dev()
1402 wait_barrier(conf, false); in wait_blocked_dev()
1410 struct r10conf *conf = mddev->private; in raid10_write_request() local
1426 prepare_to_wait(&conf->wait_barrier, in raid10_write_request()
1433 finish_wait(&conf->wait_barrier, &w); in raid10_write_request()
1437 if (!regular_request_wait(mddev, conf, bio, sectors)) in raid10_write_request()
1441 ? (bio->bi_iter.bi_sector < conf->reshape_safe && in raid10_write_request()
1442 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) in raid10_write_request()
1443 : (bio->bi_iter.bi_sector + sectors > conf->reshape_safe && in raid10_write_request()
1444 bio->bi_iter.bi_sector < conf->reshape_progress))) { in raid10_write_request()
1446 mddev->reshape_position = conf->reshape_progress; in raid10_write_request()
1451 allow_barrier(conf); in raid10_write_request()
1455 raid10_log(conf->mddev, "wait reshape metadata"); in raid10_write_request()
1459 conf->reshape_safe = mddev->reshape_position; in raid10_write_request()
1473 raid10_find_phys(conf, r10_bio); in raid10_write_request()
1480 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1484 rdev = dereference_rdev_and_rrdev(&conf->mirrors[d], &rrdev); in raid10_write_request()
1545 GFP_NOIO, &conf->bio_split); in raid10_write_request()
1547 allow_barrier(conf); in raid10_write_request()
1549 wait_barrier(conf, false); in raid10_write_request()
1559 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1570 struct r10conf *conf = mddev->private; in __make_request() local
1573 r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO); in __make_request()
1583 conf->geo.raid_disks); in __make_request()
1593 struct r10conf *conf = r10bio->mddev->private; in raid_end_discard_bio() local
1598 allow_barrier(conf); in raid_end_discard_bio()
1616 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_discard_request() local
1627 dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in raid10_end_discard_request()
1629 rdev = conf->mirrors[dev].replacement; in raid10_end_discard_request()
1637 rdev = conf->mirrors[dev].rdev; in raid10_end_discard_request()
1641 rdev_dec_pending(rdev, conf->mddev); in raid10_end_discard_request()
1652 struct r10conf *conf = mddev->private; in raid10_handle_discard() local
1653 struct geom *geo = &conf->geo; in raid10_handle_discard()
1678 wait_barrier(conf, false); in raid10_handle_discard()
1715 split = bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); in raid10_handle_discard()
1717 allow_barrier(conf); in raid10_handle_discard()
1720 wait_barrier(conf, false); in raid10_handle_discard()
1725 split = bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); in raid10_handle_discard()
1727 allow_barrier(conf); in raid10_handle_discard()
1731 wait_barrier(conf, false); in raid10_handle_discard()
1761 r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO); in raid10_handle_discard()
1792 rdev = dereference_rdev_and_rrdev(&conf->mirrors[disk], &rrdev); in raid10_handle_discard()
1852 struct md_rdev *rdev = conf->mirrors[disk].rdev; in raid10_handle_discard()
1866 struct md_rdev *rrdev = conf->mirrors[disk].replacement; in raid10_handle_discard()
1888 wait_barrier(conf, false); in raid10_handle_discard()
1896 allow_barrier(conf); in raid10_handle_discard()
1902 struct r10conf *conf = mddev->private; in raid10_make_request() local
1903 sector_t chunk_mask = (conf->geo.chunk_mask & conf->prev.chunk_mask); in raid10_make_request()
1924 && (conf->geo.near_copies < conf->geo.raid_disks in raid10_make_request()
1925 || conf->prev.near_copies < in raid10_make_request()
1926 conf->prev.raid_disks))) in raid10_make_request()
1933 wake_up_barrier(conf); in raid10_make_request()
1939 struct r10conf *conf = mddev->private; in raid10_status() local
1942 if (conf->geo.near_copies < conf->geo.raid_disks) in raid10_status()
1944 if (conf->geo.near_copies > 1) in raid10_status()
1945 seq_printf(seq, " %d near-copies", conf->geo.near_copies); in raid10_status()
1946 if (conf->geo.far_copies > 1) { in raid10_status()
1947 if (conf->geo.far_offset) in raid10_status()
1948 seq_printf(seq, " %d offset-copies", conf->geo.far_copies); in raid10_status()
1950 seq_printf(seq, " %d far-copies", conf->geo.far_copies); in raid10_status()
1951 if (conf->geo.far_set_size != conf->geo.raid_disks) in raid10_status()
1952 seq_printf(seq, " %d devices per set", conf->geo.far_set_size); in raid10_status()
1954 seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks, in raid10_status()
1955 conf->geo.raid_disks - mddev->degraded); in raid10_status()
1957 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_status()
1958 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in raid10_status()
1970 static int _enough(struct r10conf *conf, int previous, int ignore) in _enough() argument
1976 disks = conf->prev.raid_disks; in _enough()
1977 ncopies = conf->prev.near_copies; in _enough()
1979 disks = conf->geo.raid_disks; in _enough()
1980 ncopies = conf->geo.near_copies; in _enough()
1985 int n = conf->copies; in _enough()
1991 (rdev = rcu_dereference(conf->mirrors[this].rdev)) && in _enough()
2006 static int enough(struct r10conf *conf, int ignore) in enough() argument
2013 return _enough(conf, 0, ignore) && in enough()
2014 _enough(conf, 1, ignore); in enough()
2034 struct r10conf *conf = mddev->private; in raid10_error() local
2037 spin_lock_irqsave(&conf->device_lock, flags); in raid10_error()
2039 if (test_bit(In_sync, &rdev->flags) && !enough(conf, rdev->raid_disk)) { in raid10_error()
2043 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
2055 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
2059 mdname(mddev), conf->geo.raid_disks - mddev->degraded); in raid10_error()
2062 static void print_conf(struct r10conf *conf) in print_conf() argument
2068 if (!conf) { in print_conf()
2072 pr_debug(" --- wd:%d rd:%d\n", conf->geo.raid_disks - conf->mddev->degraded, in print_conf()
2073 conf->geo.raid_disks); in print_conf()
2077 for (i = 0; i < conf->geo.raid_disks; i++) { in print_conf()
2078 rdev = conf->mirrors[i].rdev; in print_conf()
2087 static void close_sync(struct r10conf *conf) in close_sync() argument
2089 wait_barrier(conf, false); in close_sync()
2090 allow_barrier(conf); in close_sync()
2092 mempool_exit(&conf->r10buf_pool); in close_sync()
2098 struct r10conf *conf = mddev->private; in raid10_spare_active() local
2107 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_spare_active()
2108 tmp = conf->mirrors + i; in raid10_spare_active()
2135 spin_lock_irqsave(&conf->device_lock, flags); in raid10_spare_active()
2137 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_spare_active()
2139 print_conf(conf); in raid10_spare_active()
2145 struct r10conf *conf = mddev->private; in raid10_add_disk() local
2149 int last = conf->geo.raid_disks - 1; in raid10_add_disk()
2157 if (rdev->saved_raid_disk < 0 && !_enough(conf, 1, -1)) in raid10_add_disk()
2167 rdev->saved_raid_disk < conf->geo.raid_disks && in raid10_add_disk()
2168 conf->mirrors[rdev->saved_raid_disk].rdev == NULL) in raid10_add_disk()
2173 p = &conf->mirrors[mirror]; in raid10_add_disk()
2192 conf->fullsync = 1; in raid10_add_disk()
2198 p = &conf->mirrors[repl_slot]; in raid10_add_disk()
2206 conf->fullsync = 1; in raid10_add_disk()
2210 print_conf(conf); in raid10_add_disk()
2216 struct r10conf *conf = mddev->private; in raid10_remove_disk() local
2222 print_conf(conf); in raid10_remove_disk()
2225 p = conf->mirrors + number; in raid10_remove_disk()
2244 number < conf->geo.raid_disks && in raid10_remove_disk()
2245 enough(conf, -1)) { in raid10_remove_disk()
2274 print_conf(conf); in raid10_remove_disk()
2280 struct r10conf *conf = r10_bio->mddev->private; in __end_sync_read() local
2289 &conf->mirrors[d].rdev->corrected_errors); in __end_sync_read()
2294 rdev_dec_pending(conf->mirrors[d].rdev, conf->mddev); in __end_sync_read()
2307 struct r10conf *conf = r10_bio->mddev->private; in end_sync_read() local
2308 int d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); in end_sync_read()
2352 struct r10conf *conf = mddev->private; in end_sync_write() local
2360 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_sync_write()
2362 rdev = conf->mirrors[d].replacement; in end_sync_write()
2364 rdev = conf->mirrors[d].rdev; in end_sync_write()
2405 struct r10conf *conf = mddev->private; in sync_request_write() local
2414 for (i=0; i<conf->copies; i++) in sync_request_write()
2418 if (i == conf->copies) in sync_request_write()
2429 for (i=0 ; i < conf->copies ; i++) { in sync_request_write()
2443 rdev = conf->mirrors[d].rdev; in sync_request_write()
2477 bio_reset(tbio, conf->mirrors[d].rdev->bdev, REQ_OP_WRITE); in sync_request_write()
2488 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in sync_request_write()
2490 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(tbio)); in sync_request_write()
2492 if (test_bit(FailFast, &conf->mirrors[d].rdev->flags)) in sync_request_write()
2494 tbio->bi_iter.bi_sector += conf->mirrors[d].rdev->data_offset; in sync_request_write()
2501 for (i = 0; i < conf->copies; i++) { in sync_request_write()
2512 md_sync_acct(conf->mirrors[d].replacement->bdev, in sync_request_write()
2544 struct r10conf *conf = mddev->private; in fix_recovery_read_error() local
2562 rdev = conf->mirrors[dr].rdev; in fix_recovery_read_error()
2570 rdev = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2592 if (rdev != conf->mirrors[dw].rdev) { in fix_recovery_read_error()
2594 struct md_rdev *rdev2 = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2602 conf->mirrors[dw].recovery_disabled in fix_recovery_read_error()
2619 struct r10conf *conf = mddev->private; in recovery_request_write() local
2646 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in recovery_request_write()
2647 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); in recovery_request_write()
2651 atomic_inc(&conf->mirrors[d].replacement->nr_pending); in recovery_request_write()
2652 md_sync_acct(conf->mirrors[d].replacement->bdev, in recovery_request_write()
2726 static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10bio *r10_bio) in fix_read_error() argument
2737 rdev = conf->mirrors[d].rdev; in fix_read_error()
2772 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2784 conf->tmppage, in fix_read_error()
2792 if (sl == conf->copies) in fix_read_error()
2803 rdev = conf->mirrors[dn].rdev; in fix_read_error()
2822 sl = conf->copies; in fix_read_error()
2825 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2836 s, conf->tmppage, REQ_OP_WRITE) in fix_read_error()
2856 sl = conf->copies; in fix_read_error()
2859 rdev = rcu_dereference(conf->mirrors[d].rdev); in fix_read_error()
2870 s, conf->tmppage, REQ_OP_READ)) { in fix_read_error()
2907 struct r10conf *conf = mddev->private; in narrow_write_error() local
2908 struct md_rdev *rdev = conf->mirrors[r10_bio->devs[i].devnum].rdev; in narrow_write_error()
2968 struct r10conf *conf = mddev->private; in handle_read_error() local
2986 freeze_array(conf, 1); in handle_read_error()
2987 fix_read_error(conf, mddev, r10_bio); in handle_read_error()
2988 unfreeze_array(conf); in handle_read_error()
2999 allow_barrier(conf); in handle_read_error()
3002 static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio) in handle_write_completed() argument
3015 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
3017 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
3031 md_error(conf->mddev, rdev); in handle_write_completed()
3033 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
3048 md_error(conf->mddev, rdev); in handle_write_completed()
3054 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
3057 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
3063 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
3067 md_error(conf->mddev, rdev); in handle_write_completed()
3071 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
3074 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
3080 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
3084 spin_lock_irq(&conf->device_lock); in handle_write_completed()
3085 list_add(&r10_bio->retry_list, &conf->bio_end_io_list); in handle_write_completed()
3086 conf->nr_queued++; in handle_write_completed()
3087 spin_unlock_irq(&conf->device_lock); in handle_write_completed()
3092 wake_up(&conf->wait_barrier); in handle_write_completed()
3093 md_wakeup_thread(conf->mddev->thread); in handle_write_completed()
3108 struct r10conf *conf = mddev->private; in raid10d() local
3109 struct list_head *head = &conf->retry_list; in raid10d()
3114 if (!list_empty_careful(&conf->bio_end_io_list) && in raid10d()
3117 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
3119 while (!list_empty(&conf->bio_end_io_list)) { in raid10d()
3120 list_move(conf->bio_end_io_list.prev, &tmp); in raid10d()
3121 conf->nr_queued--; in raid10d()
3124 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
3142 flush_pending_writes(conf); in raid10d()
3144 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
3146 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
3151 conf->nr_queued--; in raid10d()
3152 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
3155 conf = mddev->private; in raid10d()
3158 handle_write_completed(conf, r10_bio); in raid10d()
3177 static int init_resync(struct r10conf *conf) in init_resync() argument
3182 BUG_ON(mempool_initialized(&conf->r10buf_pool)); in init_resync()
3183 conf->have_replacement = 0; in init_resync()
3184 for (i = 0; i < conf->geo.raid_disks; i++) in init_resync()
3185 if (conf->mirrors[i].replacement) in init_resync()
3186 conf->have_replacement = 1; in init_resync()
3187 ret = mempool_init(&conf->r10buf_pool, buffs, in init_resync()
3188 r10buf_pool_alloc, r10buf_pool_free, conf); in init_resync()
3191 conf->next_resync = 0; in init_resync()
3195 static struct r10bio *raid10_alloc_init_r10buf(struct r10conf *conf) in raid10_alloc_init_r10buf() argument
3197 struct r10bio *r10bio = mempool_alloc(&conf->r10buf_pool, GFP_NOIO); in raid10_alloc_init_r10buf()
3203 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in raid10_alloc_init_r10buf()
3204 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in raid10_alloc_init_r10buf()
3205 nalloc = conf->copies; /* resync */ in raid10_alloc_init_r10buf()
3228 static void raid10_set_cluster_sync_high(struct r10conf *conf) in raid10_set_cluster_sync_high() argument
3245 chunks = conf->geo.raid_disks / conf->geo.near_copies; in raid10_set_cluster_sync_high()
3246 if (conf->geo.raid_disks % conf->geo.near_copies == 0) in raid10_set_cluster_sync_high()
3250 window_size = (chunks + extra_chunk) * conf->mddev->chunk_sectors; in raid10_set_cluster_sync_high()
3258 conf->cluster_sync_high = conf->cluster_sync_low + window_size; in raid10_set_cluster_sync_high()
3296 struct r10conf *conf = mddev->private; in raid10_sync_request() local
3305 sector_t chunk_mask = conf->geo.chunk_mask; in raid10_sync_request()
3319 conf->fullsync == 0) { in raid10_sync_request()
3324 if (!mempool_initialized(&conf->r10buf_pool)) in raid10_sync_request()
3325 if (init_resync(conf)) in raid10_sync_request()
3334 conf->cluster_sync_low = 0; in raid10_sync_request()
3335 conf->cluster_sync_high = 0; in raid10_sync_request()
3347 end_reshape(conf); in raid10_sync_request()
3348 close_sync(conf); in raid10_sync_request()
3356 else for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3358 raid10_find_virt(conf, mddev->curr_resync, i); in raid10_sync_request()
3364 if ((!mddev->bitmap || conf->fullsync) in raid10_sync_request()
3365 && conf->have_replacement in raid10_sync_request()
3371 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3373 rcu_dereference(conf->mirrors[i].replacement); in raid10_sync_request()
3379 conf->fullsync = 0; in raid10_sync_request()
3382 close_sync(conf); in raid10_sync_request()
3390 if (chunks_skipped >= conf->geo.raid_disks) { in raid10_sync_request()
3399 conf->mirrors[error_disk].recovery_disabled = in raid10_sync_request()
3417 if (conf->geo.near_copies < conf->geo.raid_disks && in raid10_sync_request()
3425 if (conf->nr_waiting) in raid10_sync_request()
3449 for (i = 0 ; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3455 struct raid10_info *mirror = &conf->mirrors[i]; in raid10_sync_request()
3476 sect = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3494 !conf->fullsync) { in raid10_sync_request()
3508 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3510 raise_barrier(conf, rb2 != NULL); in raid10_sync_request()
3520 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3526 for (j = 0; j < conf->geo.raid_disks; j++) { in raid10_sync_request()
3528 conf->mirrors[j].rdev); in raid10_sync_request()
3539 for (j=0; j<conf->copies;j++) { in raid10_sync_request()
3544 rcu_dereference(conf->mirrors[d].rdev); in raid10_sync_request()
3580 for (k=0; k<conf->copies; k++) in raid10_sync_request()
3583 BUG_ON(k == conf->copies); in raid10_sync_request()
3624 if (j == conf->copies) { in raid10_sync_request()
3632 for (k = 0; k < conf->copies; k++) in raid10_sync_request()
3679 for (; j < conf->copies; j++) { in raid10_sync_request()
3681 if (conf->mirrors[d].rdev && in raid10_sync_request()
3683 &conf->mirrors[d].rdev->flags)) in raid10_sync_request()
3713 (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); in raid10_sync_request()
3717 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, in raid10_sync_request()
3725 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3730 raise_barrier(conf, 0); in raid10_sync_request()
3731 conf->next_resync = sector_nr; in raid10_sync_request()
3736 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3739 for (i = 0; i < conf->copies; i++) { in raid10_sync_request()
3751 rdev = rcu_dereference(conf->mirrors[d].rdev); in raid10_sync_request()
3781 rdev = rcu_dereference(conf->mirrors[d].replacement); in raid10_sync_request()
3806 for (i=0; i<conf->copies; i++) { in raid10_sync_request()
3809 rdev_dec_pending(conf->mirrors[d].rdev, in raid10_sync_request()
3814 conf->mirrors[d].replacement, in raid10_sync_request()
3850 if (conf->cluster_sync_high < sector_nr + nr_sectors) { in raid10_sync_request()
3851 conf->cluster_sync_low = mddev->curr_resync_completed; in raid10_sync_request()
3852 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3855 conf->cluster_sync_low, in raid10_sync_request()
3856 conf->cluster_sync_high); in raid10_sync_request()
3863 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3869 sect_va1 = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3871 if (conf->cluster_sync_high < sect_va1 + nr_sectors) { in raid10_sync_request()
3877 sect_va2 = raid10_find_virt(conf, in raid10_sync_request()
3880 if (conf->cluster_sync_low == 0 || in raid10_sync_request()
3881 conf->cluster_sync_low > sect_va2) in raid10_sync_request()
3882 conf->cluster_sync_low = sect_va2; in raid10_sync_request()
3886 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3888 conf->cluster_sync_low, in raid10_sync_request()
3889 conf->cluster_sync_high); in raid10_sync_request()
3933 struct r10conf *conf = mddev->private; in raid10_size() local
3936 raid_disks = min(conf->geo.raid_disks, in raid10_size()
3937 conf->prev.raid_disks); in raid10_size()
3939 sectors = conf->dev_sectors; in raid10_size()
3941 size = sectors >> conf->geo.chunk_shift; in raid10_size()
3942 sector_div(size, conf->geo.far_copies); in raid10_size()
3944 sector_div(size, conf->geo.near_copies); in raid10_size()
3946 return size << conf->geo.chunk_shift; in raid10_size()
3949 static void calc_sectors(struct r10conf *conf, sector_t size) in calc_sectors() argument
3956 size = size >> conf->geo.chunk_shift; in calc_sectors()
3957 sector_div(size, conf->geo.far_copies); in calc_sectors()
3958 size = size * conf->geo.raid_disks; in calc_sectors()
3959 sector_div(size, conf->geo.near_copies); in calc_sectors()
3962 size = size * conf->copies; in calc_sectors()
3967 size = DIV_ROUND_UP_SECTOR_T(size, conf->geo.raid_disks); in calc_sectors()
3969 conf->dev_sectors = size << conf->geo.chunk_shift; in calc_sectors()
3971 if (conf->geo.far_offset) in calc_sectors()
3972 conf->geo.stride = 1 << conf->geo.chunk_shift; in calc_sectors()
3974 sector_div(size, conf->geo.far_copies); in calc_sectors()
3975 conf->geo.stride = size << conf->geo.chunk_shift; in calc_sectors()
4036 static void raid10_free_conf(struct r10conf *conf) in raid10_free_conf() argument
4038 if (!conf) in raid10_free_conf()
4041 mempool_exit(&conf->r10bio_pool); in raid10_free_conf()
4042 kfree(conf->mirrors); in raid10_free_conf()
4043 kfree(conf->mirrors_old); in raid10_free_conf()
4044 kfree(conf->mirrors_new); in raid10_free_conf()
4045 safe_put_page(conf->tmppage); in raid10_free_conf()
4046 bioset_exit(&conf->bio_split); in raid10_free_conf()
4047 kfree(conf); in raid10_free_conf()
4052 struct r10conf *conf = NULL; in setup_conf() local
4072 conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL); in setup_conf()
4073 if (!conf) in setup_conf()
4077 conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), in setup_conf()
4080 if (!conf->mirrors) in setup_conf()
4083 conf->tmppage = alloc_page(GFP_KERNEL); in setup_conf()
4084 if (!conf->tmppage) in setup_conf()
4087 conf->geo = geo; in setup_conf()
4088 conf->copies = copies; in setup_conf()
4089 err = mempool_init(&conf->r10bio_pool, NR_RAID_BIOS, r10bio_pool_alloc, in setup_conf()
4090 rbio_pool_free, conf); in setup_conf()
4094 err = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0); in setup_conf()
4098 calc_sectors(conf, mddev->dev_sectors); in setup_conf()
4100 conf->prev = conf->geo; in setup_conf()
4101 conf->reshape_progress = MaxSector; in setup_conf()
4103 if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) { in setup_conf()
4107 conf->reshape_progress = mddev->reshape_position; in setup_conf()
4108 if (conf->prev.far_offset) in setup_conf()
4109 conf->prev.stride = 1 << conf->prev.chunk_shift; in setup_conf()
4112 conf->prev.stride = conf->dev_sectors; in setup_conf()
4114 conf->reshape_safe = conf->reshape_progress; in setup_conf()
4115 spin_lock_init(&conf->device_lock); in setup_conf()
4116 INIT_LIST_HEAD(&conf->retry_list); in setup_conf()
4117 INIT_LIST_HEAD(&conf->bio_end_io_list); in setup_conf()
4119 seqlock_init(&conf->resync_lock); in setup_conf()
4120 init_waitqueue_head(&conf->wait_barrier); in setup_conf()
4121 atomic_set(&conf->nr_pending, 0); in setup_conf()
4124 rcu_assign_pointer(conf->thread, in setup_conf()
4126 if (!conf->thread) in setup_conf()
4129 conf->mddev = mddev; in setup_conf()
4130 return conf; in setup_conf()
4133 raid10_free_conf(conf); in setup_conf()
4137 static void raid10_set_io_opt(struct r10conf *conf) in raid10_set_io_opt() argument
4139 int raid_disks = conf->geo.raid_disks; in raid10_set_io_opt()
4141 if (!(conf->geo.raid_disks % conf->geo.near_copies)) in raid10_set_io_opt()
4142 raid_disks /= conf->geo.near_copies; in raid10_set_io_opt()
4143 blk_queue_io_opt(conf->mddev->queue, (conf->mddev->chunk_sectors << 9) * in raid10_set_io_opt()
4149 struct r10conf *conf; in raid10_run() local
4161 conf = setup_conf(mddev); in raid10_run()
4162 if (IS_ERR(conf)) in raid10_run()
4163 return PTR_ERR(conf); in raid10_run()
4164 mddev->private = conf; in raid10_run()
4166 conf = mddev->private; in raid10_run()
4167 if (!conf) in raid10_run()
4170 rcu_assign_pointer(mddev->thread, conf->thread); in raid10_run()
4171 rcu_assign_pointer(conf->thread, NULL); in raid10_run()
4173 if (mddev_is_clustered(conf->mddev)) { in raid10_run()
4188 raid10_set_io_opt(conf); in raid10_run()
4197 if (disk_idx >= conf->geo.raid_disks && in raid10_run()
4198 disk_idx >= conf->prev.raid_disks) in raid10_run()
4200 disk = conf->mirrors + disk_idx; in raid10_run()
4228 if (!enough(conf, -1)) { in raid10_run()
4234 if (conf->reshape_progress != MaxSector) { in raid10_run()
4236 if (conf->geo.far_copies != 1 && in raid10_run()
4237 conf->geo.far_offset == 0) in raid10_run()
4239 if (conf->prev.far_copies != 1 && in raid10_run()
4240 conf->prev.far_offset == 0) in raid10_run()
4246 i < conf->geo.raid_disks in raid10_run()
4247 || i < conf->prev.raid_disks; in raid10_run()
4250 disk = conf->mirrors + i; in raid10_run()
4265 conf->fullsync = 1; in raid10_run()
4271 conf->fullsync = 1; in raid10_run()
4281 mdname(mddev), conf->geo.raid_disks - mddev->degraded, in raid10_run()
4282 conf->geo.raid_disks); in raid10_run()
4286 mddev->dev_sectors = conf->dev_sectors; in raid10_run()
4295 if (conf->reshape_progress != MaxSector) { in raid10_run()
4298 before_length = ((1 << conf->prev.chunk_shift) * in raid10_run()
4299 conf->prev.far_copies); in raid10_run()
4300 after_length = ((1 << conf->geo.chunk_shift) * in raid10_run()
4301 conf->geo.far_copies); in raid10_run()
4308 conf->offset_diff = min_offset_diff; in raid10_run()
4324 raid10_free_conf(conf); in raid10_run()
4337 struct r10conf *conf = mddev->private; in raid10_quiesce() local
4340 raise_barrier(conf, 0); in raid10_quiesce()
4342 lower_barrier(conf); in raid10_quiesce()
4359 struct r10conf *conf = mddev->private; in raid10_resize() local
4365 if (conf->geo.far_copies > 1 && !conf->geo.far_offset) in raid10_resize()
4384 calc_sectors(conf, sectors); in raid10_resize()
4385 mddev->dev_sectors = conf->dev_sectors; in raid10_resize()
4393 struct r10conf *conf; in raid10_takeover_raid0() local
4413 conf = setup_conf(mddev); in raid10_takeover_raid0()
4414 if (!IS_ERR(conf)) { in raid10_takeover_raid0()
4422 return conf; in raid10_takeover_raid0()
4463 struct r10conf *conf = mddev->private; in raid10_check_reshape() local
4466 if (conf->geo.far_copies != 1 && !conf->geo.far_offset) in raid10_check_reshape()
4469 if (setup_geo(&geo, mddev, geo_start) != conf->copies) in raid10_check_reshape()
4480 if (!enough(conf, -1)) in raid10_check_reshape()
4483 kfree(conf->mirrors_new); in raid10_check_reshape()
4484 conf->mirrors_new = NULL; in raid10_check_reshape()
4487 conf->mirrors_new = in raid10_check_reshape()
4491 if (!conf->mirrors_new) in raid10_check_reshape()
4510 static int calc_degraded(struct r10conf *conf) in calc_degraded() argument
4518 for (i = 0; i < conf->prev.raid_disks; i++) { in calc_degraded()
4519 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in calc_degraded()
4530 if (conf->geo.raid_disks == conf->prev.raid_disks) in calc_degraded()
4534 for (i = 0; i < conf->geo.raid_disks; i++) { in calc_degraded()
4535 struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); in calc_degraded()
4544 if (conf->geo.raid_disks <= conf->prev.raid_disks) in calc_degraded()
4570 struct r10conf *conf = mddev->private; in raid10_start_reshape() local
4578 if (setup_geo(&new, mddev, geo_start) != conf->copies) in raid10_start_reshape()
4581 before_length = ((1 << conf->prev.chunk_shift) * in raid10_start_reshape()
4582 conf->prev.far_copies); in raid10_start_reshape()
4583 after_length = ((1 << conf->geo.chunk_shift) * in raid10_start_reshape()
4584 conf->geo.far_copies); in raid10_start_reshape()
4609 conf->offset_diff = min_offset_diff; in raid10_start_reshape()
4610 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4611 if (conf->mirrors_new) { in raid10_start_reshape()
4612 memcpy(conf->mirrors_new, conf->mirrors, in raid10_start_reshape()
4613 sizeof(struct raid10_info)*conf->prev.raid_disks); in raid10_start_reshape()
4615 kfree(conf->mirrors_old); in raid10_start_reshape()
4616 conf->mirrors_old = conf->mirrors; in raid10_start_reshape()
4617 conf->mirrors = conf->mirrors_new; in raid10_start_reshape()
4618 conf->mirrors_new = NULL; in raid10_start_reshape()
4620 setup_geo(&conf->geo, mddev, geo_start); in raid10_start_reshape()
4625 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4631 conf->reshape_progress = size; in raid10_start_reshape()
4633 conf->reshape_progress = 0; in raid10_start_reshape()
4634 conf->reshape_safe = conf->reshape_progress; in raid10_start_reshape()
4635 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4642 newsize = raid10_size(mddev, 0, conf->geo.raid_disks); in raid10_start_reshape()
4684 conf->prev.raid_disks) in raid10_start_reshape()
4692 } else if (rdev->raid_disk >= conf->prev.raid_disks in raid10_start_reshape()
4702 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4703 mddev->degraded = calc_degraded(conf); in raid10_start_reshape()
4704 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4705 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4706 mddev->reshape_position = conf->reshape_progress; in raid10_start_reshape()
4721 conf->reshape_checkpoint = jiffies; in raid10_start_reshape()
4728 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4729 conf->geo = conf->prev; in raid10_start_reshape()
4730 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4734 conf->reshape_progress = MaxSector; in raid10_start_reshape()
4735 conf->reshape_safe = MaxSector; in raid10_start_reshape()
4737 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4812 struct r10conf *conf = mddev->private; in reshape_request() local
4828 conf->reshape_progress < raid10_size(mddev, 0, 0)) { in reshape_request()
4830 - conf->reshape_progress); in reshape_request()
4832 conf->reshape_progress > 0) in reshape_request()
4833 sector_nr = conf->reshape_progress; in reshape_request()
4850 next = first_dev_address(conf->reshape_progress - 1, in reshape_request()
4851 &conf->geo); in reshape_request()
4856 safe = last_dev_address(conf->reshape_safe - 1, in reshape_request()
4857 &conf->prev); in reshape_request()
4859 if (next + conf->offset_diff < safe) in reshape_request()
4862 last = conf->reshape_progress - 1; in reshape_request()
4863 sector_nr = last & ~(sector_t)(conf->geo.chunk_mask in reshape_request()
4864 & conf->prev.chunk_mask); in reshape_request()
4871 next = last_dev_address(conf->reshape_progress, &conf->geo); in reshape_request()
4876 safe = first_dev_address(conf->reshape_safe, &conf->prev); in reshape_request()
4881 if (next > safe + conf->offset_diff) in reshape_request()
4884 sector_nr = conf->reshape_progress; in reshape_request()
4885 last = sector_nr | (conf->geo.chunk_mask in reshape_request()
4886 & conf->prev.chunk_mask); in reshape_request()
4893 time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) { in reshape_request()
4895 wait_barrier(conf, false); in reshape_request()
4896 mddev->reshape_position = conf->reshape_progress; in reshape_request()
4899 - conf->reshape_progress; in reshape_request()
4901 mddev->curr_resync_completed = conf->reshape_progress; in reshape_request()
4902 conf->reshape_checkpoint = jiffies; in reshape_request()
4908 allow_barrier(conf); in reshape_request()
4911 conf->reshape_safe = mddev->reshape_position; in reshape_request()
4912 allow_barrier(conf); in reshape_request()
4915 raise_barrier(conf, 0); in reshape_request()
4918 r10_bio = raid10_alloc_init_r10buf(conf); in reshape_request()
4920 raise_barrier(conf, 1); in reshape_request()
4926 rdev = read_balance(conf, r10_bio, &max_sectors); in reshape_request()
4934 mempool_free(r10_bio, &conf->r10buf_pool); in reshape_request()
4952 if (mddev_is_clustered(mddev) && conf->cluster_sync_high <= sector_nr) { in reshape_request()
4956 conf->cluster_sync_low = sector_nr; in reshape_request()
4957 conf->cluster_sync_high = sector_nr + CLUSTER_RESYNC_WINDOW_SECTORS; in reshape_request()
4966 if (sb_reshape_pos < conf->cluster_sync_low) in reshape_request()
4967 conf->cluster_sync_low = sb_reshape_pos; in reshape_request()
4970 md_cluster_ops->resync_info_update(mddev, conf->cluster_sync_low, in reshape_request()
4971 conf->cluster_sync_high); in reshape_request()
4975 __raid10_find_phys(&conf->geo, r10_bio); in reshape_request()
4981 for (s = 0; s < conf->copies*2; s++) { in reshape_request()
4986 rdev2 = rcu_dereference(conf->mirrors[d].replacement); in reshape_request()
4989 rdev2 = rcu_dereference(conf->mirrors[d].rdev); in reshape_request()
5035 lower_barrier(conf); in reshape_request()
5041 conf->reshape_progress -= sectors_done; in reshape_request()
5043 conf->reshape_progress += sectors_done; in reshape_request()
5058 struct r10conf *conf = mddev->private; in reshape_request_write() local
5072 for (s = 0; s < conf->copies*2; s++) { in reshape_request_write()
5078 rdev = rcu_dereference(conf->mirrors[d].replacement); in reshape_request_write()
5081 rdev = rcu_dereference(conf->mirrors[d].rdev); in reshape_request_write()
5098 static void end_reshape(struct r10conf *conf) in end_reshape() argument
5100 if (test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) in end_reshape()
5103 spin_lock_irq(&conf->device_lock); in end_reshape()
5104 conf->prev = conf->geo; in end_reshape()
5105 md_finish_reshape(conf->mddev); in end_reshape()
5107 conf->reshape_progress = MaxSector; in end_reshape()
5108 conf->reshape_safe = MaxSector; in end_reshape()
5109 spin_unlock_irq(&conf->device_lock); in end_reshape()
5111 if (conf->mddev->queue) in end_reshape()
5112 raid10_set_io_opt(conf); in end_reshape()
5113 conf->fullsync = 0; in end_reshape()
5118 struct r10conf *conf = mddev->private; in raid10_update_reshape_pos() local
5124 conf->reshape_progress = mddev->reshape_position; in raid10_update_reshape_pos()
5134 struct r10conf *conf = mddev->private; in handle_reshape_read_error() local
5140 r10b = kmalloc(struct_size(r10b, devs, conf->copies), GFP_NOIO); in handle_reshape_read_error()
5150 __raid10_find_phys(&conf->prev, r10b); in handle_reshape_read_error()
5163 struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev); in handle_reshape_read_error()
5184 if (slot >= conf->copies) in handle_reshape_read_error()
5208 struct r10conf *conf = mddev->private; in end_reshape_write() local
5214 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_reshape_write()
5216 rdev = conf->mirrors[d].replacement; in end_reshape_write()
5219 rdev = conf->mirrors[d].rdev; in end_reshape_write()
5242 struct r10conf *conf = mddev->private; in raid10_finish_reshape() local
5256 for (d = conf->geo.raid_disks ; in raid10_finish_reshape()
5257 d < conf->geo.raid_disks - mddev->delta_disks; in raid10_finish_reshape()
5259 struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev); in raid10_finish_reshape()
5262 rdev = rcu_dereference(conf->mirrors[d].replacement); in raid10_finish_reshape()
5269 mddev->chunk_sectors = 1 << conf->geo.chunk_shift; in raid10_finish_reshape()