Lines Matching refs:resmap
52 static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resv_window_bits() argument
55 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_resv_window_bits()
79 static inline int ocfs2_resmap_disabled(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_disabled() argument
81 if (resmap->m_osb->osb_resv_level == 0) in ocfs2_resmap_disabled()
86 static void ocfs2_dump_resv(struct ocfs2_reservation_map *resmap) in ocfs2_dump_resv() argument
88 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_dump_resv()
94 osb->dev_str, resmap->m_bitmap_len); in ocfs2_dump_resv()
96 node = rb_first(&resmap->m_reservations); in ocfs2_dump_resv()
112 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
123 static int ocfs2_validate_resmap_bits(struct ocfs2_reservation_map *resmap, in ocfs2_validate_resmap_bits() argument
127 char *disk_bitmap = resmap->m_disk_bitmap; in ocfs2_validate_resmap_bits()
144 static void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
151 node = rb_first(&resmap->m_reservations); 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()
190 ocfs2_dump_resv(resmap); in ocfs2_check_resmap()
194 static inline void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
215 struct ocfs2_reservation_map *resmap) in ocfs2_resmap_init() argument
217 memset(resmap, 0, sizeof(*resmap)); in ocfs2_resmap_init()
219 resmap->m_osb = osb; in ocfs2_resmap_init()
220 resmap->m_reservations = RB_ROOT; in ocfs2_resmap_init()
222 INIT_LIST_HEAD(&resmap->m_lru); in ocfs2_resmap_init()
227 static void ocfs2_resv_mark_lru(struct ocfs2_reservation_map *resmap, in ocfs2_resv_mark_lru() argument
235 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
244 static void ocfs2_resv_remove(struct ocfs2_reservation_map *resmap, in ocfs2_resv_remove() argument
249 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
254 static void __ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_discard() argument
266 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
270 void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in ocfs2_resv_discard() argument
275 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
280 static void ocfs2_resmap_clear_all_resv(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_clear_all_resv() argument
287 while ((node = rb_last(&resmap->m_reservations)) != NULL) { in ocfs2_resmap_clear_all_resv()
290 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
294 void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_restart() argument
297 if (ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_restart()
302 ocfs2_resmap_clear_all_resv(resmap); in ocfs2_resmap_restart()
303 resmap->m_bitmap_len = clen; in ocfs2_resmap_restart()
304 resmap->m_disk_bitmap = disk_bitmap; in ocfs2_resmap_restart()
309 void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_uninit() argument
314 static void ocfs2_resv_insert(struct ocfs2_reservation_map *resmap, in ocfs2_resv_insert() argument
317 struct rb_root *root = &resmap->m_reservations; in ocfs2_resv_insert()
352 ocfs2_resv_mark_lru(resmap, new); in ocfs2_resv_insert()
354 ocfs2_check_resmap(resmap); in ocfs2_resv_insert()
367 ocfs2_find_resv_lhs(struct ocfs2_reservation_map *resmap, unsigned int goal) in ocfs2_find_resv_lhs() argument
371 struct rb_node *node = resmap->m_reservations.rb_node; in ocfs2_find_resv_lhs()
378 node = rb_first(&resmap->m_reservations); in ocfs2_find_resv_lhs()
414 static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_find_free_bits() argument
421 void *bitmap = resmap->m_disk_bitmap; in ocfs2_resmap_find_free_bits()
426 wanted, resmap->m_bitmap_len); in ocfs2_resmap_find_free_bits()
431 while ((offset = ocfs2_find_next_zero_bit(bitmap, resmap->m_bitmap_len, in ocfs2_resmap_find_free_bits()
470 static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_find_window() argument
474 struct rb_root *root = &resmap->m_reservations; in __ocfs2_resv_find_window()
499 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
500 resmap->m_bitmap_len - goal, in __ocfs2_resv_find_window()
515 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
519 prev_resv = ocfs2_find_resv_lhs(resmap, goal); in __ocfs2_resv_find_window()
548 ocfs2_dump_resv(resmap); in __ocfs2_resv_find_window()
552 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
589 gap_len = resmap->m_bitmap_len - gap_start; in __ocfs2_resv_find_window()
590 gap_end = resmap->m_bitmap_len - 1; in __ocfs2_resv_find_window()
602 clen = ocfs2_resmap_find_free_bits(resmap, wanted, gap_start, in __ocfs2_resv_find_window()
626 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
630 static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, in ocfs2_cannibalize_resv() argument
639 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
650 lru_resv = list_first_entry(&resmap->m_lru, in ocfs2_cannibalize_resv()
670 __ocfs2_resv_discard(resmap, lru_resv); in ocfs2_cannibalize_resv()
688 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
691 static void ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in ocfs2_resv_find_window() argument
706 if (goal >= resmap->m_bitmap_len) in ocfs2_resv_find_window()
710 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
714 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
721 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
727 int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_resv_bits() argument
731 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
742 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
754 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
768 ocfs2_adjust_resv_from_alloc(struct ocfs2_reservation_map *resmap, in ocfs2_adjust_resv_from_alloc() argument
781 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
796 void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_claimed_bits() argument
802 if (resmap == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_claimed_bits()
821 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
830 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
836 ocfs2_check_resmap(resmap); in ocfs2_resmap_claimed_bits()