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