Lines Matching refs:resv
42 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_window_bits() argument
47 if (!(resv->r_flags & OCFS2_RESV_FLAG_DIR)) { in ocfs2_resv_window_bits()
56 static inline unsigned int ocfs2_resv_end(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_end() argument
58 if (resv->r_len) in ocfs2_resv_end()
59 return resv->r_start + resv->r_len - 1; in ocfs2_resv_end()
60 return resv->r_start; in ocfs2_resv_end()
63 static inline int ocfs2_resv_empty(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_empty() argument
65 return !!(resv->r_len == 0); in ocfs2_resv_empty()
79 struct ocfs2_alloc_reservation *resv; in ocfs2_dump_resv() local
87 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_dump_resv()
90 "\tlast_len: %u\n", resv->r_start, in ocfs2_dump_resv()
91 ocfs2_resv_end(resv), resv->r_len, resv->r_last_start, in ocfs2_dump_resv()
92 resv->r_last_len); in ocfs2_dump_resv()
101 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
103 "last_start: %u\tlast_len: %u\n", i, resv->r_start, in ocfs2_dump_resv()
104 ocfs2_resv_end(resv), resv->r_len, resv->r_last_start, in ocfs2_dump_resv()
105 resv->r_last_len); in ocfs2_dump_resv()
114 struct ocfs2_alloc_reservation *resv) in ocfs2_validate_resmap_bits() argument
117 unsigned int start = resv->r_start; in ocfs2_validate_resmap_bits()
118 unsigned int end = ocfs2_resv_end(resv); in ocfs2_validate_resmap_bits()
138 struct ocfs2_alloc_reservation *resv; in ocfs2_check_resmap() local
142 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_check_resmap()
144 if (i > 0 && resv->r_start <= off) { in ocfs2_check_resmap()
150 if (resv->r_len == 0) { in ocfs2_check_resmap()
156 if (resv->r_start > ocfs2_resv_end(resv)) { in ocfs2_check_resmap()
162 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
168 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
171 off = ocfs2_resv_end(resv); in ocfs2_check_resmap()
189 void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_init_once() argument
191 memset(resv, 0, sizeof(*resv)); in ocfs2_resv_init_once()
192 INIT_LIST_HEAD(&resv->r_lru); in ocfs2_resv_init_once()
195 void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv, in ocfs2_resv_set_type() argument
200 resv->r_flags |= flags; in ocfs2_resv_set_type()
217 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_mark_lru() argument
221 if (!list_empty(&resv->r_lru)) in ocfs2_resv_mark_lru()
222 list_del_init(&resv->r_lru); in ocfs2_resv_mark_lru()
224 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
227 static void __ocfs2_resv_trunc(struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_trunc() argument
229 resv->r_len = 0; in __ocfs2_resv_trunc()
230 resv->r_start = 0; in __ocfs2_resv_trunc()
234 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_remove() argument
236 if (resv->r_flags & OCFS2_RESV_FLAG_INUSE) { in ocfs2_resv_remove()
237 list_del_init(&resv->r_lru); in ocfs2_resv_remove()
238 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
239 resv->r_flags &= ~OCFS2_RESV_FLAG_INUSE; in ocfs2_resv_remove()
244 struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_discard() argument
248 __ocfs2_resv_trunc(resv); in __ocfs2_resv_discard()
253 resv->r_last_len = resv->r_last_start = 0; in __ocfs2_resv_discard()
255 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
260 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_discard() argument
262 if (resv) { in ocfs2_resv_discard()
264 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
272 struct ocfs2_alloc_reservation *resv; in ocfs2_resmap_clear_all_resv() local
277 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_resmap_clear_all_resv()
279 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
358 struct ocfs2_alloc_reservation *resv = NULL; in ocfs2_find_resv_lhs() local
369 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_find_resv_lhs()
371 if (resv->r_start <= goal && ocfs2_resv_end(resv) >= goal) in ocfs2_find_resv_lhs()
375 if (resv->r_start > goal) { in ocfs2_find_resv_lhs()
376 resv = prev_resv; in ocfs2_find_resv_lhs()
380 prev_resv = resv; in ocfs2_find_resv_lhs()
384 return resv; in ocfs2_find_resv_lhs()
460 struct ocfs2_alloc_reservation *resv, in __ocfs2_resv_find_window() argument
478 trace_ocfs2_resv_find_window_begin(resv->r_start, ocfs2_resv_end(resv), in __ocfs2_resv_find_window()
501 resv->r_start = cstart; in __ocfs2_resv_find_window()
502 resv->r_len = clen; in __ocfs2_resv_find_window()
504 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
613 resv->r_start = best_start; in __ocfs2_resv_find_window()
614 resv->r_len = best_len; in __ocfs2_resv_find_window()
615 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
620 struct ocfs2_alloc_reservation *resv, in ocfs2_cannibalize_resv() argument
624 int tmpwindow = !!(resv->r_flags & OCFS2_RESV_FLAG_TMP); in ocfs2_cannibalize_resv()
628 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
656 resv->r_start = lru_resv->r_start; in ocfs2_cannibalize_resv()
657 resv->r_len = lru_resv->r_len; in ocfs2_cannibalize_resv()
669 resv->r_start = ocfs2_resv_end(lru_resv) + 1; in ocfs2_cannibalize_resv()
670 resv->r_len = shrink; in ocfs2_cannibalize_resv()
673 trace_ocfs2_cannibalize_resv_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_cannibalize_resv()
674 resv->r_len, resv->r_last_start, in ocfs2_cannibalize_resv()
675 resv->r_last_len); in ocfs2_cannibalize_resv()
677 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
681 struct ocfs2_alloc_reservation *resv, in ocfs2_resv_find_window() argument
686 BUG_ON(!ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
693 if (resv->r_last_len) { in ocfs2_resv_find_window()
694 goal = resv->r_last_start + resv->r_last_len; in ocfs2_resv_find_window()
699 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
702 if (ocfs2_resv_empty(resv) && goal != 0) in ocfs2_resv_find_window()
703 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
705 if (ocfs2_resv_empty(resv)) { in ocfs2_resv_find_window()
710 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
713 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
717 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_resv_bits() argument
720 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
725 if (ocfs2_resv_empty(resv)) { in ocfs2_resmap_resv_bits()
731 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
733 if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen) in ocfs2_resmap_resv_bits()
743 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
744 trace_ocfs2_resmap_resv_bits(resv->r_start, resv->r_len); in ocfs2_resmap_resv_bits()
747 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resmap_resv_bits()
749 *cstart = resv->r_start; in ocfs2_resmap_resv_bits()
750 *clen = resv->r_len; in ocfs2_resmap_resv_bits()
758 struct ocfs2_alloc_reservation *resv, in ocfs2_adjust_resv_from_alloc() argument
762 unsigned int old_end = ocfs2_resv_end(resv); in ocfs2_adjust_resv_from_alloc()
764 BUG_ON(start != resv->r_start || old_end < end); in ocfs2_adjust_resv_from_alloc()
770 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
781 resv->r_start = end + 1; in ocfs2_adjust_resv_from_alloc()
782 resv->r_len = old_end - resv->r_start + 1; in ocfs2_adjust_resv_from_alloc()
786 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_claimed_bits() argument
794 if (resv == NULL) in ocfs2_resmap_claimed_bits()
797 BUG_ON(cstart != resv->r_start); in ocfs2_resmap_claimed_bits()
801 trace_ocfs2_resmap_claimed_bits_begin(cstart, cend, clen, resv->r_start, in ocfs2_resmap_claimed_bits()
802 ocfs2_resv_end(resv), resv->r_len, in ocfs2_resmap_claimed_bits()
803 resv->r_last_start, in ocfs2_resmap_claimed_bits()
804 resv->r_last_len); in ocfs2_resmap_claimed_bits()
806 BUG_ON(cstart < resv->r_start); in ocfs2_resmap_claimed_bits()
807 BUG_ON(cstart > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
808 BUG_ON(cend > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
810 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
811 resv->r_last_start = cstart; in ocfs2_resmap_claimed_bits()
812 resv->r_last_len = clen; in ocfs2_resmap_claimed_bits()
818 if (!ocfs2_resv_empty(resv)) in ocfs2_resmap_claimed_bits()
819 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
821 trace_ocfs2_resmap_claimed_bits_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_resmap_claimed_bits()
822 resv->r_len, resv->r_last_start, in ocfs2_resmap_claimed_bits()
823 resv->r_last_len); in ocfs2_resmap_claimed_bits()