Lines Matching full:device

57 	 * sectors-written since device creation, and other data generation tag
73 * allows to cover device sizes of up to 2**54 Byte (16 PiB) */
82 void *drbd_md_get_buffer(struct drbd_device *device, const char *intent) in drbd_md_get_buffer() argument
86 wait_event(device->misc_wait, in drbd_md_get_buffer()
87 (r = atomic_cmpxchg(&device->md_io.in_use, 0, 1)) == 0 || in drbd_md_get_buffer()
88 device->state.disk <= D_FAILED); in drbd_md_get_buffer()
93 device->md_io.current_use = intent; in drbd_md_get_buffer()
94 device->md_io.start_jif = jiffies; in drbd_md_get_buffer()
95 device->md_io.submit_jif = device->md_io.start_jif - 1; in drbd_md_get_buffer()
96 return page_address(device->md_io.page); in drbd_md_get_buffer()
99 void drbd_md_put_buffer(struct drbd_device *device) in drbd_md_put_buffer() argument
101 if (atomic_dec_and_test(&device->md_io.in_use)) in drbd_md_put_buffer()
102 wake_up(&device->misc_wait); in drbd_md_put_buffer()
105 void wait_until_done_or_force_detached(struct drbd_device *device, struct drbd_backing_dev *bdev, in wait_until_done_or_force_detached() argument
117 dt = wait_event_timeout(device->misc_wait, in wait_until_done_or_force_detached()
118 *done || test_bit(FORCE_DETACH, &device->flags), dt); in wait_until_done_or_force_detached()
120 drbd_err(device, "meta-data IO operation timed out\n"); in wait_until_done_or_force_detached()
121 drbd_chk_io_error(device, 1, DRBD_FORCE_DETACH); in wait_until_done_or_force_detached()
125 static int _drbd_md_sync_page_io(struct drbd_device *device, in _drbd_md_sync_page_io() argument
134 device->md_io.done = 0; in _drbd_md_sync_page_io()
135 device->md_io.error = -ENODEV; in _drbd_md_sync_page_io()
137 if ((op == REQ_OP_WRITE) && !test_bit(MD_NO_FUA, &device->flags)) in _drbd_md_sync_page_io()
145 if (bio_add_page(bio, device->md_io.page, size, 0) != size) in _drbd_md_sync_page_io()
147 bio->bi_private = device; in _drbd_md_sync_page_io()
151 if (op != REQ_OP_WRITE && device->state.disk == D_DISKLESS && device->ldev == NULL) in _drbd_md_sync_page_io()
154 else if (!get_ldev_if_state(device, D_ATTACHING)) { in _drbd_md_sync_page_io()
156 drbd_err(device, "ASSERT FAILED: get_ldev_if_state() == 1 in _drbd_md_sync_page_io()\n"); in _drbd_md_sync_page_io()
162 atomic_inc(&device->md_io.in_use); /* drbd_md_put_buffer() is in the completion handler */ in _drbd_md_sync_page_io()
163 device->md_io.submit_jif = jiffies; in _drbd_md_sync_page_io()
164 if (drbd_insert_fault(device, (op == REQ_OP_WRITE) ? DRBD_FAULT_MD_WR : DRBD_FAULT_MD_RD)) in _drbd_md_sync_page_io()
168 wait_until_done_or_force_detached(device, bdev, &device->md_io.done); in _drbd_md_sync_page_io()
170 err = device->md_io.error; in _drbd_md_sync_page_io()
177 int drbd_md_sync_page_io(struct drbd_device *device, struct drbd_backing_dev *bdev, in drbd_md_sync_page_io() argument
181 D_ASSERT(device, atomic_read(&device->md_io.in_use) == 1); in drbd_md_sync_page_io()
185 dynamic_drbd_dbg(device, "meta_data io: %s [%d]:%s(,%llus,%s) %pS\n", in drbd_md_sync_page_io()
192 drbd_alert(device, "%s [%d]:%s(,%llus,%s) out of range md access!\n", in drbd_md_sync_page_io()
197 err = _drbd_md_sync_page_io(device, bdev, sector, op); in drbd_md_sync_page_io()
199 drbd_err(device, "drbd_md_sync_page_io(,%llus,%s) failed with error %d\n", in drbd_md_sync_page_io()
206 static struct bm_extent *find_active_resync_extent(struct drbd_device *device, unsigned int enr) in find_active_resync_extent() argument
209 tmp = lc_find(device->resync, enr/AL_EXT_PER_BM_SECT); in find_active_resync_extent()
218 static struct lc_element *_al_get(struct drbd_device *device, unsigned int enr, bool nonblock) in _al_get() argument
224 spin_lock_irq(&device->al_lock); in _al_get()
225 bm_ext = find_active_resync_extent(device, enr); in _al_get()
228 spin_unlock_irq(&device->al_lock); in _al_get()
230 wake_up(&device->al_wait); in _al_get()
234 al_ext = lc_try_get(device->act_log, enr); in _al_get()
236 al_ext = lc_get(device->act_log, enr); in _al_get()
237 spin_unlock_irq(&device->al_lock); in _al_get()
241 bool drbd_al_begin_io_fastpath(struct drbd_device *device, struct drbd_interval *i) in drbd_al_begin_io_fastpath() argument
248 D_ASSERT(device, first <= last); in drbd_al_begin_io_fastpath()
249 D_ASSERT(device, atomic_read(&device->local_cnt) > 0); in drbd_al_begin_io_fastpath()
255 return _al_get(device, first, true); in drbd_al_begin_io_fastpath()
258 bool drbd_al_begin_io_prepare(struct drbd_device *device, struct drbd_interval *i) in drbd_al_begin_io_prepare() argument
267 D_ASSERT(device, first <= last); in drbd_al_begin_io_prepare()
268 D_ASSERT(device, atomic_read(&device->local_cnt) > 0); in drbd_al_begin_io_prepare()
272 wait_event(device->al_wait, in drbd_al_begin_io_prepare()
273 (al_ext = _al_get(device, enr, false)) != NULL); in drbd_al_begin_io_prepare()
298 static sector_t al_tr_number_to_on_disk_sector(struct drbd_device *device) in al_tr_number_to_on_disk_sector() argument
300 const unsigned int stripes = device->ldev->md.al_stripes; in al_tr_number_to_on_disk_sector()
301 const unsigned int stripe_size_4kB = device->ldev->md.al_stripe_size_4k; in al_tr_number_to_on_disk_sector()
304 unsigned int t = device->al_tr_number % (device->ldev->md.al_size_4k); in al_tr_number_to_on_disk_sector()
313 return device->ldev->md.md_offset + device->ldev->md.al_offset + t; in al_tr_number_to_on_disk_sector()
316 static int __al_write_transaction(struct drbd_device *device, struct al_transaction_on_disk *buffer) in __al_write_transaction() argument
327 buffer->tr_number = cpu_to_be32(device->al_tr_number); in __al_write_transaction()
331 drbd_bm_reset_al_hints(device); in __al_write_transaction()
337 spin_lock_irq(&device->al_lock); in __al_write_transaction()
338 list_for_each_entry(e, &device->act_log->to_be_changed, list) { in __al_write_transaction()
346 drbd_bm_mark_for_writeout(device, in __al_write_transaction()
350 spin_unlock_irq(&device->al_lock); in __al_write_transaction()
359 buffer->context_size = cpu_to_be16(device->act_log->nr_elements); in __al_write_transaction()
360 buffer->context_start_slot_nr = cpu_to_be16(device->al_tr_cycle); in __al_write_transaction()
363 device->act_log->nr_elements - device->al_tr_cycle); in __al_write_transaction()
365 unsigned idx = device->al_tr_cycle + i; in __al_write_transaction()
366 extent_nr = lc_element_by_index(device->act_log, idx)->lc_number; in __al_write_transaction()
372 device->al_tr_cycle += AL_CONTEXT_PER_TRANSACTION; in __al_write_transaction()
373 if (device->al_tr_cycle >= device->act_log->nr_elements) in __al_write_transaction()
374 device->al_tr_cycle = 0; in __al_write_transaction()
376 sector = al_tr_number_to_on_disk_sector(device); in __al_write_transaction()
381 if (drbd_bm_write_hinted(device)) in __al_write_transaction()
386 write_al_updates = rcu_dereference(device->ldev->disk_conf)->al_updates; in __al_write_transaction()
389 if (drbd_md_sync_page_io(device, device->ldev, sector, WRITE)) { in __al_write_transaction()
391 drbd_chk_io_error(device, 1, DRBD_META_IO_ERROR); in __al_write_transaction()
393 device->al_tr_number++; in __al_write_transaction()
394 device->al_writ_cnt++; in __al_write_transaction()
402 static int al_write_transaction(struct drbd_device *device) in al_write_transaction() argument
407 if (!get_ldev(device)) { in al_write_transaction()
408 drbd_err(device, "disk is %s, cannot start al transaction\n", in al_write_transaction()
409 drbd_disk_str(device->state.disk)); in al_write_transaction()
414 if (device->state.disk < D_INCONSISTENT) { in al_write_transaction()
415 drbd_err(device, in al_write_transaction()
417 drbd_disk_str(device->state.disk)); in al_write_transaction()
418 put_ldev(device); in al_write_transaction()
423 buffer = drbd_md_get_buffer(device, __func__); in al_write_transaction()
425 drbd_err(device, "disk failed while waiting for md_io buffer\n"); in al_write_transaction()
426 put_ldev(device); in al_write_transaction()
430 err = __al_write_transaction(device, buffer); in al_write_transaction()
432 drbd_md_put_buffer(device); in al_write_transaction()
433 put_ldev(device); in al_write_transaction()
439 void drbd_al_begin_io_commit(struct drbd_device *device) in drbd_al_begin_io_commit() argument
446 wait_event(device->al_wait, in drbd_al_begin_io_commit()
447 device->act_log->pending_changes == 0 || in drbd_al_begin_io_commit()
448 (locked = lc_try_lock_for_transaction(device->act_log))); in drbd_al_begin_io_commit()
453 if (device->act_log->pending_changes) { in drbd_al_begin_io_commit()
457 write_al_updates = rcu_dereference(device->ldev->disk_conf)->al_updates; in drbd_al_begin_io_commit()
461 al_write_transaction(device); in drbd_al_begin_io_commit()
462 spin_lock_irq(&device->al_lock); in drbd_al_begin_io_commit()
467 lc_committed(device->act_log); in drbd_al_begin_io_commit()
468 spin_unlock_irq(&device->al_lock); in drbd_al_begin_io_commit()
470 lc_unlock(device->act_log); in drbd_al_begin_io_commit()
471 wake_up(&device->al_wait); in drbd_al_begin_io_commit()
478 void drbd_al_begin_io(struct drbd_device *device, struct drbd_interval *i) in drbd_al_begin_io() argument
480 if (drbd_al_begin_io_prepare(device, i)) in drbd_al_begin_io()
481 drbd_al_begin_io_commit(device); in drbd_al_begin_io()
484 int drbd_al_begin_io_nonblock(struct drbd_device *device, struct drbd_interval *i) in drbd_al_begin_io_nonblock() argument
486 struct lru_cache *al = device->act_log; in drbd_al_begin_io_nonblock()
495 D_ASSERT(device, first <= last); in drbd_al_begin_io_nonblock()
514 __set_bit(__LC_STARVING, &device->act_log->flags); in drbd_al_begin_io_nonblock()
521 tmp = lc_find(device->resync, enr/AL_EXT_PER_BM_SECT); in drbd_al_begin_io_nonblock()
537 al_ext = lc_get_cumulative(device->act_log, enr); in drbd_al_begin_io_nonblock()
539 drbd_info(device, "LOGIC BUG for enr=%u\n", enr); in drbd_al_begin_io_nonblock()
544 void drbd_al_complete_io(struct drbd_device *device, struct drbd_interval *i) in drbd_al_complete_io() argument
554 D_ASSERT(device, first <= last); in drbd_al_complete_io()
555 spin_lock_irqsave(&device->al_lock, flags); in drbd_al_complete_io()
558 extent = lc_find(device->act_log, enr); in drbd_al_complete_io()
560 drbd_err(device, "al_complete_io() called on inactive extent %u\n", enr); in drbd_al_complete_io()
563 lc_put(device->act_log, extent); in drbd_al_complete_io()
565 spin_unlock_irqrestore(&device->al_lock, flags); in drbd_al_complete_io()
566 wake_up(&device->al_wait); in drbd_al_complete_io()
569 static int _try_lc_del(struct drbd_device *device, struct lc_element *al_ext) in _try_lc_del() argument
573 spin_lock_irq(&device->al_lock); in _try_lc_del()
576 lc_del(device->act_log, al_ext); in _try_lc_del()
577 spin_unlock_irq(&device->al_lock); in _try_lc_del()
584 * @device: DRBD device.
589 * You need to lock device->act_log with lc_try_lock() / lc_unlock()
591 void drbd_al_shrink(struct drbd_device *device) in drbd_al_shrink() argument
596 D_ASSERT(device, test_bit(__LC_LOCKED, &device->act_log->flags)); in drbd_al_shrink()
598 for (i = 0; i < device->act_log->nr_elements; i++) { in drbd_al_shrink()
599 al_ext = lc_element_by_index(device->act_log, i); in drbd_al_shrink()
602 wait_event(device->al_wait, _try_lc_del(device, al_ext)); in drbd_al_shrink()
605 wake_up(&device->al_wait); in drbd_al_shrink()
608 int drbd_al_initialize(struct drbd_device *device, void *buffer) in drbd_al_initialize() argument
611 struct drbd_md *md = &device->ldev->md; in drbd_al_initialize()
615 __al_write_transaction(device, al); in drbd_al_initialize()
617 spin_lock_irq(&device->al_lock); in drbd_al_initialize()
618 lc_committed(device->act_log); in drbd_al_initialize()
619 spin_unlock_irq(&device->al_lock); in drbd_al_initialize()
625 int err = __al_write_transaction(device, al); in drbd_al_initialize()
651 static bool update_rs_extent(struct drbd_device *device, in update_rs_extent() argument
657 D_ASSERT(device, atomic_read(&device->local_cnt)); in update_rs_extent()
667 e = lc_find(device->resync, enr); in update_rs_extent()
669 e = lc_get(device->resync, enr); in update_rs_extent()
680 drbd_warn(device, "BAD! enr=%u rs_left=%d " in update_rs_extent()
684 drbd_conn_str(device->state.conn)); in update_rs_extent()
692 ext->rs_left = drbd_bm_e_weight(device, enr); in update_rs_extent()
701 int rs_left = drbd_bm_e_weight(device, enr); in update_rs_extent()
703 drbd_warn(device, "changing resync lce: %d[%u;%02lx]" in update_rs_extent()
710 drbd_warn(device, "Kicking resync_lru element enr=%u " in update_rs_extent()
718 lc_committed(device->resync); in update_rs_extent()
721 lc_put(device->resync, &ext->lce); in update_rs_extent()
730 drbd_err(device, "lc_get() failed! locked=%d/%d flags=%lu\n", in update_rs_extent()
731 device->resync_locked, in update_rs_extent()
732 device->resync->nr_elements, in update_rs_extent()
733 device->resync->flags); in update_rs_extent()
738 void drbd_advance_rs_marks(struct drbd_device *device, unsigned long still_to_go) in drbd_advance_rs_marks() argument
741 unsigned long last = device->rs_mark_time[device->rs_last_mark]; in drbd_advance_rs_marks()
742 int next = (device->rs_last_mark + 1) % DRBD_SYNC_MARKS; in drbd_advance_rs_marks()
744 if (device->rs_mark_left[device->rs_last_mark] != still_to_go && in drbd_advance_rs_marks()
745 device->state.conn != C_PAUSED_SYNC_T && in drbd_advance_rs_marks()
746 device->state.conn != C_PAUSED_SYNC_S) { in drbd_advance_rs_marks()
747 device->rs_mark_time[next] = now; in drbd_advance_rs_marks()
748 device->rs_mark_left[next] = still_to_go; in drbd_advance_rs_marks()
749 device->rs_last_mark = next; in drbd_advance_rs_marks()
755 static bool lazy_bitmap_update_due(struct drbd_device *device) in lazy_bitmap_update_due() argument
757 return time_after(jiffies, device->rs_last_bcast + 2*HZ); in lazy_bitmap_update_due()
760 static void maybe_schedule_on_disk_bitmap_update(struct drbd_device *device, bool rs_done) in maybe_schedule_on_disk_bitmap_update() argument
763 struct drbd_connection *connection = first_peer_device(device)->connection; in maybe_schedule_on_disk_bitmap_update()
765 is_sync_target_state(device->state.conn)) in maybe_schedule_on_disk_bitmap_update()
766 set_bit(RS_DONE, &device->flags); in maybe_schedule_on_disk_bitmap_update()
773 } else if (!lazy_bitmap_update_due(device)) in maybe_schedule_on_disk_bitmap_update()
776 drbd_device_post_work(device, RS_PROGRESS); in maybe_schedule_on_disk_bitmap_update()
779 static int update_sync_bits(struct drbd_device *device, in update_sync_bits() argument
804 c = drbd_bm_count_bits(device, sbnr, tbnr); in update_sync_bits()
806 c = drbd_bm_clear_bits(device, sbnr, tbnr); in update_sync_bits()
808 c = drbd_bm_set_bits(device, sbnr, tbnr); in update_sync_bits()
811 spin_lock_irqsave(&device->al_lock, flags); in update_sync_bits()
812 cleared += update_rs_extent(device, BM_BIT_TO_EXT(sbnr), c, mode); in update_sync_bits()
813 spin_unlock_irqrestore(&device->al_lock, flags); in update_sync_bits()
820 unsigned long still_to_go = drbd_bm_total_weight(device); in update_sync_bits()
821 bool rs_is_done = (still_to_go <= device->rs_failed); in update_sync_bits()
822 drbd_advance_rs_marks(device, still_to_go); in update_sync_bits()
824 maybe_schedule_on_disk_bitmap_update(device, rs_is_done); in update_sync_bits()
826 device->rs_failed += count; in update_sync_bits()
827 wake_up(&device->al_wait); in update_sync_bits()
846 int __drbd_change_sync(struct drbd_device *device, sector_t sector, int size, in __drbd_change_sync() argument
859 drbd_err(device, "%s: sector=%llus size=%d nonsense!\n", in __drbd_change_sync()
865 if (!get_ldev(device)) in __drbd_change_sync()
868 nr_sectors = get_capacity(device->vdisk); in __drbd_change_sync()
895 count = update_sync_bits(device, sbnr, ebnr, mode); in __drbd_change_sync()
897 put_ldev(device); in __drbd_change_sync()
902 struct bm_extent *_bme_get(struct drbd_device *device, unsigned int enr) in _bme_get() argument
909 spin_lock_irq(&device->al_lock); in _bme_get()
910 if (device->resync_locked > device->resync->nr_elements/2) { in _bme_get()
911 spin_unlock_irq(&device->al_lock); in _bme_get()
914 e = lc_get(device->resync, enr); in _bme_get()
918 bm_ext->rs_left = drbd_bm_e_weight(device, enr); in _bme_get()
920 lc_committed(device->resync); in _bme_get()
924 device->resync_locked++; in _bme_get()
927 rs_flags = device->resync->flags; in _bme_get()
928 spin_unlock_irq(&device->al_lock); in _bme_get()
930 wake_up(&device->al_wait); in _bme_get()
934 drbd_warn(device, "Have to wait for element" in _bme_get()
942 static int _is_in_al(struct drbd_device *device, unsigned int enr) in _is_in_al() argument
946 spin_lock_irq(&device->al_lock); in _is_in_al()
947 rv = lc_is_used(device->act_log, enr); in _is_in_al()
948 spin_unlock_irq(&device->al_lock); in _is_in_al()
955 * @device: DRBD device.
960 int drbd_rs_begin_io(struct drbd_device *device, sector_t sector) in drbd_rs_begin_io() argument
968 sig = wait_event_interruptible(device->al_wait, in drbd_rs_begin_io()
969 (bm_ext = _bme_get(device, enr))); in drbd_rs_begin_io()
977 sa = drbd_rs_c_min_rate_throttle(device); in drbd_rs_begin_io()
980 sig = wait_event_interruptible(device->al_wait, in drbd_rs_begin_io()
981 !_is_in_al(device, enr * AL_EXT_PER_BM_SECT + i) || in drbd_rs_begin_io()
985 spin_lock_irq(&device->al_lock); in drbd_rs_begin_io()
986 if (lc_put(device->resync, &bm_ext->lce) == 0) { in drbd_rs_begin_io()
988 device->resync_locked--; in drbd_rs_begin_io()
989 wake_up(&device->al_wait); in drbd_rs_begin_io()
991 spin_unlock_irq(&device->al_lock); in drbd_rs_begin_io()
1005 * @device: DRBD device.
1012 int drbd_try_rs_begin_io(struct drbd_device *device, sector_t sector) in drbd_try_rs_begin_io() argument
1019 bool throttle = drbd_rs_should_slow_down(device, sector, true); in drbd_try_rs_begin_io()
1026 if (throttle && device->resync_wenr != enr) in drbd_try_rs_begin_io()
1029 spin_lock_irq(&device->al_lock); in drbd_try_rs_begin_io()
1030 if (device->resync_wenr != LC_FREE && device->resync_wenr != enr) { in drbd_try_rs_begin_io()
1044 e = lc_find(device->resync, device->resync_wenr); in drbd_try_rs_begin_io()
1047 D_ASSERT(device, !test_bit(BME_LOCKED, &bm_ext->flags)); in drbd_try_rs_begin_io()
1048 D_ASSERT(device, test_bit(BME_NO_WRITES, &bm_ext->flags)); in drbd_try_rs_begin_io()
1050 device->resync_wenr = LC_FREE; in drbd_try_rs_begin_io()
1051 if (lc_put(device->resync, &bm_ext->lce) == 0) { in drbd_try_rs_begin_io()
1053 device->resync_locked--; in drbd_try_rs_begin_io()
1055 wake_up(&device->al_wait); in drbd_try_rs_begin_io()
1057 drbd_alert(device, "LOGIC BUG\n"); in drbd_try_rs_begin_io()
1061 e = lc_try_get(device->resync, enr); in drbd_try_rs_begin_io()
1067 device->resync_locked++; in drbd_try_rs_begin_io()
1074 D_ASSERT(device, bm_ext->lce.refcnt > 0); in drbd_try_rs_begin_io()
1079 if (device->resync_locked > device->resync->nr_elements-3) in drbd_try_rs_begin_io()
1082 e = lc_get(device->resync, enr); in drbd_try_rs_begin_io()
1085 const unsigned long rs_flags = device->resync->flags; in drbd_try_rs_begin_io()
1087 drbd_warn(device, "Have to wait for element" in drbd_try_rs_begin_io()
1093 bm_ext->rs_left = drbd_bm_e_weight(device, enr); in drbd_try_rs_begin_io()
1095 lc_committed(device->resync); in drbd_try_rs_begin_io()
1096 wake_up(&device->al_wait); in drbd_try_rs_begin_io()
1097 D_ASSERT(device, test_bit(BME_LOCKED, &bm_ext->flags) == 0); in drbd_try_rs_begin_io()
1100 D_ASSERT(device, bm_ext->lce.refcnt == 1); in drbd_try_rs_begin_io()
1101 device->resync_locked++; in drbd_try_rs_begin_io()
1106 if (lc_is_used(device->act_log, al_enr+i)) in drbd_try_rs_begin_io()
1111 device->resync_wenr = LC_FREE; in drbd_try_rs_begin_io()
1112 spin_unlock_irq(&device->al_lock); in drbd_try_rs_begin_io()
1118 D_ASSERT(device, !test_bit(BME_LOCKED, &bm_ext->flags)); in drbd_try_rs_begin_io()
1119 D_ASSERT(device, test_bit(BME_NO_WRITES, &bm_ext->flags)); in drbd_try_rs_begin_io()
1121 device->resync_wenr = LC_FREE; in drbd_try_rs_begin_io()
1122 if (lc_put(device->resync, &bm_ext->lce) == 0) { in drbd_try_rs_begin_io()
1124 device->resync_locked--; in drbd_try_rs_begin_io()
1126 wake_up(&device->al_wait); in drbd_try_rs_begin_io()
1128 device->resync_wenr = enr; in drbd_try_rs_begin_io()
1130 spin_unlock_irq(&device->al_lock); in drbd_try_rs_begin_io()
1134 void drbd_rs_complete_io(struct drbd_device *device, sector_t sector) in drbd_rs_complete_io() argument
1141 spin_lock_irqsave(&device->al_lock, flags); in drbd_rs_complete_io()
1142 e = lc_find(device->resync, enr); in drbd_rs_complete_io()
1145 spin_unlock_irqrestore(&device->al_lock, flags); in drbd_rs_complete_io()
1147 drbd_err(device, "drbd_rs_complete_io() called, but extent not found\n"); in drbd_rs_complete_io()
1152 spin_unlock_irqrestore(&device->al_lock, flags); in drbd_rs_complete_io()
1153 drbd_err(device, "drbd_rs_complete_io(,%llu [=%u]) called, " in drbd_rs_complete_io()
1159 if (lc_put(device->resync, &bm_ext->lce) == 0) { in drbd_rs_complete_io()
1161 device->resync_locked--; in drbd_rs_complete_io()
1162 wake_up(&device->al_wait); in drbd_rs_complete_io()
1165 spin_unlock_irqrestore(&device->al_lock, flags); in drbd_rs_complete_io()
1170 * @device: DRBD device.
1172 void drbd_rs_cancel_all(struct drbd_device *device) in drbd_rs_cancel_all() argument
1174 spin_lock_irq(&device->al_lock); in drbd_rs_cancel_all()
1176 if (get_ldev_if_state(device, D_FAILED)) { /* Makes sure ->resync is there. */ in drbd_rs_cancel_all()
1177 lc_reset(device->resync); in drbd_rs_cancel_all()
1178 put_ldev(device); in drbd_rs_cancel_all()
1180 device->resync_locked = 0; in drbd_rs_cancel_all()
1181 device->resync_wenr = LC_FREE; in drbd_rs_cancel_all()
1182 spin_unlock_irq(&device->al_lock); in drbd_rs_cancel_all()
1183 wake_up(&device->al_wait); in drbd_rs_cancel_all()
1188 * @device: DRBD device.
1193 int drbd_rs_del_all(struct drbd_device *device) in drbd_rs_del_all() argument
1199 spin_lock_irq(&device->al_lock); in drbd_rs_del_all()
1201 if (get_ldev_if_state(device, D_FAILED)) { in drbd_rs_del_all()
1203 for (i = 0; i < device->resync->nr_elements; i++) { in drbd_rs_del_all()
1204 e = lc_element_by_index(device->resync, i); in drbd_rs_del_all()
1208 if (bm_ext->lce.lc_number == device->resync_wenr) { in drbd_rs_del_all()
1209 drbd_info(device, "dropping %u in drbd_rs_del_all, apparently" in drbd_rs_del_all()
1211 device->resync_wenr); in drbd_rs_del_all()
1212 D_ASSERT(device, !test_bit(BME_LOCKED, &bm_ext->flags)); in drbd_rs_del_all()
1213 D_ASSERT(device, test_bit(BME_NO_WRITES, &bm_ext->flags)); in drbd_rs_del_all()
1215 device->resync_wenr = LC_FREE; in drbd_rs_del_all()
1216 lc_put(device->resync, &bm_ext->lce); in drbd_rs_del_all()
1219 drbd_info(device, "Retrying drbd_rs_del_all() later. " in drbd_rs_del_all()
1221 put_ldev(device); in drbd_rs_del_all()
1222 spin_unlock_irq(&device->al_lock); in drbd_rs_del_all()
1225 D_ASSERT(device, !test_bit(BME_LOCKED, &bm_ext->flags)); in drbd_rs_del_all()
1226 D_ASSERT(device, !test_bit(BME_NO_WRITES, &bm_ext->flags)); in drbd_rs_del_all()
1227 lc_del(device->resync, &bm_ext->lce); in drbd_rs_del_all()
1229 D_ASSERT(device, device->resync->used == 0); in drbd_rs_del_all()
1230 put_ldev(device); in drbd_rs_del_all()
1232 spin_unlock_irq(&device->al_lock); in drbd_rs_del_all()
1233 wake_up(&device->al_wait); in drbd_rs_del_all()