Lines Matching refs:lr

161 	zfs_locked_range_t *lr;  in zfs_rangelock_enter_writer()  local
194 lr = avl_find(tree, new, &where); in zfs_rangelock_enter_writer()
195 if (lr != NULL) in zfs_rangelock_enter_writer()
198 lr = avl_nearest(tree, where, AVL_AFTER); in zfs_rangelock_enter_writer()
199 if (lr != NULL && in zfs_rangelock_enter_writer()
200 lr->lr_offset < new->lr_offset + new->lr_length) in zfs_rangelock_enter_writer()
203 lr = avl_nearest(tree, where, AVL_BEFORE); in zfs_rangelock_enter_writer()
204 if (lr != NULL && in zfs_rangelock_enter_writer()
205 lr->lr_offset + lr->lr_length > new->lr_offset) in zfs_rangelock_enter_writer()
213 if (!lr->lr_write_wanted) { in zfs_rangelock_enter_writer()
214 cv_init(&lr->lr_write_cv, NULL, CV_DEFAULT, NULL); in zfs_rangelock_enter_writer()
215 lr->lr_write_wanted = B_TRUE; in zfs_rangelock_enter_writer()
217 cv_wait(&lr->lr_write_cv, &rl->rl_lock); in zfs_rangelock_enter_writer()
231 zfs_rangelock_proxify(avl_tree_t *tree, zfs_locked_range_t *lr) in zfs_rangelock_proxify() argument
235 if (lr->lr_proxy) in zfs_rangelock_proxify()
236 return (lr); /* already a proxy */ in zfs_rangelock_proxify()
238 ASSERT3U(lr->lr_count, ==, 1); in zfs_rangelock_proxify()
239 ASSERT(lr->lr_write_wanted == B_FALSE); in zfs_rangelock_proxify()
240 ASSERT(lr->lr_read_wanted == B_FALSE); in zfs_rangelock_proxify()
241 avl_remove(tree, lr); in zfs_rangelock_proxify()
242 lr->lr_count = 0; in zfs_rangelock_proxify()
246 proxy->lr_offset = lr->lr_offset; in zfs_rangelock_proxify()
247 proxy->lr_length = lr->lr_length; in zfs_rangelock_proxify()
263 zfs_rangelock_split(avl_tree_t *tree, zfs_locked_range_t *lr, uint64_t off) in zfs_rangelock_split() argument
267 ASSERT3U(lr->lr_length, >, 1); in zfs_rangelock_split()
268 ASSERT3U(off, >, lr->lr_offset); in zfs_rangelock_split()
269 ASSERT3U(off, <, lr->lr_offset + lr->lr_length); in zfs_rangelock_split()
270 ASSERT(lr->lr_write_wanted == B_FALSE); in zfs_rangelock_split()
271 ASSERT(lr->lr_read_wanted == B_FALSE); in zfs_rangelock_split()
276 rear->lr_length = lr->lr_offset + lr->lr_length - off; in zfs_rangelock_split()
277 rear->lr_count = lr->lr_count; in zfs_rangelock_split()
283 zfs_locked_range_t *front = zfs_rangelock_proxify(tree, lr); in zfs_rangelock_split()
284 front->lr_length = off - lr->lr_offset; in zfs_rangelock_split()
296 zfs_locked_range_t *lr; in zfs_rangelock_new_proxy() local
299 lr = kmem_alloc(sizeof (zfs_locked_range_t), KM_SLEEP); in zfs_rangelock_new_proxy()
300 lr->lr_offset = off; in zfs_rangelock_new_proxy()
301 lr->lr_length = len; in zfs_rangelock_new_proxy()
302 lr->lr_count = 1; in zfs_rangelock_new_proxy()
303 lr->lr_type = RL_READER; in zfs_rangelock_new_proxy()
304 lr->lr_proxy = B_TRUE; in zfs_rangelock_new_proxy()
305 lr->lr_write_wanted = B_FALSE; in zfs_rangelock_new_proxy()
306 lr->lr_read_wanted = B_FALSE; in zfs_rangelock_new_proxy()
307 avl_add(tree, lr); in zfs_rangelock_new_proxy()
538 zfs_rangelock_free(zfs_locked_range_t *lr) in zfs_rangelock_free() argument
540 if (lr->lr_write_wanted) in zfs_rangelock_free()
541 cv_destroy(&lr->lr_write_cv); in zfs_rangelock_free()
543 if (lr->lr_read_wanted) in zfs_rangelock_free()
544 cv_destroy(&lr->lr_read_cv); in zfs_rangelock_free()
546 kmem_free(lr, sizeof (zfs_locked_range_t)); in zfs_rangelock_free()
582 zfs_locked_range_t *lr = avl_find(tree, remove, NULL); in zfs_rangelock_exit_reader() local
583 ASSERT3P(lr, !=, NULL); in zfs_rangelock_exit_reader()
584 ASSERT3U(lr->lr_count, !=, 0); in zfs_rangelock_exit_reader()
585 ASSERT3U(lr->lr_type, ==, RL_READER); in zfs_rangelock_exit_reader()
587 for (len = remove->lr_length; len != 0; lr = next) { in zfs_rangelock_exit_reader()
588 len -= lr->lr_length; in zfs_rangelock_exit_reader()
590 next = AVL_NEXT(tree, lr); in zfs_rangelock_exit_reader()
592 ASSERT3U(lr->lr_offset + lr->lr_length, ==, in zfs_rangelock_exit_reader()
597 lr->lr_count--; in zfs_rangelock_exit_reader()
598 if (lr->lr_count == 0) { in zfs_rangelock_exit_reader()
599 avl_remove(tree, lr); in zfs_rangelock_exit_reader()
600 if (lr->lr_write_wanted) in zfs_rangelock_exit_reader()
601 cv_broadcast(&lr->lr_write_cv); in zfs_rangelock_exit_reader()
602 if (lr->lr_read_wanted) in zfs_rangelock_exit_reader()
603 cv_broadcast(&lr->lr_read_cv); in zfs_rangelock_exit_reader()
604 list_insert_tail(free_list, lr); in zfs_rangelock_exit_reader()
615 zfs_rangelock_exit(zfs_locked_range_t *lr) in zfs_rangelock_exit() argument
617 zfs_rangelock_t *rl = lr->lr_rangelock; in zfs_rangelock_exit()
621 ASSERT(lr->lr_type == RL_WRITER || lr->lr_type == RL_READER); in zfs_rangelock_exit()
622 ASSERT(lr->lr_count == 1 || lr->lr_count == 0); in zfs_rangelock_exit()
623 ASSERT(!lr->lr_proxy); in zfs_rangelock_exit()
633 if (lr->lr_type == RL_WRITER) { in zfs_rangelock_exit()
635 avl_remove(&rl->rl_tree, lr); in zfs_rangelock_exit()
636 if (lr->lr_write_wanted) in zfs_rangelock_exit()
637 cv_broadcast(&lr->lr_write_cv); in zfs_rangelock_exit()
638 if (lr->lr_read_wanted) in zfs_rangelock_exit()
639 cv_broadcast(&lr->lr_read_cv); in zfs_rangelock_exit()
640 list_insert_tail(&free_list, lr); in zfs_rangelock_exit()
646 zfs_rangelock_exit_reader(rl, lr, &free_list); in zfs_rangelock_exit()
662 zfs_rangelock_reduce(zfs_locked_range_t *lr, uint64_t off, uint64_t len) in zfs_rangelock_reduce() argument
664 zfs_rangelock_t *rl = lr->lr_rangelock; in zfs_rangelock_reduce()
668 ASSERT3U(lr->lr_offset, ==, 0); in zfs_rangelock_reduce()
669 ASSERT3U(lr->lr_type, ==, RL_WRITER); in zfs_rangelock_reduce()
670 ASSERT(!lr->lr_proxy); in zfs_rangelock_reduce()
671 ASSERT3U(lr->lr_length, ==, UINT64_MAX); in zfs_rangelock_reduce()
672 ASSERT3U(lr->lr_count, ==, 1); in zfs_rangelock_reduce()
675 lr->lr_offset = off; in zfs_rangelock_reduce()
676 lr->lr_length = len; in zfs_rangelock_reduce()
678 if (lr->lr_write_wanted) in zfs_rangelock_reduce()
679 cv_broadcast(&lr->lr_write_cv); in zfs_rangelock_reduce()
680 if (lr->lr_read_wanted) in zfs_rangelock_reduce()
681 cv_broadcast(&lr->lr_read_cv); in zfs_rangelock_reduce()