Lines Matching full:device

52 	struct drbd_device *device;  in drbd_md_endio()  local
54 device = bio->bi_private; in drbd_md_endio()
55 device->md_io.error = blk_status_to_errno(bio->bi_status); in drbd_md_endio()
58 if (device->ldev) in drbd_md_endio()
59 put_ldev(device); in drbd_md_endio()
63 * to timeout on the lower level device, and eventually detach from it. in drbd_md_endio()
71 * ASSERT(atomic_read(&device->md_io_in_use) == 1) there. in drbd_md_endio()
73 drbd_md_put_buffer(device); in drbd_md_endio()
74 device->md_io.done = 1; in drbd_md_endio()
75 wake_up(&device->misc_wait); in drbd_md_endio()
85 struct drbd_device *device = peer_device->device; in drbd_endio_read_sec_final() local
87 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_endio_read_sec_final()
88 device->read_cnt += peer_req->i.size >> 9; in drbd_endio_read_sec_final()
90 if (list_empty(&device->read_ee)) in drbd_endio_read_sec_final()
91 wake_up(&device->ee_wait); in drbd_endio_read_sec_final()
93 __drbd_chk_io_error(device, DRBD_READ_ERROR); in drbd_endio_read_sec_final()
94 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_endio_read_sec_final()
97 put_ldev(device); in drbd_endio_read_sec_final()
106 struct drbd_device *device = peer_device->device; in drbd_endio_write_sec_final() local
126 inc_unacked(device); in drbd_endio_write_sec_final()
130 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_endio_write_sec_final()
131 device->writ_cnt += peer_req->i.size >> 9; in drbd_endio_write_sec_final()
132 list_move_tail(&peer_req->w.list, &device->done_ee); in drbd_endio_write_sec_final()
142 do_wake = list_empty(block_id == ID_SYNCER ? &device->sync_ee : &device->active_ee); in drbd_endio_write_sec_final()
147 __drbd_chk_io_error(device, DRBD_WRITE_ERROR); in drbd_endio_write_sec_final()
150 kref_get(&device->kref); /* put is in drbd_send_acks_wf() */ in drbd_endio_write_sec_final()
152 kref_put(&device->kref, drbd_destroy_device); in drbd_endio_write_sec_final()
154 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_endio_write_sec_final()
157 drbd_rs_complete_io(device, i.sector); in drbd_endio_write_sec_final()
160 wake_up(&device->ee_wait); in drbd_endio_write_sec_final()
163 drbd_al_complete_io(device, &i); in drbd_endio_write_sec_final()
165 put_ldev(device); in drbd_endio_write_sec_final()
174 struct drbd_device *device = peer_req->peer_device->device; in drbd_peer_request_endio() local
180 drbd_warn(device, "%s: error=%d s=%llus\n", in drbd_peer_request_endio()
198 drbd_panic_after_delayed_completion_of_aborted_request(struct drbd_device *device) in drbd_panic_after_delayed_completion_of_aborted_request() argument
201 device->minor, device->resource->name, device->vnr); in drbd_panic_after_delayed_completion_of_aborted_request()
210 struct drbd_device *device = req->device; in drbd_request_endio() local
230 * If later the local backing device "recovers", and now DMAs some data in drbd_request_endio()
244 …drbd_emerg(device, "delayed completion of aborted local request; disk-timeout may be too aggressiv… in drbd_request_endio()
247 drbd_panic_after_delayed_completion_of_aborted_request(device); in drbd_request_endio()
278 spin_lock_irqsave(&device->resource->req_lock, flags); in drbd_request_endio()
280 spin_unlock_irqrestore(&device->resource->req_lock, flags); in drbd_request_endio()
281 put_ldev(device); in drbd_request_endio()
284 complete_master_bio(device, &m); in drbd_request_endio()
342 struct drbd_device *device = peer_device->device; in w_e_send_csum() local
364 drbd_free_peer_req(device, peer_req); in w_e_send_csum()
372 drbd_err(device, "kmalloc() of digest failed.\n"); in w_e_send_csum()
378 drbd_free_peer_req(device, peer_req); in w_e_send_csum()
381 drbd_err(device, "drbd_send_drequest(..., csum) failed\n"); in w_e_send_csum()
389 struct drbd_device *device = peer_device->device; in read_for_csum() local
392 if (!get_ldev(device)) in read_for_csum()
404 spin_lock_irq(&device->resource->req_lock); in read_for_csum()
405 list_add_tail(&peer_req->w.list, &device->read_ee); in read_for_csum()
406 spin_unlock_irq(&device->resource->req_lock); in read_for_csum()
408 atomic_add(size >> 9, &device->rs_sect_ev); in read_for_csum()
416 spin_lock_irq(&device->resource->req_lock); in read_for_csum()
418 spin_unlock_irq(&device->resource->req_lock); in read_for_csum()
420 drbd_free_peer_req(device, peer_req); in read_for_csum()
422 put_ldev(device); in read_for_csum()
428 struct drbd_device *device = in w_resync_timer() local
431 switch (device->state.conn) { in w_resync_timer()
433 make_ov_request(first_peer_device(device), cancel); in w_resync_timer()
436 make_resync_request(first_peer_device(device), cancel); in w_resync_timer()
445 struct drbd_device *device = from_timer(device, t, resync_timer); in resync_timer_fn() local
448 &first_peer_device(device)->connection->sender_work, in resync_timer_fn()
449 &device->resync_work); in resync_timer_fn()
498 struct drbd_device *device = peer_device->device; in drbd_rs_controller() local
509 dc = rcu_dereference(device->ldev->disk_conf); in drbd_rs_controller()
510 plan = rcu_dereference(device->rs_plan_s); in drbd_rs_controller()
514 if (device->rs_in_flight + sect_in == 0) { /* At start of resync */ in drbd_rs_controller()
521 correction = want - device->rs_in_flight - plan->total; in drbd_rs_controller()
541 drbd_warn(device, "si=%u if=%d wa=%u co=%d st=%d cps=%d pl=%d cc=%d rs=%d\n", in drbd_rs_controller()
542 sect_in, device->rs_in_flight, want, correction, in drbd_rs_controller()
543 steps, cps, device->rs_planed, curr_corr, req_sect); in drbd_rs_controller()
551 struct drbd_device *device = peer_device->device; in drbd_rs_number_requests() local
555 sect_in = atomic_xchg(&device->rs_sect_in, 0); in drbd_rs_number_requests()
556 device->rs_in_flight -= sect_in; in drbd_rs_number_requests()
559 mxb = drbd_get_max_buffers(device) / 2; in drbd_rs_number_requests()
560 if (rcu_dereference(device->rs_plan_s)->size) { in drbd_rs_number_requests()
562 device->c_sync_rate = number * HZ * (BM_BLOCK_SIZE / 1024) / SLEEP_TIME; in drbd_rs_number_requests()
564 device->c_sync_rate = rcu_dereference(device->ldev->disk_conf)->resync_rate; in drbd_rs_number_requests()
565 number = SLEEP_TIME * device->c_sync_rate / ((BM_BLOCK_SIZE / 1024) * HZ); in drbd_rs_number_requests()
579 if (mxb - device->rs_in_flight/8 < number) in drbd_rs_number_requests()
580 number = mxb - device->rs_in_flight/8; in drbd_rs_number_requests()
587 struct drbd_device *const device = peer_device->device; in make_resync_request() local
591 const sector_t capacity = get_capacity(device->vdisk); in make_resync_request()
601 if (device->rs_total == 0) { in make_resync_request()
607 if (!get_ldev(device)) { in make_resync_request()
608 /* Since we only need to access device->rsync a in make_resync_request()
609 get_ldev_if_state(device,D_FAILED) would be sufficient, but in make_resync_request()
612 drbd_err(device, "Disk broke down during resync!\n"); in make_resync_request()
618 discard_granularity = rcu_dereference(device->ldev->disk_conf)->rs_discard_granularity; in make_resync_request()
622 max_bio_size = queue_max_hw_sectors(device->rq_queue) << 9; in make_resync_request()
648 bit = drbd_bm_find_next(device, device->bm_resync_fo); in make_resync_request()
651 device->bm_resync_fo = drbd_bm_bits(device); in make_resync_request()
652 put_ldev(device); in make_resync_request()
659 device->bm_resync_fo = bit; in make_resync_request()
662 device->bm_resync_fo = bit + 1; in make_resync_request()
664 if (unlikely(drbd_bm_test_bit(device, bit) == 0)) { in make_resync_request()
665 drbd_rs_complete_io(device, sector); in make_resync_request()
697 if (drbd_bm_test_bit(device, bit+1) != 1) in make_resync_request()
708 device->bm_resync_fo = bit + 1; in make_resync_request()
715 if (device->use_csums) { in make_resync_request()
718 put_ldev(device); in make_resync_request()
721 drbd_rs_complete_io(device, sector); in make_resync_request()
722 device->bm_resync_fo = BM_SECT_TO_BIT(sector); in make_resync_request()
739 drbd_err(device, "drbd_send_drequest() failed, aborting...\n"); in make_resync_request()
741 put_ldev(device); in make_resync_request()
747 if (device->bm_resync_fo >= drbd_bm_bits(device)) { in make_resync_request()
754 put_ldev(device); in make_resync_request()
759 device->rs_in_flight += (i << (BM_BLOCK_SHIFT - 9)); in make_resync_request()
760 mod_timer(&device->resync_timer, jiffies + SLEEP_TIME); in make_resync_request()
761 put_ldev(device); in make_resync_request()
767 struct drbd_device *device = peer_device->device; in make_ov_request() local
770 const sector_t capacity = get_capacity(device->vdisk); in make_ov_request()
778 sector = device->ov_position; in make_ov_request()
787 && verify_can_do_stop_sector(device) in make_ov_request()
788 && sector >= device->ov_stop_sector; in make_ov_request()
795 device->ov_position = sector; in make_ov_request()
803 if (drbd_send_ov_request(first_peer_device(device), sector, size)) { in make_ov_request()
809 device->ov_position = sector; in make_ov_request()
812 device->rs_in_flight += (i << (BM_BLOCK_SHIFT - 9)); in make_ov_request()
814 mod_timer(&device->resync_timer, jiffies + SLEEP_TIME); in make_ov_request()
822 struct drbd_device *device = dw->device; in w_ov_finished() local
824 ov_out_of_sync_print(first_peer_device(device)); in w_ov_finished()
825 drbd_resync_finished(first_peer_device(device)); in w_ov_finished()
834 struct drbd_device *device = dw->device; in w_resync_finished() local
837 drbd_resync_finished(first_peer_device(device)); in w_resync_finished()
842 static void ping_peer(struct drbd_device *device) in ping_peer() argument
844 struct drbd_connection *connection = first_peer_device(device)->connection; in ping_peer()
849 test_bit(GOT_PING_ACK, &connection->flags) || device->state.conn < C_CONNECTED); in ping_peer()
854 struct drbd_device *device = peer_device->device; in drbd_resync_finished() local
866 if (drbd_rs_del_all(device)) { in drbd_resync_finished()
876 dw->device = device; in drbd_resync_finished()
880 drbd_err(device, "Warn failed to drbd_rs_del_all() and to kmalloc(dw).\n"); in drbd_resync_finished()
883 dt = (jiffies - device->rs_start - device->rs_paused) / HZ; in drbd_resync_finished()
887 db = device->rs_total; in drbd_resync_finished()
889 if (device->state.conn == C_VERIFY_S || device->state.conn == C_VERIFY_T) in drbd_resync_finished()
890 db -= device->ov_left; in drbd_resync_finished()
893 device->rs_paused /= HZ; in drbd_resync_finished()
895 if (!get_ldev(device)) in drbd_resync_finished()
898 ping_peer(device); in drbd_resync_finished()
900 spin_lock_irq(&device->resource->req_lock); in drbd_resync_finished()
901 os = drbd_read_state(device); in drbd_resync_finished()
913 drbd_info(device, "%s done (total %lu sec; paused %lu sec; %lu K/sec)\n", in drbd_resync_finished()
915 dt + device->rs_paused, device->rs_paused, dbdt); in drbd_resync_finished()
917 n_oos = drbd_bm_total_weight(device); in drbd_resync_finished()
921 drbd_alert(device, "Online verify found %lu %dk block out of sync!\n", in drbd_resync_finished()
926 D_ASSERT(device, (n_oos - device->rs_failed) == 0); in drbd_resync_finished()
931 if (device->use_csums && device->rs_total) { in drbd_resync_finished()
932 const unsigned long s = device->rs_same_csum; in drbd_resync_finished()
933 const unsigned long t = device->rs_total; in drbd_resync_finished()
937 drbd_info(device, "%u %% had equal checksums, eliminated: %luK; " in drbd_resync_finished()
940 Bit2KB(device->rs_same_csum), in drbd_resync_finished()
941 Bit2KB(device->rs_total - device->rs_same_csum), in drbd_resync_finished()
942 Bit2KB(device->rs_total)); in drbd_resync_finished()
946 if (device->rs_failed) { in drbd_resync_finished()
947 drbd_info(device, " %lu failed blocks\n", device->rs_failed); in drbd_resync_finished()
961 if (device->p_uuid) { in drbd_resync_finished()
964 _drbd_uuid_set(device, i, device->p_uuid[i]); in drbd_resync_finished()
965 drbd_uuid_set(device, UI_BITMAP, device->ldev->md.uuid[UI_CURRENT]); in drbd_resync_finished()
966 _drbd_uuid_set(device, UI_CURRENT, device->p_uuid[UI_CURRENT]); in drbd_resync_finished()
968 drbd_err(device, "device->p_uuid is NULL! BUG\n"); in drbd_resync_finished()
975 drbd_uuid_set_bm(device, 0UL); in drbd_resync_finished()
976 drbd_print_uuids(device, "updated UUIDs"); in drbd_resync_finished()
977 if (device->p_uuid) { in drbd_resync_finished()
982 device->p_uuid[i] = device->ldev->md.uuid[i]; in drbd_resync_finished()
987 _drbd_set_state(device, ns, CS_VERBOSE, NULL); in drbd_resync_finished()
989 spin_unlock_irq(&device->resource->req_lock); in drbd_resync_finished()
999 fp = rcu_dereference(device->ldev->disk_conf)->fencing; in drbd_resync_finished()
1004 struct drbd_device *device = peer_device->device; in drbd_resync_finished() local
1005 disk_state = min_t(enum drbd_disk_state, disk_state, device->state.disk); in drbd_resync_finished()
1006 pdsk_state = min_t(enum drbd_disk_state, pdsk_state, device->state.pdsk); in drbd_resync_finished()
1014 put_ldev(device); in drbd_resync_finished()
1016 device->rs_total = 0; in drbd_resync_finished()
1017 device->rs_failed = 0; in drbd_resync_finished()
1018 device->rs_paused = 0; in drbd_resync_finished()
1020 /* reset start sector, if we reached end of device */ in drbd_resync_finished()
1021 if (verify_done && device->ov_left == 0) in drbd_resync_finished()
1022 device->ov_start_sector = 0; in drbd_resync_finished()
1024 drbd_md_sync(device); in drbd_resync_finished()
1027 drbd_khelper(device, khelper_cmd); in drbd_resync_finished()
1033 static void move_to_net_ee_or_free(struct drbd_device *device, struct drbd_peer_request *peer_req) in move_to_net_ee_or_free() argument
1038 atomic_add(i, &device->pp_in_use_by_net); in move_to_net_ee_or_free()
1039 atomic_sub(i, &device->pp_in_use); in move_to_net_ee_or_free()
1040 spin_lock_irq(&device->resource->req_lock); in move_to_net_ee_or_free()
1041 list_add_tail(&peer_req->w.list, &device->net_ee); in move_to_net_ee_or_free()
1042 spin_unlock_irq(&device->resource->req_lock); in move_to_net_ee_or_free()
1045 drbd_free_peer_req(device, peer_req); in move_to_net_ee_or_free()
1057 struct drbd_device *device = peer_device->device; in w_e_end_data_req() local
1061 drbd_free_peer_req(device, peer_req); in w_e_end_data_req()
1062 dec_unacked(device); in w_e_end_data_req()
1070 drbd_err(device, "Sending NegDReply. sector=%llus.\n", in w_e_end_data_req()
1076 dec_unacked(device); in w_e_end_data_req()
1078 move_to_net_ee_or_free(device, peer_req); in w_e_end_data_req()
1081 drbd_err(device, "drbd_send_block() failed\n"); in w_e_end_data_req()
1118 struct drbd_device *device = peer_device->device; in w_e_end_rsdata_req() local
1122 drbd_free_peer_req(device, peer_req); in w_e_end_rsdata_req()
1123 dec_unacked(device); in w_e_end_rsdata_req()
1127 if (get_ldev_if_state(device, D_FAILED)) { in w_e_end_rsdata_req()
1128 drbd_rs_complete_io(device, peer_req->i.sector); in w_e_end_rsdata_req()
1129 put_ldev(device); in w_e_end_rsdata_req()
1132 if (device->state.conn == C_AHEAD) { in w_e_end_rsdata_req()
1135 if (likely(device->state.pdsk >= D_INCONSISTENT)) { in w_e_end_rsdata_req()
1143 drbd_err(device, "Not sending RSDataReply, " in w_e_end_rsdata_req()
1149 drbd_err(device, "Sending NegRSDReply. sector %llus.\n", in w_e_end_rsdata_req()
1158 dec_unacked(device); in w_e_end_rsdata_req()
1160 move_to_net_ee_or_free(device, peer_req); in w_e_end_rsdata_req()
1163 drbd_err(device, "drbd_send_block() failed\n"); in w_e_end_rsdata_req()
1171 struct drbd_device *device = peer_device->device; in w_e_end_csum_rs_req() local
1178 drbd_free_peer_req(device, peer_req); in w_e_end_csum_rs_req()
1179 dec_unacked(device); in w_e_end_csum_rs_req()
1183 if (get_ldev(device)) { in w_e_end_csum_rs_req()
1184 drbd_rs_complete_io(device, peer_req->i.sector); in w_e_end_csum_rs_req()
1185 put_ldev(device); in w_e_end_csum_rs_req()
1196 D_ASSERT(device, digest_size == di->digest_size); in w_e_end_csum_rs_req()
1208 device->rs_same_csum += peer_req->i.size >> BM_BLOCK_SHIFT; in w_e_end_csum_rs_req()
1220 drbd_err(device, "Sending NegDReply. I guess it gets messy.\n"); in w_e_end_csum_rs_req()
1223 dec_unacked(device); in w_e_end_csum_rs_req()
1224 move_to_net_ee_or_free(device, peer_req); in w_e_end_csum_rs_req()
1227 drbd_err(device, "drbd_send_block/ack() failed\n"); in w_e_end_csum_rs_req()
1235 struct drbd_device *device = peer_device->device; in w_e_end_ov_req() local
1262 drbd_free_peer_req(device, peer_req); in w_e_end_ov_req()
1272 drbd_free_peer_req(device, peer_req); in w_e_end_ov_req()
1273 dec_unacked(device); in w_e_end_ov_req()
1279 struct drbd_device *device = peer_device->device; in drbd_ov_out_of_sync_found() local
1280 if (device->ov_last_oos_start + device->ov_last_oos_size == sector) { in drbd_ov_out_of_sync_found()
1281 device->ov_last_oos_size += size>>9; in drbd_ov_out_of_sync_found()
1283 device->ov_last_oos_start = sector; in drbd_ov_out_of_sync_found()
1284 device->ov_last_oos_size = size>>9; in drbd_ov_out_of_sync_found()
1293 struct drbd_device *device = peer_device->device; in w_e_end_ov_reply() local
1303 drbd_free_peer_req(device, peer_req); in w_e_end_ov_reply()
1304 dec_unacked(device); in w_e_end_ov_reply()
1310 if (get_ldev(device)) { in w_e_end_ov_reply()
1311 drbd_rs_complete_io(device, peer_req->i.sector); in w_e_end_ov_reply()
1312 put_ldev(device); in w_e_end_ov_reply()
1323 D_ASSERT(device, digest_size == di->digest_size); in w_e_end_ov_reply()
1334 drbd_free_peer_req(device, peer_req); in w_e_end_ov_reply()
1343 dec_unacked(device); in w_e_end_ov_reply()
1345 --device->ov_left; in w_e_end_ov_reply()
1348 if ((device->ov_left & 0x200) == 0x200) in w_e_end_ov_reply()
1349 drbd_advance_rs_marks(peer_device, device->ov_left); in w_e_end_ov_reply()
1351 stop_sector_reached = verify_can_do_stop_sector(device) && in w_e_end_ov_reply()
1352 (sector + (size>>9)) >= device->ov_stop_sector; in w_e_end_ov_reply()
1354 if (device->ov_left == 0 || stop_sector_reached) { in w_e_end_ov_reply()
1394 struct drbd_device *device = in w_send_write_hint() local
1399 return pd_send_unplug_remote(first_peer_device(device)); in w_send_write_hint()
1427 struct drbd_device *device = req->device; in w_send_out_of_sync() local
1428 struct drbd_peer_device *const peer_device = first_peer_device(device); in w_send_out_of_sync()
1458 struct drbd_device *device = req->device; in w_send_dblock() local
1459 struct drbd_peer_device *const peer_device = first_peer_device(device); in w_send_dblock()
1491 struct drbd_device *device = req->device; in w_send_read_req() local
1492 struct drbd_peer_device *const peer_device = first_peer_device(device); in w_send_read_req()
1521 struct drbd_device *device = req->device; in w_restart_disk_io() local
1524 drbd_al_begin_io(device, &req->i); in w_restart_disk_io()
1526 req->private_bio = bio_alloc_clone(device->ldev->backing_bdev, in w_restart_disk_io()
1536 static int _drbd_may_sync_now(struct drbd_device *device) in _drbd_may_sync_now() argument
1538 struct drbd_device *odev = device; in _drbd_may_sync_now()
1562 * @device: DRBD device.
1566 static bool drbd_pause_after(struct drbd_device *device) in drbd_pause_after() argument
1588 * @device: DRBD device.
1592 static bool drbd_resume_next(struct drbd_device *device) in drbd_resume_next() argument
1613 void resume_next_sg(struct drbd_device *device) in resume_next_sg() argument
1616 drbd_resume_next(device); in resume_next_sg()
1620 void suspend_other_sg(struct drbd_device *device) in suspend_other_sg() argument
1623 drbd_pause_after(device); in suspend_other_sg()
1628 enum drbd_ret_code drbd_resync_after_valid(struct drbd_device *device, int o_minor) in drbd_resync_after_valid() argument
1641 if (odev == device) in drbd_resync_after_valid()
1666 void drbd_resync_after_changed(struct drbd_device *device) in drbd_resync_after_changed() argument
1671 changed = drbd_pause_after(device); in drbd_resync_after_changed()
1672 changed |= drbd_resume_next(device); in drbd_resync_after_changed()
1678 struct drbd_device *device = peer_device->device; in drbd_rs_controller_reset() local
1679 struct gendisk *disk = device->ldev->backing_bdev->bd_disk; in drbd_rs_controller_reset()
1682 atomic_set(&device->rs_sect_in, 0); in drbd_rs_controller_reset()
1683 atomic_set(&device->rs_sect_ev, 0); in drbd_rs_controller_reset()
1684 device->rs_in_flight = 0; in drbd_rs_controller_reset()
1685 device->rs_last_events = in drbd_rs_controller_reset()
1693 plan = rcu_dereference(device->rs_plan_s); in drbd_rs_controller_reset()
1701 struct drbd_device *device = from_timer(device, t, start_resync_timer); in start_resync_timer_fn() local
1702 drbd_device_post_work(device, RS_START); in start_resync_timer_fn()
1705 static void do_start_resync(struct drbd_device *device) in do_start_resync() argument
1707 if (atomic_read(&device->unacked_cnt) || atomic_read(&device->rs_pending_cnt)) { in do_start_resync()
1708 drbd_warn(device, "postponing start_resync ...\n"); in do_start_resync()
1709 device->start_resync_timer.expires = jiffies + HZ/10; in do_start_resync()
1710 add_timer(&device->start_resync_timer); in do_start_resync()
1714 drbd_start_resync(device, C_SYNC_SOURCE); in do_start_resync()
1715 clear_bit(AHEAD_TO_SYNC_SOURCE, &device->flags); in do_start_resync()
1718 …atic bool use_checksum_based_resync(struct drbd_connection *connection, struct drbd_device *device) in use_checksum_based_resync() argument
1727 || test_bit(CRASHED_PRIMARY, &device->flags)); /* or only after Primary crash? */ in use_checksum_based_resync()
1732 * @device: DRBD device.
1738 void drbd_start_resync(struct drbd_device *device, enum drbd_conns side) in drbd_start_resync() argument
1740 struct drbd_peer_device *peer_device = first_peer_device(device); in drbd_start_resync()
1745 if (device->state.conn >= C_SYNC_SOURCE && device->state.conn < C_AHEAD) { in drbd_start_resync()
1746 drbd_err(device, "Resync already running!\n"); in drbd_start_resync()
1751 drbd_err(device, "No connection to peer, aborting!\n"); in drbd_start_resync()
1755 if (!test_bit(B_RS_H_DONE, &device->flags)) { in drbd_start_resync()
1760 r = drbd_khelper(device, "before-resync-target"); in drbd_start_resync()
1763 drbd_info(device, "before-resync-target handler returned %d, " in drbd_start_resync()
1769 r = drbd_khelper(device, "before-resync-source"); in drbd_start_resync()
1773 drbd_info(device, "before-resync-source handler returned %d, " in drbd_start_resync()
1776 drbd_info(device, "before-resync-source handler returned %d, " in drbd_start_resync()
1789 if (!mutex_trylock(device->state_mutex)) { in drbd_start_resync()
1790 set_bit(B_RS_H_DONE, &device->flags); in drbd_start_resync()
1791 device->start_resync_timer.expires = jiffies + HZ/5; in drbd_start_resync()
1792 add_timer(&device->start_resync_timer); in drbd_start_resync()
1796 mutex_lock(device->state_mutex); in drbd_start_resync()
1800 clear_bit(B_RS_H_DONE, &device->flags); in drbd_start_resync()
1802 if (device->state.conn < C_CONNECTED in drbd_start_resync()
1803 || !get_ldev_if_state(device, D_NEGOTIATING)) { in drbd_start_resync()
1808 ns = drbd_read_state(device); in drbd_start_resync()
1810 ns.aftr_isp = !_drbd_may_sync_now(device); in drbd_start_resync()
1819 r = _drbd_set_state(device, ns, CS_VERBOSE, NULL); in drbd_start_resync()
1820 ns = drbd_read_state(device); in drbd_start_resync()
1826 unsigned long tw = drbd_bm_total_weight(device); in drbd_start_resync()
1830 device->rs_failed = 0; in drbd_start_resync()
1831 device->rs_paused = 0; in drbd_start_resync()
1832 device->rs_same_csum = 0; in drbd_start_resync()
1833 device->rs_last_sect_ev = 0; in drbd_start_resync()
1834 device->rs_total = tw; in drbd_start_resync()
1835 device->rs_start = now; in drbd_start_resync()
1837 device->rs_mark_left[i] = tw; in drbd_start_resync()
1838 device->rs_mark_time[i] = now; in drbd_start_resync()
1840 drbd_pause_after(device); in drbd_start_resync()
1842 * Open coded drbd_rs_cancel_all(device), we already have IRQs in drbd_start_resync()
1844 spin_lock(&device->al_lock); in drbd_start_resync()
1845 lc_reset(device->resync); in drbd_start_resync()
1846 device->resync_locked = 0; in drbd_start_resync()
1847 device->resync_wenr = LC_FREE; in drbd_start_resync()
1848 spin_unlock(&device->al_lock); in drbd_start_resync()
1853 wake_up(&device->al_wait); /* for lc_reset() above */ in drbd_start_resync()
1856 device->rs_last_bcast = jiffies - HZ; in drbd_start_resync()
1858 drbd_info(device, "Began resync as %s (will sync %lu KB [%lu bits set]).\n", in drbd_start_resync()
1860 (unsigned long) device->rs_total << (BM_BLOCK_SHIFT-10), in drbd_start_resync()
1861 (unsigned long) device->rs_total); in drbd_start_resync()
1863 device->bm_resync_fo = 0; in drbd_start_resync()
1864 device->use_csums = use_checksum_based_resync(connection, device); in drbd_start_resync()
1866 device->use_csums = false; in drbd_start_resync()
1879 if (connection->agreed_pro_version < 95 && device->rs_total == 0) { in drbd_start_resync()
1904 /* ns.conn may already be != device->state.conn, in drbd_start_resync()
1909 mod_timer(&device->resync_timer, jiffies); in drbd_start_resync()
1911 drbd_md_sync(device); in drbd_start_resync()
1913 put_ldev(device); in drbd_start_resync()
1915 mutex_unlock(device->state_mutex); in drbd_start_resync()
1920 struct drbd_device *device = peer_device->device; in update_on_disk_bitmap() local
1922 device->rs_last_bcast = jiffies; in update_on_disk_bitmap()
1924 if (!get_ldev(device)) in update_on_disk_bitmap()
1927 drbd_bm_write_lazy(device, 0); in update_on_disk_bitmap()
1928 if (resync_done && is_sync_state(device->state.conn)) in update_on_disk_bitmap()
1931 drbd_bcast_event(device, &sib); in update_on_disk_bitmap()
1933 device->rs_last_bcast = jiffies; in update_on_disk_bitmap()
1934 put_ldev(device); in update_on_disk_bitmap()
1937 static void drbd_ldev_destroy(struct drbd_device *device) in drbd_ldev_destroy() argument
1939 lc_destroy(device->resync); in drbd_ldev_destroy()
1940 device->resync = NULL; in drbd_ldev_destroy()
1941 lc_destroy(device->act_log); in drbd_ldev_destroy()
1942 device->act_log = NULL; in drbd_ldev_destroy()
1945 drbd_backing_dev_free(device, device->ldev); in drbd_ldev_destroy()
1946 device->ldev = NULL; in drbd_ldev_destroy()
1949 clear_bit(GOING_DISKLESS, &device->flags); in drbd_ldev_destroy()
1950 wake_up(&device->misc_wait); in drbd_ldev_destroy()
1953 static void go_diskless(struct drbd_device *device) in go_diskless() argument
1955 struct drbd_peer_device *peer_device = first_peer_device(device); in go_diskless()
1956 D_ASSERT(device, device->state.disk == D_FAILED); in go_diskless()
1975 if (device->bitmap && device->ldev) { in go_diskless()
1980 if (drbd_bitmap_io_from_worker(device, drbd_bm_write, in go_diskless()
1982 if (test_bit(WAS_READ_ERROR, &device->flags)) { in go_diskless()
1983 drbd_md_set_flag(device, MDF_FULL_SYNC); in go_diskless()
1984 drbd_md_sync(device); in go_diskless()
1989 drbd_force_state(device, NS(disk, D_DISKLESS)); in go_diskless()
1992 static int do_md_sync(struct drbd_device *device) in do_md_sync() argument
1994 drbd_warn(device, "md_sync_timer expired! Worker calls drbd_md_sync().\n"); in do_md_sync()
1995 drbd_md_sync(device); in do_md_sync()
2022 static void do_device_work(struct drbd_device *device, const unsigned long todo) in do_device_work() argument
2025 do_md_sync(device); in do_device_work()
2028 update_on_disk_bitmap(first_peer_device(device), test_bit(RS_DONE, &todo)); in do_device_work()
2030 go_diskless(device); in do_device_work()
2032 drbd_ldev_destroy(device); in do_device_work()
2034 do_start_resync(device); in do_device_work()
2063 struct drbd_device *device = peer_device->device; in do_unqueued_work() local
2064 unsigned long todo = get_work_bits(&device->flags); in do_unqueued_work()
2068 kref_get(&device->kref); in do_unqueued_work()
2070 do_device_work(device, todo); in do_unqueued_work()
2071 kref_put(&device->kref, drbd_destroy_device); in do_unqueued_work()
2230 struct drbd_device *device = peer_device->device; in drbd_worker() local
2231 D_ASSERT(device, device->state.disk == D_DISKLESS && device->state.conn == C_STANDALONE); in drbd_worker()
2232 kref_get(&device->kref); in drbd_worker()
2234 drbd_device_cleanup(device); in drbd_worker()
2235 kref_put(&device->kref, drbd_destroy_device); in drbd_worker()