Lines Matching refs:resv
53 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_window_bits() argument
58 if (!(resv->r_flags & OCFS2_RESV_FLAG_DIR)) { in ocfs2_resv_window_bits()
67 static inline unsigned int ocfs2_resv_end(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_end() argument
69 if (resv->r_len) in ocfs2_resv_end()
70 return resv->r_start + resv->r_len - 1; in ocfs2_resv_end()
71 return resv->r_start; in ocfs2_resv_end()
74 static inline int ocfs2_resv_empty(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_empty() argument
76 return !!(resv->r_len == 0); in ocfs2_resv_empty()
90 struct ocfs2_alloc_reservation *resv; in ocfs2_dump_resv() local
98 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_dump_resv()
101 "\tlast_len: %u\n", 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 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
114 "last_start: %u\tlast_len: %u\n", i, resv->r_start, in ocfs2_dump_resv()
115 ocfs2_resv_end(resv), resv->r_len, resv->r_last_start, in ocfs2_dump_resv()
116 resv->r_last_len); in ocfs2_dump_resv()
125 struct ocfs2_alloc_reservation *resv) in ocfs2_validate_resmap_bits() argument
128 unsigned int start = resv->r_start; in ocfs2_validate_resmap_bits()
129 unsigned int end = ocfs2_resv_end(resv); in ocfs2_validate_resmap_bits()
149 struct ocfs2_alloc_reservation *resv; in ocfs2_check_resmap() local
153 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_check_resmap()
155 if (i > 0 && resv->r_start <= off) { in ocfs2_check_resmap()
161 if (resv->r_len == 0) { in ocfs2_check_resmap()
167 if (resv->r_start > ocfs2_resv_end(resv)) { in ocfs2_check_resmap()
173 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
179 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
182 off = ocfs2_resv_end(resv); in ocfs2_check_resmap()
200 void ocfs2_resv_init_once(struct ocfs2_alloc_reservation *resv) in ocfs2_resv_init_once() argument
202 memset(resv, 0, sizeof(*resv)); in ocfs2_resv_init_once()
203 INIT_LIST_HEAD(&resv->r_lru); in ocfs2_resv_init_once()
206 void ocfs2_resv_set_type(struct ocfs2_alloc_reservation *resv, in ocfs2_resv_set_type() argument
211 resv->r_flags |= flags; in ocfs2_resv_set_type()
228 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_mark_lru() argument
232 if (!list_empty(&resv->r_lru)) in ocfs2_resv_mark_lru()
233 list_del_init(&resv->r_lru); in ocfs2_resv_mark_lru()
235 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
238 static void __ocfs2_resv_trunc(struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_trunc() argument
240 resv->r_len = 0; in __ocfs2_resv_trunc()
241 resv->r_start = 0; in __ocfs2_resv_trunc()
245 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_remove() argument
247 if (resv->r_flags & OCFS2_RESV_FLAG_INUSE) { in ocfs2_resv_remove()
248 list_del_init(&resv->r_lru); in ocfs2_resv_remove()
249 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
250 resv->r_flags &= ~OCFS2_RESV_FLAG_INUSE; in ocfs2_resv_remove()
255 struct ocfs2_alloc_reservation *resv) in __ocfs2_resv_discard() argument
259 __ocfs2_resv_trunc(resv); in __ocfs2_resv_discard()
264 resv->r_last_len = resv->r_last_start = 0; in __ocfs2_resv_discard()
266 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
271 struct ocfs2_alloc_reservation *resv) in ocfs2_resv_discard() argument
273 if (resv) { in ocfs2_resv_discard()
275 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
283 struct ocfs2_alloc_reservation *resv; in ocfs2_resmap_clear_all_resv() local
288 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_resmap_clear_all_resv()
290 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
369 struct ocfs2_alloc_reservation *resv = NULL; in ocfs2_find_resv_lhs() local
380 resv = rb_entry(node, struct ocfs2_alloc_reservation, r_node); in ocfs2_find_resv_lhs()
382 if (resv->r_start <= goal && ocfs2_resv_end(resv) >= goal) in ocfs2_find_resv_lhs()
386 if (resv->r_start > goal) { in ocfs2_find_resv_lhs()
387 resv = prev_resv; in ocfs2_find_resv_lhs()
391 prev_resv = resv; in ocfs2_find_resv_lhs()
395 return resv; in ocfs2_find_resv_lhs()
471 struct ocfs2_alloc_reservation *resv, in __ocfs2_resv_find_window() argument
489 trace_ocfs2_resv_find_window_begin(resv->r_start, ocfs2_resv_end(resv), in __ocfs2_resv_find_window()
512 resv->r_start = cstart; in __ocfs2_resv_find_window()
513 resv->r_len = clen; in __ocfs2_resv_find_window()
515 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
624 resv->r_start = best_start; in __ocfs2_resv_find_window()
625 resv->r_len = best_len; in __ocfs2_resv_find_window()
626 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
631 struct ocfs2_alloc_reservation *resv, in ocfs2_cannibalize_resv() argument
635 int tmpwindow = !!(resv->r_flags & OCFS2_RESV_FLAG_TMP); in ocfs2_cannibalize_resv()
639 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
667 resv->r_start = lru_resv->r_start; in ocfs2_cannibalize_resv()
668 resv->r_len = lru_resv->r_len; in ocfs2_cannibalize_resv()
680 resv->r_start = ocfs2_resv_end(lru_resv) + 1; in ocfs2_cannibalize_resv()
681 resv->r_len = shrink; in ocfs2_cannibalize_resv()
684 trace_ocfs2_cannibalize_resv_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_cannibalize_resv()
685 resv->r_len, resv->r_last_start, in ocfs2_cannibalize_resv()
686 resv->r_last_len); in ocfs2_cannibalize_resv()
688 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
692 struct ocfs2_alloc_reservation *resv, in ocfs2_resv_find_window() argument
697 BUG_ON(!ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
704 if (resv->r_last_len) { in ocfs2_resv_find_window()
705 goal = resv->r_last_start + resv->r_last_len; in ocfs2_resv_find_window()
710 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
713 if (ocfs2_resv_empty(resv) && goal != 0) in ocfs2_resv_find_window()
714 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
716 if (ocfs2_resv_empty(resv)) { in ocfs2_resv_find_window()
721 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
724 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resv_find_window()
728 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_resv_bits() argument
731 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
736 if (ocfs2_resv_empty(resv)) { in ocfs2_resmap_resv_bits()
742 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
744 if ((resv->r_flags & OCFS2_RESV_FLAG_TMP) || wanted < *clen) in ocfs2_resmap_resv_bits()
754 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
755 trace_ocfs2_resmap_resv_bits(resv->r_start, resv->r_len); in ocfs2_resmap_resv_bits()
758 BUG_ON(ocfs2_resv_empty(resv)); in ocfs2_resmap_resv_bits()
760 *cstart = resv->r_start; in ocfs2_resmap_resv_bits()
761 *clen = resv->r_len; in ocfs2_resmap_resv_bits()
769 struct ocfs2_alloc_reservation *resv, in ocfs2_adjust_resv_from_alloc() argument
773 unsigned int old_end = ocfs2_resv_end(resv); in ocfs2_adjust_resv_from_alloc()
775 BUG_ON(start != resv->r_start || old_end < end); in ocfs2_adjust_resv_from_alloc()
781 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
792 resv->r_start = end + 1; in ocfs2_adjust_resv_from_alloc()
793 resv->r_len = old_end - resv->r_start + 1; in ocfs2_adjust_resv_from_alloc()
797 struct ocfs2_alloc_reservation *resv, in ocfs2_resmap_claimed_bits() argument
805 if (resv == NULL) in ocfs2_resmap_claimed_bits()
808 BUG_ON(cstart != resv->r_start); in ocfs2_resmap_claimed_bits()
812 trace_ocfs2_resmap_claimed_bits_begin(cstart, cend, clen, resv->r_start, in ocfs2_resmap_claimed_bits()
813 ocfs2_resv_end(resv), resv->r_len, in ocfs2_resmap_claimed_bits()
814 resv->r_last_start, in ocfs2_resmap_claimed_bits()
815 resv->r_last_len); in ocfs2_resmap_claimed_bits()
817 BUG_ON(cstart < resv->r_start); in ocfs2_resmap_claimed_bits()
818 BUG_ON(cstart > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
819 BUG_ON(cend > ocfs2_resv_end(resv)); in ocfs2_resmap_claimed_bits()
821 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
822 resv->r_last_start = cstart; in ocfs2_resmap_claimed_bits()
823 resv->r_last_len = clen; in ocfs2_resmap_claimed_bits()
829 if (!ocfs2_resv_empty(resv)) in ocfs2_resmap_claimed_bits()
830 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
832 trace_ocfs2_resmap_claimed_bits_end(resv->r_start, ocfs2_resv_end(resv), in ocfs2_resmap_claimed_bits()
833 resv->r_len, resv->r_last_start, in ocfs2_resmap_claimed_bits()
834 resv->r_last_len); in ocfs2_resmap_claimed_bits()