Lines Matching refs:resmap

44 static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,  in ocfs2_resv_window_bits()  argument
47 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_resv_window_bits()
71 static inline int ocfs2_resmap_disabled(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_disabled() argument
73 if (resmap->m_osb->osb_resv_level == 0) in ocfs2_resmap_disabled()
78 static void ocfs2_dump_resv(struct ocfs2_reservation_map *resmap) in ocfs2_dump_resv() argument
80 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_dump_resv()
86 osb->dev_str, resmap->m_bitmap_len); in ocfs2_dump_resv()
88 node = rb_first(&resmap->m_reservations); in ocfs2_dump_resv()
104 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
115 static int ocfs2_validate_resmap_bits(struct ocfs2_reservation_map *resmap, in ocfs2_validate_resmap_bits() argument
119 char *disk_bitmap = resmap->m_disk_bitmap; in ocfs2_validate_resmap_bits()
136 static void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
143 node = rb_first(&resmap->m_reservations); in ocfs2_check_resmap()
165 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
171 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
182 ocfs2_dump_resv(resmap); in ocfs2_check_resmap()
186 static inline void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
207 struct ocfs2_reservation_map *resmap) in ocfs2_resmap_init() argument
209 memset(resmap, 0, sizeof(*resmap)); in ocfs2_resmap_init()
211 resmap->m_osb = osb; in ocfs2_resmap_init()
212 resmap->m_reservations = RB_ROOT; in ocfs2_resmap_init()
214 INIT_LIST_HEAD(&resmap->m_lru); in ocfs2_resmap_init()
219 static void ocfs2_resv_mark_lru(struct ocfs2_reservation_map *resmap, in ocfs2_resv_mark_lru() argument
227 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
236 static void ocfs2_resv_remove(struct ocfs2_reservation_map *resmap, in ocfs2_resv_remove() argument
241 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
246 static void __ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_discard() argument
258 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
262 void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in ocfs2_resv_discard() argument
267 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
272 static void ocfs2_resmap_clear_all_resv(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_clear_all_resv() argument
279 while ((node = rb_last(&resmap->m_reservations)) != NULL) { in ocfs2_resmap_clear_all_resv()
282 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
286 void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_restart() argument
289 if (ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_restart()
294 ocfs2_resmap_clear_all_resv(resmap); in ocfs2_resmap_restart()
295 resmap->m_bitmap_len = clen; in ocfs2_resmap_restart()
296 resmap->m_disk_bitmap = disk_bitmap; in ocfs2_resmap_restart()
301 void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_uninit() argument
306 static void ocfs2_resv_insert(struct ocfs2_reservation_map *resmap, in ocfs2_resv_insert() argument
309 struct rb_root *root = &resmap->m_reservations; in ocfs2_resv_insert()
344 ocfs2_resv_mark_lru(resmap, new); in ocfs2_resv_insert()
346 ocfs2_check_resmap(resmap); in ocfs2_resv_insert()
359 ocfs2_find_resv_lhs(struct ocfs2_reservation_map *resmap, unsigned int goal) in ocfs2_find_resv_lhs() argument
363 struct rb_node *node = resmap->m_reservations.rb_node; in ocfs2_find_resv_lhs()
370 node = rb_first(&resmap->m_reservations); in ocfs2_find_resv_lhs()
406 static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_find_free_bits() argument
413 void *bitmap = resmap->m_disk_bitmap; in ocfs2_resmap_find_free_bits()
418 wanted, resmap->m_bitmap_len); in ocfs2_resmap_find_free_bits()
423 while ((offset = ocfs2_find_next_zero_bit(bitmap, resmap->m_bitmap_len, in ocfs2_resmap_find_free_bits()
462 static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_find_window() argument
466 struct rb_root *root = &resmap->m_reservations; in __ocfs2_resv_find_window()
491 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
492 resmap->m_bitmap_len - goal, in __ocfs2_resv_find_window()
507 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
511 prev_resv = ocfs2_find_resv_lhs(resmap, goal); in __ocfs2_resv_find_window()
540 ocfs2_dump_resv(resmap); in __ocfs2_resv_find_window()
544 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
581 gap_len = resmap->m_bitmap_len - gap_start; in __ocfs2_resv_find_window()
582 gap_end = resmap->m_bitmap_len - 1; in __ocfs2_resv_find_window()
594 clen = ocfs2_resmap_find_free_bits(resmap, wanted, gap_start, in __ocfs2_resv_find_window()
618 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
622 static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, in ocfs2_cannibalize_resv() argument
631 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
642 lru_resv = list_first_entry(&resmap->m_lru, in ocfs2_cannibalize_resv()
662 __ocfs2_resv_discard(resmap, lru_resv); in ocfs2_cannibalize_resv()
680 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
683 static void ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in ocfs2_resv_find_window() argument
698 if (goal >= resmap->m_bitmap_len) in ocfs2_resv_find_window()
702 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
706 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
713 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
719 int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_resv_bits() argument
723 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
734 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
746 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
760 ocfs2_adjust_resv_from_alloc(struct ocfs2_reservation_map *resmap, in ocfs2_adjust_resv_from_alloc() argument
773 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
788 void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_claimed_bits() argument
794 if (resmap == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_claimed_bits()
813 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
822 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
828 ocfs2_check_resmap(resmap); in ocfs2_resmap_claimed_bits()