Lines Matching refs:resv

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