Lines Matching full:conf
69 static void allow_barrier(struct r10conf *conf);
70 static void lower_barrier(struct r10conf *conf);
71 static int _enough(struct r10conf *conf, int previous, int ignore);
72 static int enough(struct r10conf *conf, int ignore);
77 static void end_reshape(struct r10conf *conf);
82 #define cmd_before(conf, cmd) \ argument
84 write_sequnlock_irq(&(conf)->resync_lock); \
87 #define cmd_after(conf) write_seqlock_irq(&(conf)->resync_lock) argument
89 #define wait_event_barrier_cmd(conf, cond, cmd) \ argument
90 wait_event_cmd((conf)->wait_barrier, cond, cmd_before(conf, cmd), \
91 cmd_after(conf))
93 #define wait_event_barrier(conf, cond) \ argument
94 wait_event_barrier_cmd(conf, cond, NULL_CMD)
107 struct r10conf *conf = data; in r10bio_pool_alloc() local
108 int size = offsetof(struct r10bio, devs[conf->geo.raid_disks]); in r10bio_pool_alloc()
132 struct r10conf *conf = data; in r10buf_pool_alloc() local
139 r10_bio = r10bio_pool_alloc(gfp_flags, conf); in r10buf_pool_alloc()
143 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in r10buf_pool_alloc()
144 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in r10buf_pool_alloc()
145 nalloc = conf->copies; /* resync */ in r10buf_pool_alloc()
150 if (!conf->have_replacement) in r10buf_pool_alloc()
167 if (!conf->have_replacement) in r10buf_pool_alloc()
190 &conf->mddev->recovery)) { in r10buf_pool_alloc()
224 rbio_pool_free(r10_bio, conf); in r10buf_pool_alloc()
230 struct r10conf *conf = data; in r10buf_pool_free() local
235 for (j = conf->copies; j--; ) { in r10buf_pool_free()
255 rbio_pool_free(r10bio, conf); in r10buf_pool_free()
258 static void put_all_bios(struct r10conf *conf, struct r10bio *r10_bio) in put_all_bios() argument
262 for (i = 0; i < conf->geo.raid_disks; i++) { in put_all_bios()
276 struct r10conf *conf = r10_bio->mddev->private; in free_r10bio() local
278 put_all_bios(conf, r10_bio); in free_r10bio()
279 mempool_free(r10_bio, &conf->r10bio_pool); in free_r10bio()
284 struct r10conf *conf = r10_bio->mddev->private; in put_buf() local
286 mempool_free(r10_bio, &conf->r10buf_pool); in put_buf()
288 lower_barrier(conf); in put_buf()
291 static void wake_up_barrier(struct r10conf *conf) in wake_up_barrier() argument
293 if (wq_has_sleeper(&conf->wait_barrier)) in wake_up_barrier()
294 wake_up(&conf->wait_barrier); in wake_up_barrier()
301 struct r10conf *conf = mddev->private; in reschedule_retry() local
303 spin_lock_irqsave(&conf->device_lock, flags); in reschedule_retry()
304 list_add(&r10_bio->retry_list, &conf->retry_list); in reschedule_retry()
305 conf->nr_queued ++; in reschedule_retry()
306 spin_unlock_irqrestore(&conf->device_lock, flags); in reschedule_retry()
309 wake_up(&conf->wait_barrier); in reschedule_retry()
322 struct r10conf *conf = r10_bio->mddev->private; in raid_end_bio_io() local
332 allow_barrier(conf); in raid_end_bio_io()
342 struct r10conf *conf = r10_bio->mddev->private; in update_head_pos() local
344 conf->mirrors[r10_bio->devs[slot].devnum].head_position = in update_head_pos()
351 static int find_bio_disk(struct r10conf *conf, struct r10bio *r10_bio, in find_bio_disk() argument
357 for (slot = 0; slot < conf->geo.raid_disks; slot++) { in find_bio_disk()
381 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_read_request() local
407 if (!_enough(conf, test_bit(R10BIO_Previous, &r10_bio->state), in raid10_end_read_request()
413 rdev_dec_pending(rdev, conf->mddev); in raid10_end_read_request()
419 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()
552 rdev_dec_pending(rdev, conf->mddev); in raid10_end_write_request()
645 static void raid10_find_phys(struct r10conf *conf, struct r10bio *r10bio) in raid10_find_phys() argument
647 struct geom *geo = &conf->geo; in raid10_find_phys()
649 if (conf->reshape_progress != MaxSector && in raid10_find_phys()
650 ((r10bio->sector >= conf->reshape_progress) != in raid10_find_phys()
651 conf->mddev->reshape_backwards)) { in raid10_find_phys()
653 geo = &conf->prev; in raid10_find_phys()
660 static sector_t raid10_find_virt(struct r10conf *conf, sector_t sector, int dev) in raid10_find_virt() argument
663 /* Never use conf->prev as this is only called during resync in raid10_find_virt()
666 struct geom *geo = &conf->geo; in raid10_find_virt()
724 static struct md_rdev *read_balance(struct r10conf *conf, in read_balance() argument
738 struct geom *geo = &conf->geo; in read_balance()
740 raid10_find_phys(conf, r10_bio); in read_balance()
750 if (raid1_should_read_first(conf->mddev, this_sector, sectors)) in read_balance()
753 for (slot = 0; slot < conf->copies ; slot++) { in read_balance()
763 rdev = conf->mirrors[disk].replacement; in read_balance()
767 rdev = conf->mirrors[disk].rdev; in read_balance()
834 conf->mirrors[disk].head_position); in read_balance()
842 if (slot >= conf->copies) { in read_balance()
862 static void flush_pending_writes(struct r10conf *conf) in flush_pending_writes() argument
867 spin_lock_irq(&conf->device_lock); in flush_pending_writes()
869 if (conf->pending_bio_list.head) { in flush_pending_writes()
873 bio = bio_list_get(&conf->pending_bio_list); in flush_pending_writes()
874 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
888 raid1_prepare_flush_writes(conf->mddev); in flush_pending_writes()
889 wake_up(&conf->wait_barrier); in flush_pending_writes()
900 spin_unlock_irq(&conf->device_lock); in flush_pending_writes()
925 static void raise_barrier(struct r10conf *conf, int force) in raise_barrier() argument
927 write_seqlock_irq(&conf->resync_lock); in raise_barrier()
929 if (WARN_ON_ONCE(force && !conf->barrier)) in raise_barrier()
933 wait_event_barrier(conf, force || !conf->nr_waiting); in raise_barrier()
936 WRITE_ONCE(conf->barrier, conf->barrier + 1); in raise_barrier()
939 wait_event_barrier(conf, !atomic_read(&conf->nr_pending) && in raise_barrier()
940 conf->barrier < RESYNC_DEPTH); in raise_barrier()
942 write_sequnlock_irq(&conf->resync_lock); in raise_barrier()
945 static void lower_barrier(struct r10conf *conf) in lower_barrier() argument
949 write_seqlock_irqsave(&conf->resync_lock, flags); in lower_barrier()
950 WRITE_ONCE(conf->barrier, conf->barrier - 1); in lower_barrier()
951 write_sequnlock_irqrestore(&conf->resync_lock, flags); in lower_barrier()
952 wake_up(&conf->wait_barrier); in lower_barrier()
955 static bool stop_waiting_barrier(struct r10conf *conf) in stop_waiting_barrier() argument
961 if (!conf->barrier) in stop_waiting_barrier()
970 if (atomic_read(&conf->nr_pending) && bio_list && in stop_waiting_barrier()
975 thread = rcu_dereference_protected(conf->mddev->thread, true); in stop_waiting_barrier()
982 WARN_ON_ONCE(atomic_read(&conf->nr_pending) == 0); in stop_waiting_barrier()
989 static bool wait_barrier_nolock(struct r10conf *conf) in wait_barrier_nolock() argument
991 unsigned int seq = read_seqbegin(&conf->resync_lock); in wait_barrier_nolock()
993 if (READ_ONCE(conf->barrier)) in wait_barrier_nolock()
996 atomic_inc(&conf->nr_pending); in wait_barrier_nolock()
997 if (!read_seqretry(&conf->resync_lock, seq)) in wait_barrier_nolock()
1000 if (atomic_dec_and_test(&conf->nr_pending)) in wait_barrier_nolock()
1001 wake_up_barrier(conf); in wait_barrier_nolock()
1006 static bool wait_barrier(struct r10conf *conf, bool nowait) in wait_barrier() argument
1010 if (wait_barrier_nolock(conf)) in wait_barrier()
1013 write_seqlock_irq(&conf->resync_lock); in wait_barrier()
1014 if (conf->barrier) { in wait_barrier()
1019 conf->nr_waiting++; in wait_barrier()
1020 mddev_add_trace_msg(conf->mddev, "raid10 wait barrier"); in wait_barrier()
1021 wait_event_barrier(conf, stop_waiting_barrier(conf)); in wait_barrier()
1022 conf->nr_waiting--; in wait_barrier()
1024 if (!conf->nr_waiting) in wait_barrier()
1025 wake_up(&conf->wait_barrier); in wait_barrier()
1029 atomic_inc(&conf->nr_pending); in wait_barrier()
1030 write_sequnlock_irq(&conf->resync_lock); in wait_barrier()
1034 static void allow_barrier(struct r10conf *conf) in allow_barrier() argument
1036 if ((atomic_dec_and_test(&conf->nr_pending)) || in allow_barrier()
1037 (conf->array_freeze_pending)) in allow_barrier()
1038 wake_up_barrier(conf); in allow_barrier()
1041 static void freeze_array(struct r10conf *conf, int extra) in freeze_array() argument
1055 write_seqlock_irq(&conf->resync_lock); in freeze_array()
1056 conf->array_freeze_pending++; in freeze_array()
1057 WRITE_ONCE(conf->barrier, conf->barrier + 1); in freeze_array()
1058 conf->nr_waiting++; in freeze_array()
1059 wait_event_barrier_cmd(conf, atomic_read(&conf->nr_pending) == in freeze_array()
1060 conf->nr_queued + extra, flush_pending_writes(conf)); in freeze_array()
1061 conf->array_freeze_pending--; in freeze_array()
1062 write_sequnlock_irq(&conf->resync_lock); in freeze_array()
1065 static void unfreeze_array(struct r10conf *conf) in unfreeze_array() argument
1068 write_seqlock_irq(&conf->resync_lock); in unfreeze_array()
1069 WRITE_ONCE(conf->barrier, conf->barrier - 1); in unfreeze_array()
1070 conf->nr_waiting--; in unfreeze_array()
1071 wake_up(&conf->wait_barrier); in unfreeze_array()
1072 write_sequnlock_irq(&conf->resync_lock); in unfreeze_array()
1089 struct r10conf *conf = mddev->private; in raid10_unplug() local
1093 spin_lock_irq(&conf->device_lock); in raid10_unplug()
1094 bio_list_merge(&conf->pending_bio_list, &plug->pending); in raid10_unplug()
1095 spin_unlock_irq(&conf->device_lock); in raid10_unplug()
1096 wake_up_barrier(conf); in raid10_unplug()
1105 wake_up_barrier(conf); in raid10_unplug()
1123 static bool regular_request_wait(struct mddev *mddev, struct r10conf *conf, in regular_request_wait() argument
1127 if (!wait_barrier(conf, bio->bi_opf & REQ_NOWAIT)) { in regular_request_wait()
1132 bio->bi_iter.bi_sector < conf->reshape_progress && in regular_request_wait()
1133 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { in regular_request_wait()
1134 allow_barrier(conf); in regular_request_wait()
1139 mddev_add_trace_msg(conf->mddev, "raid10 wait reshape"); in regular_request_wait()
1140 wait_event(conf->wait_barrier, in regular_request_wait()
1141 conf->reshape_progress <= bio->bi_iter.bi_sector || in regular_request_wait()
1142 conf->reshape_progress >= bio->bi_iter.bi_sector + in regular_request_wait()
1144 wait_barrier(conf, false); in regular_request_wait()
1152 struct r10conf *conf = mddev->private; in raid10_read_request() local
1167 * we must use the one in conf. in raid10_read_request()
1179 err_rdev = conf->mirrors[disk].rdev; in raid10_read_request()
1189 if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors)) in raid10_read_request()
1191 rdev = read_balance(conf, r10_bio, &max_sectors); in raid10_read_request()
1208 gfp, &conf->bio_split); in raid10_read_request()
1210 allow_barrier(conf); in raid10_read_request()
1212 wait_barrier(conf, false); in raid10_read_request()
1249 struct r10conf *conf = mddev->private; in raid10_write_one_disk() local
1254 rdev = replacement ? conf->mirrors[devnum].replacement : in raid10_write_one_disk()
1255 conf->mirrors[devnum].rdev; in raid10_write_one_disk()
1268 &conf->mirrors[devnum].rdev->flags) in raid10_write_one_disk()
1269 && enough(conf, devnum)) in raid10_write_one_disk()
1278 if (!raid1_add_bio_to_plug(mddev, mbio, raid10_unplug, conf->copies)) { in raid10_write_one_disk()
1279 spin_lock_irqsave(&conf->device_lock, flags); in raid10_write_one_disk()
1280 bio_list_add(&conf->pending_bio_list, mbio); in raid10_write_one_disk()
1281 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_write_one_disk()
1289 struct r10conf *conf = mddev->private; in wait_blocked_dev() local
1294 for (i = 0; i < conf->copies; i++) { in wait_blocked_dev()
1297 rdev = conf->mirrors[i].rdev; in wait_blocked_dev()
1298 rrdev = conf->mirrors[i].replacement; in wait_blocked_dev()
1336 allow_barrier(conf); in wait_blocked_dev()
1337 mddev_add_trace_msg(conf->mddev, in wait_blocked_dev()
1341 wait_barrier(conf, false); in wait_blocked_dev()
1349 struct r10conf *conf = mddev->private; in raid10_write_request() local
1365 prepare_to_wait(&conf->wait_barrier, in raid10_write_request()
1372 finish_wait(&conf->wait_barrier, &w); in raid10_write_request()
1376 if (!regular_request_wait(mddev, conf, bio, sectors)) in raid10_write_request()
1380 ? (bio->bi_iter.bi_sector < conf->reshape_safe && in raid10_write_request()
1381 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) in raid10_write_request()
1382 : (bio->bi_iter.bi_sector + sectors > conf->reshape_safe && in raid10_write_request()
1383 bio->bi_iter.bi_sector < conf->reshape_progress))) { in raid10_write_request()
1385 mddev->reshape_position = conf->reshape_progress; in raid10_write_request()
1390 allow_barrier(conf); in raid10_write_request()
1394 mddev_add_trace_msg(conf->mddev, in raid10_write_request()
1399 conf->reshape_safe = mddev->reshape_position; in raid10_write_request()
1413 raid10_find_phys(conf, r10_bio); in raid10_write_request()
1419 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1423 rdev = conf->mirrors[d].rdev; in raid10_write_request()
1424 rrdev = conf->mirrors[d].replacement; in raid10_write_request()
1484 GFP_NOIO, &conf->bio_split); in raid10_write_request()
1486 allow_barrier(conf); in raid10_write_request()
1488 wait_barrier(conf, false); in raid10_write_request()
1499 for (i = 0; i < conf->copies; i++) { in raid10_write_request()
1510 struct r10conf *conf = mddev->private; in __make_request() local
1513 r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO); in __make_request()
1523 conf->geo.raid_disks); in __make_request()
1533 struct r10conf *conf = r10bio->mddev->private; in raid_end_discard_bio() local
1538 allow_barrier(conf); in raid_end_discard_bio()
1556 struct r10conf *conf = r10_bio->mddev->private; in raid10_end_discard_request() local
1567 dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in raid10_end_discard_request()
1568 rdev = repl ? conf->mirrors[dev].replacement : in raid10_end_discard_request()
1569 conf->mirrors[dev].rdev; in raid10_end_discard_request()
1572 rdev_dec_pending(rdev, conf->mddev); in raid10_end_discard_request()
1583 struct r10conf *conf = mddev->private; in raid10_handle_discard() local
1584 struct geom *geo = &conf->geo; in raid10_handle_discard()
1609 wait_barrier(conf, false); in raid10_handle_discard()
1646 split = bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); in raid10_handle_discard()
1648 allow_barrier(conf); in raid10_handle_discard()
1651 wait_barrier(conf, false); in raid10_handle_discard()
1656 split = bio_split(bio, split_size, GFP_NOIO, &conf->bio_split); in raid10_handle_discard()
1658 allow_barrier(conf); in raid10_handle_discard()
1662 wait_barrier(conf, false); in raid10_handle_discard()
1692 r10_bio = mempool_alloc(&conf->r10bio_pool, GFP_NOIO); in raid10_handle_discard()
1722 rdev = conf->mirrors[disk].rdev; in raid10_handle_discard()
1723 rrdev = conf->mirrors[disk].replacement; in raid10_handle_discard()
1782 struct md_rdev *rdev = conf->mirrors[disk].rdev; in raid10_handle_discard()
1796 struct md_rdev *rrdev = conf->mirrors[disk].replacement; in raid10_handle_discard()
1818 wait_barrier(conf, false); in raid10_handle_discard()
1826 allow_barrier(conf); in raid10_handle_discard()
1832 struct r10conf *conf = mddev->private; in raid10_make_request() local
1833 sector_t chunk_mask = (conf->geo.chunk_mask & conf->prev.chunk_mask); in raid10_make_request()
1853 && (conf->geo.near_copies < conf->geo.raid_disks in raid10_make_request()
1854 || conf->prev.near_copies < in raid10_make_request()
1855 conf->prev.raid_disks))) in raid10_make_request()
1862 wake_up_barrier(conf); in raid10_make_request()
1868 struct r10conf *conf = mddev->private; in raid10_status() local
1873 if (conf->geo.near_copies < conf->geo.raid_disks) in raid10_status()
1875 if (conf->geo.near_copies > 1) in raid10_status()
1876 seq_printf(seq, " %d near-copies", conf->geo.near_copies); in raid10_status()
1877 if (conf->geo.far_copies > 1) { in raid10_status()
1878 if (conf->geo.far_offset) in raid10_status()
1879 seq_printf(seq, " %d offset-copies", conf->geo.far_copies); in raid10_status()
1881 seq_printf(seq, " %d far-copies", conf->geo.far_copies); in raid10_status()
1882 if (conf->geo.far_set_size != conf->geo.raid_disks) in raid10_status()
1883 seq_printf(seq, " %d devices per set", conf->geo.far_set_size); in raid10_status()
1885 seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks, in raid10_status()
1886 conf->geo.raid_disks - mddev->degraded); in raid10_status()
1887 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_status()
1888 struct md_rdev *rdev = READ_ONCE(conf->mirrors[i].rdev); in raid10_status()
1900 static int _enough(struct r10conf *conf, int previous, int ignore) in _enough() argument
1906 disks = conf->prev.raid_disks; in _enough()
1907 ncopies = conf->prev.near_copies; in _enough()
1909 disks = conf->geo.raid_disks; in _enough()
1910 ncopies = conf->geo.near_copies; in _enough()
1914 int n = conf->copies; in _enough()
1920 (rdev = conf->mirrors[this].rdev) && in _enough()
1934 static int enough(struct r10conf *conf, int ignore) in enough() argument
1941 return _enough(conf, 0, ignore) && in enough()
1942 _enough(conf, 1, ignore); in enough()
1962 struct r10conf *conf = mddev->private; in raid10_error() local
1965 spin_lock_irqsave(&conf->device_lock, flags); in raid10_error()
1967 if (test_bit(In_sync, &rdev->flags) && !enough(conf, rdev->raid_disk)) { in raid10_error()
1971 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
1983 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_error()
1987 mdname(mddev), conf->geo.raid_disks - mddev->degraded); in raid10_error()
1990 static void print_conf(struct r10conf *conf) in print_conf() argument
1995 pr_debug("RAID10 conf printout:\n"); in print_conf()
1996 if (!conf) { in print_conf()
1997 pr_debug("(!conf)\n"); in print_conf()
2000 pr_debug(" --- wd:%d rd:%d\n", conf->geo.raid_disks - conf->mddev->degraded, in print_conf()
2001 conf->geo.raid_disks); in print_conf()
2003 lockdep_assert_held(&conf->mddev->reconfig_mutex); in print_conf()
2004 for (i = 0; i < conf->geo.raid_disks; i++) { in print_conf()
2005 rdev = conf->mirrors[i].rdev; in print_conf()
2014 static void close_sync(struct r10conf *conf) in close_sync() argument
2016 wait_barrier(conf, false); in close_sync()
2017 allow_barrier(conf); in close_sync()
2019 mempool_exit(&conf->r10buf_pool); in close_sync()
2025 struct r10conf *conf = mddev->private; in raid10_spare_active() local
2034 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_spare_active()
2035 tmp = conf->mirrors + i; in raid10_spare_active()
2062 spin_lock_irqsave(&conf->device_lock, flags); in raid10_spare_active()
2064 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10_spare_active()
2066 print_conf(conf); in raid10_spare_active()
2072 struct r10conf *conf = mddev->private; in raid10_add_disk() local
2076 int last = conf->geo.raid_disks - 1; in raid10_add_disk()
2084 if (rdev->saved_raid_disk < 0 && !_enough(conf, 1, -1)) in raid10_add_disk()
2091 rdev->saved_raid_disk < conf->geo.raid_disks && in raid10_add_disk()
2092 conf->mirrors[rdev->saved_raid_disk].rdev == NULL) in raid10_add_disk()
2097 p = &conf->mirrors[mirror]; in raid10_add_disk()
2115 conf->fullsync = 1; in raid10_add_disk()
2121 p = &conf->mirrors[repl_slot]; in raid10_add_disk()
2128 conf->fullsync = 1; in raid10_add_disk()
2132 print_conf(conf); in raid10_add_disk()
2138 struct r10conf *conf = mddev->private; in raid10_remove_disk() local
2144 print_conf(conf); in raid10_remove_disk()
2147 p = conf->mirrors + number; in raid10_remove_disk()
2166 number < conf->geo.raid_disks && in raid10_remove_disk()
2167 enough(conf, -1)) { in raid10_remove_disk()
2184 print_conf(conf); in raid10_remove_disk()
2190 struct r10conf *conf = r10_bio->mddev->private; in __end_sync_read() local
2199 &conf->mirrors[d].rdev->corrected_errors); in __end_sync_read()
2204 rdev_dec_pending(conf->mirrors[d].rdev, conf->mddev); in __end_sync_read()
2217 struct r10conf *conf = r10_bio->mddev->private; in end_sync_read() local
2218 int d = find_bio_disk(conf, r10_bio, bio, NULL, NULL); in end_sync_read()
2262 struct r10conf *conf = mddev->private; in end_sync_write() local
2268 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_sync_write()
2270 rdev = conf->mirrors[d].replacement; in end_sync_write()
2272 rdev = conf->mirrors[d].rdev; in end_sync_write()
2312 struct r10conf *conf = mddev->private; in sync_request_write() local
2321 for (i=0; i<conf->copies; i++) in sync_request_write()
2325 if (i == conf->copies) in sync_request_write()
2336 for (i=0 ; i < conf->copies ; i++) { in sync_request_write()
2350 rdev = conf->mirrors[d].rdev; in sync_request_write()
2384 bio_reset(tbio, conf->mirrors[d].rdev->bdev, REQ_OP_WRITE); in sync_request_write()
2395 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in sync_request_write()
2397 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(tbio)); in sync_request_write()
2399 if (test_bit(FailFast, &conf->mirrors[d].rdev->flags)) in sync_request_write()
2401 tbio->bi_iter.bi_sector += conf->mirrors[d].rdev->data_offset; in sync_request_write()
2408 for (i = 0; i < conf->copies; i++) { in sync_request_write()
2419 md_sync_acct(conf->mirrors[d].replacement->bdev, in sync_request_write()
2451 struct r10conf *conf = mddev->private; in fix_recovery_read_error() local
2469 rdev = conf->mirrors[dr].rdev; in fix_recovery_read_error()
2477 rdev = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2499 if (rdev != conf->mirrors[dw].rdev) { in fix_recovery_read_error()
2501 struct md_rdev *rdev2 = conf->mirrors[dw].rdev; in fix_recovery_read_error()
2509 conf->mirrors[dw].recovery_disabled in fix_recovery_read_error()
2526 struct r10conf *conf = mddev->private; in recovery_request_write() local
2553 atomic_inc(&conf->mirrors[d].rdev->nr_pending); in recovery_request_write()
2554 md_sync_acct(conf->mirrors[d].rdev->bdev, bio_sectors(wbio)); in recovery_request_write()
2558 atomic_inc(&conf->mirrors[d].replacement->nr_pending); in recovery_request_write()
2559 md_sync_acct(conf->mirrors[d].replacement->bdev, in recovery_request_write()
2594 static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10bio *r10_bio) in fix_read_error() argument
2604 rdev = conf->mirrors[d].rdev; in fix_read_error()
2627 rdev = conf->mirrors[d].rdev; in fix_read_error()
2639 conf->tmppage, in fix_read_error()
2646 if (sl == conf->copies) in fix_read_error()
2656 rdev = conf->mirrors[dn].rdev; in fix_read_error()
2674 sl = conf->copies; in fix_read_error()
2677 rdev = conf->mirrors[d].rdev; in fix_read_error()
2687 s, conf->tmppage, REQ_OP_WRITE) in fix_read_error()
2706 sl = conf->copies; in fix_read_error()
2709 rdev = conf->mirrors[d].rdev; in fix_read_error()
2719 s, conf->tmppage, REQ_OP_READ)) { in fix_read_error()
2754 struct r10conf *conf = mddev->private; in narrow_write_error() local
2755 struct md_rdev *rdev = conf->mirrors[r10_bio->devs[i].devnum].rdev; in narrow_write_error()
2815 struct r10conf *conf = mddev->private; in handle_read_error() local
2833 freeze_array(conf, 1); in handle_read_error()
2834 fix_read_error(conf, mddev, r10_bio); in handle_read_error()
2835 unfreeze_array(conf); in handle_read_error()
2846 allow_barrier(conf); in handle_read_error()
2849 static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio) in handle_write_completed() argument
2862 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
2864 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
2878 md_error(conf->mddev, rdev); in handle_write_completed()
2880 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
2895 md_error(conf->mddev, rdev); in handle_write_completed()
2901 for (m = 0; m < conf->copies; m++) { in handle_write_completed()
2904 rdev = conf->mirrors[dev].rdev; in handle_write_completed()
2910 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2914 md_error(conf->mddev, rdev); in handle_write_completed()
2918 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2921 rdev = conf->mirrors[dev].replacement; in handle_write_completed()
2927 rdev_dec_pending(rdev, conf->mddev); in handle_write_completed()
2931 spin_lock_irq(&conf->device_lock); in handle_write_completed()
2932 list_add(&r10_bio->retry_list, &conf->bio_end_io_list); in handle_write_completed()
2933 conf->nr_queued++; in handle_write_completed()
2934 spin_unlock_irq(&conf->device_lock); in handle_write_completed()
2939 wake_up(&conf->wait_barrier); in handle_write_completed()
2940 md_wakeup_thread(conf->mddev->thread); in handle_write_completed()
2955 struct r10conf *conf = mddev->private; in raid10d() local
2956 struct list_head *head = &conf->retry_list; in raid10d()
2961 if (!list_empty_careful(&conf->bio_end_io_list) && in raid10d()
2964 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
2966 while (!list_empty(&conf->bio_end_io_list)) { in raid10d()
2967 list_move(conf->bio_end_io_list.prev, &tmp); in raid10d()
2968 conf->nr_queued--; in raid10d()
2971 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
2989 flush_pending_writes(conf); in raid10d()
2991 spin_lock_irqsave(&conf->device_lock, flags); in raid10d()
2993 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
2998 conf->nr_queued--; in raid10d()
2999 spin_unlock_irqrestore(&conf->device_lock, flags); in raid10d()
3002 conf = mddev->private; in raid10d()
3005 handle_write_completed(conf, r10_bio); in raid10d()
3024 static int init_resync(struct r10conf *conf) in init_resync() argument
3029 BUG_ON(mempool_initialized(&conf->r10buf_pool)); in init_resync()
3030 conf->have_replacement = 0; in init_resync()
3031 for (i = 0; i < conf->geo.raid_disks; i++) in init_resync()
3032 if (conf->mirrors[i].replacement) in init_resync()
3033 conf->have_replacement = 1; in init_resync()
3034 ret = mempool_init(&conf->r10buf_pool, buffs, in init_resync()
3035 r10buf_pool_alloc, r10buf_pool_free, conf); in init_resync()
3038 conf->next_resync = 0; in init_resync()
3042 static struct r10bio *raid10_alloc_init_r10buf(struct r10conf *conf) in raid10_alloc_init_r10buf() argument
3044 struct r10bio *r10bio = mempool_alloc(&conf->r10buf_pool, GFP_NOIO); in raid10_alloc_init_r10buf()
3050 if (test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery) || in raid10_alloc_init_r10buf()
3051 test_bit(MD_RECOVERY_RESHAPE, &conf->mddev->recovery)) in raid10_alloc_init_r10buf()
3052 nalloc = conf->copies; /* resync */ in raid10_alloc_init_r10buf()
3075 static void raid10_set_cluster_sync_high(struct r10conf *conf) in raid10_set_cluster_sync_high() argument
3092 chunks = conf->geo.raid_disks / conf->geo.near_copies; in raid10_set_cluster_sync_high()
3093 if (conf->geo.raid_disks % conf->geo.near_copies == 0) in raid10_set_cluster_sync_high()
3097 window_size = (chunks + extra_chunk) * conf->mddev->chunk_sectors; in raid10_set_cluster_sync_high()
3105 conf->cluster_sync_high = conf->cluster_sync_low + window_size; in raid10_set_cluster_sync_high()
3143 struct r10conf *conf = mddev->private; in raid10_sync_request() local
3152 sector_t chunk_mask = conf->geo.chunk_mask; in raid10_sync_request()
3166 conf->fullsync == 0) { in raid10_sync_request()
3171 if (!mempool_initialized(&conf->r10buf_pool)) in raid10_sync_request()
3172 if (init_resync(conf)) in raid10_sync_request()
3177 conf->cluster_sync_low = 0; in raid10_sync_request()
3178 conf->cluster_sync_high = 0; in raid10_sync_request()
3190 end_reshape(conf); in raid10_sync_request()
3191 close_sync(conf); in raid10_sync_request()
3200 else for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3202 raid10_find_virt(conf, mddev->curr_resync, i); in raid10_sync_request()
3209 if ((!mddev->bitmap || conf->fullsync) in raid10_sync_request()
3210 && conf->have_replacement in raid10_sync_request()
3215 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3217 conf->mirrors[i].replacement; in raid10_sync_request()
3223 conf->fullsync = 0; in raid10_sync_request()
3226 close_sync(conf); in raid10_sync_request()
3234 if (chunks_skipped >= conf->geo.raid_disks) { in raid10_sync_request()
3243 conf->mirrors[error_disk].recovery_disabled = in raid10_sync_request()
3261 if (conf->geo.near_copies < conf->geo.raid_disks && in raid10_sync_request()
3269 if (conf->nr_waiting) in raid10_sync_request()
3293 for (i = 0 ; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3299 struct raid10_info *mirror = &conf->mirrors[i]; in raid10_sync_request()
3317 sect = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3334 !conf->fullsync) { in raid10_sync_request()
3346 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3348 raise_barrier(conf, rb2 != NULL); in raid10_sync_request()
3358 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3363 for (j = 0; j < conf->geo.raid_disks; j++) { in raid10_sync_request()
3364 struct md_rdev *rdev = conf->mirrors[j].rdev; in raid10_sync_request()
3376 for (j=0; j<conf->copies;j++) { in raid10_sync_request()
3380 struct md_rdev *rdev = conf->mirrors[d].rdev; in raid10_sync_request()
3416 for (k=0; k<conf->copies; k++) in raid10_sync_request()
3419 BUG_ON(k == conf->copies); in raid10_sync_request()
3459 if (j == conf->copies) { in raid10_sync_request()
3467 for (k = 0; k < conf->copies; k++) in raid10_sync_request()
3514 for (; j < conf->copies; j++) { in raid10_sync_request()
3516 if (conf->mirrors[d].rdev && in raid10_sync_request()
3518 &conf->mirrors[d].rdev->flags)) in raid10_sync_request()
3548 (sector_nr + 2 * RESYNC_SECTORS > conf->cluster_sync_high)); in raid10_sync_request()
3553 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, in raid10_sync_request()
3561 r10_bio = raid10_alloc_init_r10buf(conf); in raid10_sync_request()
3566 raise_barrier(conf, 0); in raid10_sync_request()
3567 conf->next_resync = sector_nr; in raid10_sync_request()
3572 raid10_find_phys(conf, r10_bio); in raid10_sync_request()
3575 for (i = 0; i < conf->copies; i++) { in raid10_sync_request()
3586 rdev = conf->mirrors[d].rdev; in raid10_sync_request()
3614 rdev = conf->mirrors[d].replacement; in raid10_sync_request()
3637 for (i=0; i<conf->copies; i++) { in raid10_sync_request()
3640 rdev_dec_pending(conf->mirrors[d].rdev, in raid10_sync_request()
3645 conf->mirrors[d].replacement, in raid10_sync_request()
3681 if (conf->cluster_sync_high < sector_nr + nr_sectors) { in raid10_sync_request()
3682 conf->cluster_sync_low = mddev->curr_resync_completed; in raid10_sync_request()
3683 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3686 conf->cluster_sync_low, in raid10_sync_request()
3687 conf->cluster_sync_high); in raid10_sync_request()
3694 for (i = 0; i < conf->geo.raid_disks; i++) { in raid10_sync_request()
3700 sect_va1 = raid10_find_virt(conf, sector_nr, i); in raid10_sync_request()
3702 if (conf->cluster_sync_high < sect_va1 + nr_sectors) { in raid10_sync_request()
3708 sect_va2 = raid10_find_virt(conf, in raid10_sync_request()
3711 if (conf->cluster_sync_low == 0 || in raid10_sync_request()
3712 conf->cluster_sync_low > sect_va2) in raid10_sync_request()
3713 conf->cluster_sync_low = sect_va2; in raid10_sync_request()
3717 raid10_set_cluster_sync_high(conf); in raid10_sync_request()
3719 conf->cluster_sync_low, in raid10_sync_request()
3720 conf->cluster_sync_high); in raid10_sync_request()
3764 struct r10conf *conf = mddev->private; in raid10_size() local
3767 raid_disks = min(conf->geo.raid_disks, in raid10_size()
3768 conf->prev.raid_disks); in raid10_size()
3770 sectors = conf->dev_sectors; in raid10_size()
3772 size = sectors >> conf->geo.chunk_shift; in raid10_size()
3773 sector_div(size, conf->geo.far_copies); in raid10_size()
3775 sector_div(size, conf->geo.near_copies); in raid10_size()
3777 return size << conf->geo.chunk_shift; in raid10_size()
3780 static void calc_sectors(struct r10conf *conf, sector_t size) in calc_sectors() argument
3783 * actually be used, and set conf->dev_sectors and in calc_sectors()
3784 * conf->stride in calc_sectors()
3787 size = size >> conf->geo.chunk_shift; in calc_sectors()
3788 sector_div(size, conf->geo.far_copies); in calc_sectors()
3789 size = size * conf->geo.raid_disks; in calc_sectors()
3790 sector_div(size, conf->geo.near_copies); in calc_sectors()
3793 size = size * conf->copies; in calc_sectors()
3798 size = DIV_ROUND_UP_SECTOR_T(size, conf->geo.raid_disks); in calc_sectors()
3800 conf->dev_sectors = size << conf->geo.chunk_shift; in calc_sectors()
3802 if (conf->geo.far_offset) in calc_sectors()
3803 conf->geo.stride = 1 << conf->geo.chunk_shift; in calc_sectors()
3805 sector_div(size, conf->geo.far_copies); in calc_sectors()
3806 conf->geo.stride = size << conf->geo.chunk_shift; in calc_sectors()
3867 static void raid10_free_conf(struct r10conf *conf) in raid10_free_conf() argument
3869 if (!conf) in raid10_free_conf()
3872 mempool_exit(&conf->r10bio_pool); in raid10_free_conf()
3873 kfree(conf->mirrors); in raid10_free_conf()
3874 kfree(conf->mirrors_old); in raid10_free_conf()
3875 kfree(conf->mirrors_new); in raid10_free_conf()
3876 safe_put_page(conf->tmppage); in raid10_free_conf()
3877 bioset_exit(&conf->bio_split); in raid10_free_conf()
3878 kfree(conf); in raid10_free_conf()
3883 struct r10conf *conf = NULL; in setup_conf() local
3903 conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL); in setup_conf()
3904 if (!conf) in setup_conf()
3908 conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), in setup_conf()
3911 if (!conf->mirrors) in setup_conf()
3914 conf->tmppage = alloc_page(GFP_KERNEL); in setup_conf()
3915 if (!conf->tmppage) in setup_conf()
3918 conf->geo = geo; in setup_conf()
3919 conf->copies = copies; in setup_conf()
3920 err = mempool_init(&conf->r10bio_pool, NR_RAID_BIOS, r10bio_pool_alloc, in setup_conf()
3921 rbio_pool_free, conf); in setup_conf()
3925 err = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0); in setup_conf()
3929 calc_sectors(conf, mddev->dev_sectors); in setup_conf()
3931 conf->prev = conf->geo; in setup_conf()
3932 conf->reshape_progress = MaxSector; in setup_conf()
3934 if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) { in setup_conf()
3938 conf->reshape_progress = mddev->reshape_position; in setup_conf()
3939 if (conf->prev.far_offset) in setup_conf()
3940 conf->prev.stride = 1 << conf->prev.chunk_shift; in setup_conf()
3943 conf->prev.stride = conf->dev_sectors; in setup_conf()
3945 conf->reshape_safe = conf->reshape_progress; in setup_conf()
3946 spin_lock_init(&conf->device_lock); in setup_conf()
3947 INIT_LIST_HEAD(&conf->retry_list); in setup_conf()
3948 INIT_LIST_HEAD(&conf->bio_end_io_list); in setup_conf()
3950 seqlock_init(&conf->resync_lock); in setup_conf()
3951 init_waitqueue_head(&conf->wait_barrier); in setup_conf()
3952 atomic_set(&conf->nr_pending, 0); in setup_conf()
3955 rcu_assign_pointer(conf->thread, in setup_conf()
3957 if (!conf->thread) in setup_conf()
3960 conf->mddev = mddev; in setup_conf()
3961 return conf; in setup_conf()
3964 raid10_free_conf(conf); in setup_conf()
3968 static unsigned int raid10_nr_stripes(struct r10conf *conf) in raid10_nr_stripes() argument
3970 unsigned int raid_disks = conf->geo.raid_disks; in raid10_nr_stripes()
3972 if (conf->geo.raid_disks % conf->geo.near_copies) in raid10_nr_stripes()
3974 return raid_disks / conf->geo.near_copies; in raid10_nr_stripes()
3979 struct r10conf *conf = mddev->private; in raid10_set_queue_limits() local
3986 lim.io_opt = lim.io_min * raid10_nr_stripes(conf); in raid10_set_queue_limits()
3997 struct r10conf *conf; in raid10_run() local
4007 conf = setup_conf(mddev); in raid10_run()
4008 if (IS_ERR(conf)) in raid10_run()
4009 return PTR_ERR(conf); in raid10_run()
4010 mddev->private = conf; in raid10_run()
4012 conf = mddev->private; in raid10_run()
4013 if (!conf) in raid10_run()
4016 rcu_assign_pointer(mddev->thread, conf->thread); in raid10_run()
4017 rcu_assign_pointer(conf->thread, NULL); in raid10_run()
4019 if (mddev_is_clustered(conf->mddev)) { in raid10_run()
4037 if (disk_idx >= conf->geo.raid_disks && in raid10_run()
4038 disk_idx >= conf->prev.raid_disks) in raid10_run()
4040 disk = conf->mirrors + disk_idx; in raid10_run()
4063 if (!mddev_is_dm(conf->mddev)) { in raid10_run()
4073 if (!enough(conf, -1)) { in raid10_run()
4079 if (conf->reshape_progress != MaxSector) { in raid10_run()
4081 if (conf->geo.far_copies != 1 && in raid10_run()
4082 conf->geo.far_offset == 0) in raid10_run()
4084 if (conf->prev.far_copies != 1 && in raid10_run()
4085 conf->prev.far_offset == 0) in raid10_run()
4091 i < conf->geo.raid_disks in raid10_run()
4092 || i < conf->prev.raid_disks; in raid10_run()
4095 disk = conf->mirrors + i; in raid10_run()
4110 conf->fullsync = 1; in raid10_run()
4116 conf->fullsync = 1; in raid10_run()
4126 mdname(mddev), conf->geo.raid_disks - mddev->degraded, in raid10_run()
4127 conf->geo.raid_disks); in raid10_run()
4131 mddev->dev_sectors = conf->dev_sectors; in raid10_run()
4140 if (conf->reshape_progress != MaxSector) { in raid10_run()
4143 before_length = ((1 << conf->prev.chunk_shift) * in raid10_run()
4144 conf->prev.far_copies); in raid10_run()
4145 after_length = ((1 << conf->geo.chunk_shift) * in raid10_run()
4146 conf->geo.far_copies); in raid10_run()
4153 conf->offset_diff = min_offset_diff; in raid10_run()
4165 raid10_free_conf(conf); in raid10_run()
4178 struct r10conf *conf = mddev->private; in raid10_quiesce() local
4181 raise_barrier(conf, 0); in raid10_quiesce()
4183 lower_barrier(conf); in raid10_quiesce()
4200 struct r10conf *conf = mddev->private; in raid10_resize() local
4207 if (conf->geo.far_copies > 1 && !conf->geo.far_offset) in raid10_resize()
4226 calc_sectors(conf, sectors); in raid10_resize()
4227 mddev->dev_sectors = conf->dev_sectors; in raid10_resize()
4235 struct r10conf *conf; in raid10_takeover_raid0() local
4255 conf = setup_conf(mddev); in raid10_takeover_raid0()
4256 if (!IS_ERR(conf)) { in raid10_takeover_raid0()
4264 return conf; in raid10_takeover_raid0()
4305 struct r10conf *conf = mddev->private; in raid10_check_reshape() local
4308 if (conf->geo.far_copies != 1 && !conf->geo.far_offset) in raid10_check_reshape()
4311 if (setup_geo(&geo, mddev, geo_start) != conf->copies) in raid10_check_reshape()
4322 if (!enough(conf, -1)) in raid10_check_reshape()
4325 kfree(conf->mirrors_new); in raid10_check_reshape()
4326 conf->mirrors_new = NULL; in raid10_check_reshape()
4329 conf->mirrors_new = in raid10_check_reshape()
4333 if (!conf->mirrors_new) in raid10_check_reshape()
4352 static int calc_degraded(struct r10conf *conf) in calc_degraded() argument
4359 for (i = 0; i < conf->prev.raid_disks; i++) { in calc_degraded()
4360 struct md_rdev *rdev = conf->mirrors[i].rdev; in calc_degraded()
4371 if (conf->geo.raid_disks == conf->prev.raid_disks) in calc_degraded()
4374 for (i = 0; i < conf->geo.raid_disks; i++) { in calc_degraded()
4375 struct md_rdev *rdev = conf->mirrors[i].rdev; in calc_degraded()
4385 if (conf->geo.raid_disks <= conf->prev.raid_disks) in calc_degraded()
4410 struct r10conf *conf = mddev->private; in raid10_start_reshape() local
4418 if (setup_geo(&new, mddev, geo_start) != conf->copies) in raid10_start_reshape()
4421 before_length = ((1 << conf->prev.chunk_shift) * in raid10_start_reshape()
4422 conf->prev.far_copies); in raid10_start_reshape()
4423 after_length = ((1 << conf->geo.chunk_shift) * in raid10_start_reshape()
4424 conf->geo.far_copies); in raid10_start_reshape()
4449 conf->offset_diff = min_offset_diff; in raid10_start_reshape()
4450 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4451 if (conf->mirrors_new) { in raid10_start_reshape()
4452 memcpy(conf->mirrors_new, conf->mirrors, in raid10_start_reshape()
4453 sizeof(struct raid10_info)*conf->prev.raid_disks); in raid10_start_reshape()
4455 kfree(conf->mirrors_old); in raid10_start_reshape()
4456 conf->mirrors_old = conf->mirrors; in raid10_start_reshape()
4457 conf->mirrors = conf->mirrors_new; in raid10_start_reshape()
4458 conf->mirrors_new = NULL; in raid10_start_reshape()
4460 setup_geo(&conf->geo, mddev, geo_start); in raid10_start_reshape()
4465 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4471 conf->reshape_progress = size; in raid10_start_reshape()
4473 conf->reshape_progress = 0; in raid10_start_reshape()
4474 conf->reshape_safe = conf->reshape_progress; in raid10_start_reshape()
4475 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4482 newsize = raid10_size(mddev, 0, conf->geo.raid_disks); in raid10_start_reshape()
4524 conf->prev.raid_disks) in raid10_start_reshape()
4532 } else if (rdev->raid_disk >= conf->prev.raid_disks in raid10_start_reshape()
4542 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4543 mddev->degraded = calc_degraded(conf); in raid10_start_reshape()
4544 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4545 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4546 mddev->reshape_position = conf->reshape_progress; in raid10_start_reshape()
4554 conf->reshape_checkpoint = jiffies; in raid10_start_reshape()
4560 spin_lock_irq(&conf->device_lock); in raid10_start_reshape()
4561 conf->geo = conf->prev; in raid10_start_reshape()
4562 mddev->raid_disks = conf->geo.raid_disks; in raid10_start_reshape()
4566 conf->reshape_progress = MaxSector; in raid10_start_reshape()
4567 conf->reshape_safe = MaxSector; in raid10_start_reshape()
4569 spin_unlock_irq(&conf->device_lock); in raid10_start_reshape()
4634 * (conf->offset_diff - always positive) allows a bit of slack, in reshape_request()
4644 struct r10conf *conf = mddev->private; in reshape_request() local
4660 conf->reshape_progress < raid10_size(mddev, 0, 0)) { in reshape_request()
4662 - conf->reshape_progress); in reshape_request()
4664 conf->reshape_progress > 0) in reshape_request()
4665 sector_nr = conf->reshape_progress; in reshape_request()
4682 next = first_dev_address(conf->reshape_progress - 1, in reshape_request()
4683 &conf->geo); in reshape_request()
4688 safe = last_dev_address(conf->reshape_safe - 1, in reshape_request()
4689 &conf->prev); in reshape_request()
4691 if (next + conf->offset_diff < safe) in reshape_request()
4694 last = conf->reshape_progress - 1; in reshape_request()
4695 sector_nr = last & ~(sector_t)(conf->geo.chunk_mask in reshape_request()
4696 & conf->prev.chunk_mask); in reshape_request()
4703 next = last_dev_address(conf->reshape_progress, &conf->geo); in reshape_request()
4708 safe = first_dev_address(conf->reshape_safe, &conf->prev); in reshape_request()
4713 if (next > safe + conf->offset_diff) in reshape_request()
4716 sector_nr = conf->reshape_progress; in reshape_request()
4717 last = sector_nr | (conf->geo.chunk_mask in reshape_request()
4718 & conf->prev.chunk_mask); in reshape_request()
4725 time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) { in reshape_request()
4727 wait_barrier(conf, false); in reshape_request()
4728 mddev->reshape_position = conf->reshape_progress; in reshape_request()
4731 - conf->reshape_progress; in reshape_request()
4733 mddev->curr_resync_completed = conf->reshape_progress; in reshape_request()
4734 conf->reshape_checkpoint = jiffies; in reshape_request()
4740 allow_barrier(conf); in reshape_request()
4743 conf->reshape_safe = mddev->reshape_position; in reshape_request()
4744 allow_barrier(conf); in reshape_request()
4747 raise_barrier(conf, 0); in reshape_request()
4750 r10_bio = raid10_alloc_init_r10buf(conf); in reshape_request()
4752 raise_barrier(conf, 1); in reshape_request()
4758 rdev = read_balance(conf, r10_bio, &max_sectors); in reshape_request()
4766 mempool_free(r10_bio, &conf->r10buf_pool); in reshape_request()
4784 if (mddev_is_clustered(mddev) && conf->cluster_sync_high <= sector_nr) { in reshape_request()
4788 conf->cluster_sync_low = sector_nr; in reshape_request()
4789 conf->cluster_sync_high = sector_nr + CLUSTER_RESYNC_WINDOW_SECTORS; in reshape_request()
4798 if (sb_reshape_pos < conf->cluster_sync_low) in reshape_request()
4799 conf->cluster_sync_low = sb_reshape_pos; in reshape_request()
4802 md_cluster_ops->resync_info_update(mddev, conf->cluster_sync_low, in reshape_request()
4803 conf->cluster_sync_high); in reshape_request()
4807 __raid10_find_phys(&conf->geo, r10_bio); in reshape_request()
4812 for (s = 0; s < conf->copies*2; s++) { in reshape_request()
4817 rdev2 = conf->mirrors[d].replacement; in reshape_request()
4820 rdev2 = conf->mirrors[d].rdev; in reshape_request()
4865 lower_barrier(conf); in reshape_request()
4871 conf->reshape_progress -= sectors_done; in reshape_request()
4873 conf->reshape_progress += sectors_done; in reshape_request()
4888 struct r10conf *conf = mddev->private; in reshape_request_write() local
4902 for (s = 0; s < conf->copies*2; s++) { in reshape_request_write()
4907 rdev = conf->mirrors[d].replacement; in reshape_request_write()
4910 rdev = conf->mirrors[d].rdev; in reshape_request_write()
4925 static void end_reshape(struct r10conf *conf) in end_reshape() argument
4927 if (test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) in end_reshape()
4930 spin_lock_irq(&conf->device_lock); in end_reshape()
4931 conf->prev = conf->geo; in end_reshape()
4932 md_finish_reshape(conf->mddev); in end_reshape()
4934 conf->reshape_progress = MaxSector; in end_reshape()
4935 conf->reshape_safe = MaxSector; in end_reshape()
4936 spin_unlock_irq(&conf->device_lock); in end_reshape()
4938 mddev_update_io_opt(conf->mddev, raid10_nr_stripes(conf)); in end_reshape()
4939 conf->fullsync = 0; in end_reshape()
4944 struct r10conf *conf = mddev->private; in raid10_update_reshape_pos() local
4950 conf->reshape_progress = mddev->reshape_position; in raid10_update_reshape_pos()
4960 struct r10conf *conf = mddev->private; in handle_reshape_read_error() local
4966 r10b = kmalloc(struct_size(r10b, devs, conf->copies), GFP_NOIO); in handle_reshape_read_error()
4976 __raid10_find_phys(&conf->prev, r10b); in handle_reshape_read_error()
4988 struct md_rdev *rdev = conf->mirrors[d].rdev; in handle_reshape_read_error()
5007 if (slot >= conf->copies) in handle_reshape_read_error()
5030 struct r10conf *conf = mddev->private; in end_reshape_write() local
5036 d = find_bio_disk(conf, r10_bio, bio, &slot, &repl); in end_reshape_write()
5037 rdev = repl ? conf->mirrors[d].replacement : in end_reshape_write()
5038 conf->mirrors[d].rdev; in end_reshape_write()
5060 struct r10conf *conf = mddev->private; in raid10_finish_reshape() local
5073 for (d = conf->geo.raid_disks ; in raid10_finish_reshape()
5074 d < conf->geo.raid_disks - mddev->delta_disks; in raid10_finish_reshape()
5076 struct md_rdev *rdev = conf->mirrors[d].rdev; in raid10_finish_reshape()
5079 rdev = conf->mirrors[d].replacement; in raid10_finish_reshape()
5085 mddev->chunk_sectors = 1 << conf->geo.chunk_shift; in raid10_finish_reshape()