Lines Matching refs:resmap

39 static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap,  in ocfs2_resv_window_bits()  argument
42 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_resv_window_bits()
66 static inline int ocfs2_resmap_disabled(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_disabled() argument
68 if (resmap->m_osb->osb_resv_level == 0) in ocfs2_resmap_disabled()
73 static void ocfs2_dump_resv(struct ocfs2_reservation_map *resmap) in ocfs2_dump_resv() argument
75 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_dump_resv()
81 osb->dev_str, resmap->m_bitmap_len); in ocfs2_dump_resv()
83 node = rb_first(&resmap->m_reservations); in ocfs2_dump_resv()
99 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
110 static int ocfs2_validate_resmap_bits(struct ocfs2_reservation_map *resmap, in ocfs2_validate_resmap_bits() argument
114 char *disk_bitmap = resmap->m_disk_bitmap; in ocfs2_validate_resmap_bits()
131 static void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
138 node = rb_first(&resmap->m_reservations); in ocfs2_check_resmap()
160 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
166 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
177 ocfs2_dump_resv(resmap); in ocfs2_check_resmap()
181 static inline void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
202 struct ocfs2_reservation_map *resmap) in ocfs2_resmap_init() argument
204 memset(resmap, 0, sizeof(*resmap)); in ocfs2_resmap_init()
206 resmap->m_osb = osb; in ocfs2_resmap_init()
207 resmap->m_reservations = RB_ROOT; in ocfs2_resmap_init()
209 INIT_LIST_HEAD(&resmap->m_lru); in ocfs2_resmap_init()
212 static void ocfs2_resv_mark_lru(struct ocfs2_reservation_map *resmap, in ocfs2_resv_mark_lru() argument
220 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
229 static void ocfs2_resv_remove(struct ocfs2_reservation_map *resmap, in ocfs2_resv_remove() argument
234 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
239 static void __ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_discard() argument
251 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
255 void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in ocfs2_resv_discard() argument
260 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
265 static void ocfs2_resmap_clear_all_resv(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_clear_all_resv() argument
272 while ((node = rb_last(&resmap->m_reservations)) != NULL) { in ocfs2_resmap_clear_all_resv()
275 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
279 void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_restart() argument
282 if (ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_restart()
287 ocfs2_resmap_clear_all_resv(resmap); in ocfs2_resmap_restart()
288 resmap->m_bitmap_len = clen; in ocfs2_resmap_restart()
289 resmap->m_disk_bitmap = disk_bitmap; in ocfs2_resmap_restart()
294 void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_uninit() argument
299 static void ocfs2_resv_insert(struct ocfs2_reservation_map *resmap, in ocfs2_resv_insert() argument
302 struct rb_root *root = &resmap->m_reservations; in ocfs2_resv_insert()
337 ocfs2_resv_mark_lru(resmap, new); in ocfs2_resv_insert()
339 ocfs2_check_resmap(resmap); in ocfs2_resv_insert()
352 ocfs2_find_resv_lhs(struct ocfs2_reservation_map *resmap, unsigned int goal) in ocfs2_find_resv_lhs() argument
356 struct rb_node *node = resmap->m_reservations.rb_node; in ocfs2_find_resv_lhs()
363 node = rb_first(&resmap->m_reservations); in ocfs2_find_resv_lhs()
399 static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_find_free_bits() argument
406 void *bitmap = resmap->m_disk_bitmap; in ocfs2_resmap_find_free_bits()
411 wanted, resmap->m_bitmap_len); in ocfs2_resmap_find_free_bits()
416 while ((offset = ocfs2_find_next_zero_bit(bitmap, resmap->m_bitmap_len, in ocfs2_resmap_find_free_bits()
417 start)) < resmap->m_bitmap_len) { in ocfs2_resmap_find_free_bits()
455 static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_find_window() argument
459 struct rb_root *root = &resmap->m_reservations; in __ocfs2_resv_find_window()
484 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
485 resmap->m_bitmap_len - goal, in __ocfs2_resv_find_window()
500 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
504 prev_resv = ocfs2_find_resv_lhs(resmap, goal); in __ocfs2_resv_find_window()
533 ocfs2_dump_resv(resmap); in __ocfs2_resv_find_window()
537 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
574 gap_len = resmap->m_bitmap_len - gap_start; in __ocfs2_resv_find_window()
575 gap_end = resmap->m_bitmap_len - 1; in __ocfs2_resv_find_window()
587 clen = ocfs2_resmap_find_free_bits(resmap, wanted, gap_start, in __ocfs2_resv_find_window()
611 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
615 static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, in ocfs2_cannibalize_resv() argument
624 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
635 lru_resv = list_first_entry(&resmap->m_lru, in ocfs2_cannibalize_resv()
655 __ocfs2_resv_discard(resmap, lru_resv); in ocfs2_cannibalize_resv()
673 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
676 static void ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in ocfs2_resv_find_window() argument
691 if (goal >= resmap->m_bitmap_len) in ocfs2_resv_find_window()
695 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
699 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
706 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
712 int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_resv_bits() argument
716 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
727 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
739 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
753 ocfs2_adjust_resv_from_alloc(struct ocfs2_reservation_map *resmap, in ocfs2_adjust_resv_from_alloc() argument
766 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
781 void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_claimed_bits() argument
787 if (resmap == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_claimed_bits()
806 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
815 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
821 ocfs2_check_resmap(resmap); in ocfs2_resmap_claimed_bits()