Lines Matching refs:resv

40 					   struct ocfs2_alloc_reservation *resv)  in ocfs2_resv_window_bits()  argument
45 if (!(resv->r_flags & OCFS2_RESV_FLAG_DIR)) { in ocfs2_resv_window_bits()
54 static inline unsigned int ocfs2_resv_end(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_end() argument
56 if (resv->r_len) in ocfs2_resv_end()
57 return resv->r_start + resv->r_len - 1; in ocfs2_resv_end()
58 return resv->r_start; in ocfs2_resv_end()
61 static inline int ocfs2_resv_empty(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_empty() argument
63 return !!(resv->r_len == 0); in ocfs2_resv_empty()
77 struct ocfs2_alloc_reservation *resv; in ocfs2_dump_resv() local
85 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_dump_resv()
88 "\tlast_len: %u\n", resv->r_start, in ocfs2_dump_resv()
89 ocfs2_resv_end(resv), resv->r_len, resv->r_last_start, in ocfs2_dump_resv()
90 resv->r_last_len); in ocfs2_dump_resv()
99 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
101 "last_start: %u\tlast_len: %u\n", i, resv->r_start, in ocfs2_dump_resv()
102 ocfs2_resv_end(resv), resv->r_len, resv->r_last_start, in ocfs2_dump_resv()
103 resv->r_last_len); in ocfs2_dump_resv()
112 struct ocfs2_alloc_reservation *resv) in ocfs2_validate_resmap_bits() argument
115 unsigned int start = resv->r_start; in ocfs2_validate_resmap_bits()
116 unsigned int end = ocfs2_resv_end(resv); in ocfs2_validate_resmap_bits()
136 struct ocfs2_alloc_reservation *resv; in ocfs2_check_resmap() local
140 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_check_resmap()
142 if (i > 0 && resv->r_start <= off) { in ocfs2_check_resmap()
148 if (resv->r_len == 0) { in ocfs2_check_resmap()
154 if (resv->r_start > ocfs2_resv_end(resv)) { in ocfs2_check_resmap()
160 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
166 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
169 off = ocfs2_resv_end(resv); in ocfs2_check_resmap()
187 void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_init_once() argument
189 memset(resv, 0, sizeof(*resv)); in ocfs2_resv_init_once()
190 INIT_LIST_HEAD(&resv->r_lru); in ocfs2_resv_init_once()
193 void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv, in ocfs2_resv_set_type() argument
198 resv->r_flags |= flags; in ocfs2_resv_set_type()
213 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_mark_lru() argument
217 if (!list_empty(&resv->r_lru)) in ocfs2_resv_mark_lru()
218 list_del_init(&resv->r_lru); in ocfs2_resv_mark_lru()
220 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
223 static void __ocfs2_resv_trunc(struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_trunc() argument
225 resv->r_len = 0; in __ocfs2_resv_trunc()
226 resv->r_start = 0; in __ocfs2_resv_trunc()
230 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_remove() argument
232 if (resv->r_flags & OCFS2_RESV_FLAG_INUSE) { in ocfs2_resv_remove()
233 list_del_init(&resv->r_lru); in ocfs2_resv_remove()
234 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
235 resv->r_flags &= ~OCFS2_RESV_FLAG_INUSE; in ocfs2_resv_remove()
240 struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_discard() argument
244 __ocfs2_resv_trunc(resv); in __ocfs2_resv_discard()
249 resv->r_last_len = resv->r_last_start = 0; in __ocfs2_resv_discard()
251 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
256 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_discard() argument
258 if (resv) { in ocfs2_resv_discard()
260 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
268 struct ocfs2_alloc_reservation *resv; in ocfs2_resmap_clear_all_resv() local
273 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_resmap_clear_all_resv()
275 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
354 struct ocfs2_alloc_reservation *resv = NULL; in ocfs2_find_resv_lhs() local
365 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_find_resv_lhs()
367 if (resv->r_start <= goal && ocfs2_resv_end(resv) >= goal) in ocfs2_find_resv_lhs()
371 if (resv->r_start > goal) { in ocfs2_find_resv_lhs()
372 resv = prev_resv; in ocfs2_find_resv_lhs()
376 prev_resv = resv; in ocfs2_find_resv_lhs()
380 return resv; in ocfs2_find_resv_lhs()
456 struct ocfs2_alloc_reservation *resv, in __ocfs2_resv_find_window() argument
474 trace_ocfs2_resv_find_window_begin(resv->r_start, ocfs2_resv_end(resv), in __ocfs2_resv_find_window()
497 resv->r_start = cstart; in __ocfs2_resv_find_window()
498 resv->r_len = clen; in __ocfs2_resv_find_window()
500 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
609 resv->r_start = best_start; in __ocfs2_resv_find_window()
610 resv->r_len = best_len; in __ocfs2_resv_find_window()
611 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
616 struct ocfs2_alloc_reservation *resv, in ocfs2_cannibalize_resv() argument
620 int tmpwindow = !!(resv->r_flags & OCFS2_RESV_FLAG_TMP); in ocfs2_cannibalize_resv()
624 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
652 resv->r_start = lru_resv->r_start; in ocfs2_cannibalize_resv()
653 resv->r_len = lru_resv->r_len; in ocfs2_cannibalize_resv()
665 resv->r_start = ocfs2_resv_end(lru_resv) + 1; in ocfs2_cannibalize_resv()
666 resv->r_len = shrink; in ocfs2_cannibalize_resv()
669 trace_ocfs2_cannibalize_resv_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_cannibalize_resv()
670 resv->r_len, resv->r_last_start, in ocfs2_cannibalize_resv()
671 resv->r_last_len); in ocfs2_cannibalize_resv()
673 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
677 struct ocfs2_alloc_reservation *resv, in ocfs2_resv_find_window() argument
682 BUG_ON(!ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
689 if (resv->r_last_len) { in ocfs2_resv_find_window()
690 goal = resv->r_last_start + resv->r_last_len; in ocfs2_resv_find_window()
695 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
698 if (ocfs2_resv_empty(resv) && goal != 0) in ocfs2_resv_find_window()
699 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
701 if (ocfs2_resv_empty(resv)) { in ocfs2_resv_find_window()
706 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
709 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
713 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_resv_bits() argument
716 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
721 if (ocfs2_resv_empty(resv)) { in ocfs2_resmap_resv_bits()
727 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
729 if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen) in ocfs2_resmap_resv_bits()
739 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
740 trace_ocfs2_resmap_resv_bits(resv->r_start, resv->r_len); in ocfs2_resmap_resv_bits()
743 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resmap_resv_bits()
745 *cstart = resv->r_start; in ocfs2_resmap_resv_bits()
746 *clen = resv->r_len; in ocfs2_resmap_resv_bits()
754 struct ocfs2_alloc_reservation *resv, in ocfs2_adjust_resv_from_alloc() argument
758 unsigned int old_end = ocfs2_resv_end(resv); in ocfs2_adjust_resv_from_alloc()
760 BUG_ON(start != resv->r_start || old_end < end); in ocfs2_adjust_resv_from_alloc()
766 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
777 resv->r_start = end + 1; in ocfs2_adjust_resv_from_alloc()
778 resv->r_len = old_end - resv->r_start + 1; in ocfs2_adjust_resv_from_alloc()
782 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_claimed_bits() argument
790 if (resv == NULL) in ocfs2_resmap_claimed_bits()
793 BUG_ON(cstart != resv->r_start); in ocfs2_resmap_claimed_bits()
797 trace_ocfs2_resmap_claimed_bits_begin(cstart, cend, clen, resv->r_start, in ocfs2_resmap_claimed_bits()
798 ocfs2_resv_end(resv), resv->r_len, in ocfs2_resmap_claimed_bits()
799 resv->r_last_start, in ocfs2_resmap_claimed_bits()
800 resv->r_last_len); in ocfs2_resmap_claimed_bits()
802 BUG_ON(cstart < resv->r_start); in ocfs2_resmap_claimed_bits()
803 BUG_ON(cstart > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
804 BUG_ON(cend > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
806 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
807 resv->r_last_start = cstart; in ocfs2_resmap_claimed_bits()
808 resv->r_last_len = clen; in ocfs2_resmap_claimed_bits()
814 if (!ocfs2_resv_empty(resv)) in ocfs2_resmap_claimed_bits()
815 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
817 trace_ocfs2_resmap_claimed_bits_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_resmap_claimed_bits()
818 resv->r_len, resv->r_last_start, in ocfs2_resmap_claimed_bits()
819 resv->r_last_len); in ocfs2_resmap_claimed_bits()