Lines Matching refs:resmap
41 static unsigned int ocfs2_resv_window_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resv_window_bits() argument
44 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_resv_window_bits()
68 static inline int ocfs2_resmap_disabled(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_disabled() argument
70 if (resmap->m_osb->osb_resv_level == 0) in ocfs2_resmap_disabled()
75 static void ocfs2_dump_resv(struct ocfs2_reservation_map *resmap) in ocfs2_dump_resv() argument
77 struct ocfs2_super *osb = resmap->m_osb; in ocfs2_dump_resv()
83 osb->dev_str, resmap->m_bitmap_len); in ocfs2_dump_resv()
85 node = rb_first(&resmap->m_reservations); in ocfs2_dump_resv()
101 list_for_each_entry(resv, &resmap->m_lru, r_lru) { in ocfs2_dump_resv()
112 static int ocfs2_validate_resmap_bits(struct ocfs2_reservation_map *resmap, in ocfs2_validate_resmap_bits() argument
116 char *disk_bitmap = resmap->m_disk_bitmap; in ocfs2_validate_resmap_bits()
133 static void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
140 node = rb_first(&resmap->m_reservations); in ocfs2_check_resmap()
162 if (ocfs2_resv_end(resv) >= resmap->m_bitmap_len) { in ocfs2_check_resmap()
168 if (ocfs2_validate_resmap_bits(resmap, i, resv)) in ocfs2_check_resmap()
179 ocfs2_dump_resv(resmap); in ocfs2_check_resmap()
183 static inline void ocfs2_check_resmap(struct ocfs2_reservation_map *resmap) in ocfs2_check_resmap() argument
204 struct ocfs2_reservation_map *resmap) in ocfs2_resmap_init() argument
206 memset(resmap, 0, sizeof(*resmap)); in ocfs2_resmap_init()
208 resmap->m_osb = osb; in ocfs2_resmap_init()
209 resmap->m_reservations = RB_ROOT; in ocfs2_resmap_init()
211 INIT_LIST_HEAD(&resmap->m_lru); in ocfs2_resmap_init()
216 static void ocfs2_resv_mark_lru(struct ocfs2_reservation_map *resmap, in ocfs2_resv_mark_lru() argument
224 list_add_tail(&resv->r_lru, &resmap->m_lru); in ocfs2_resv_mark_lru()
233 static void ocfs2_resv_remove(struct ocfs2_reservation_map *resmap, in ocfs2_resv_remove() argument
238 rb_erase(&resv->r_node, &resmap->m_reservations); in ocfs2_resv_remove()
243 static void __ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_discard() argument
255 ocfs2_resv_remove(resmap, resv); in __ocfs2_resv_discard()
259 void ocfs2_resv_discard(struct ocfs2_reservation_map *resmap, in ocfs2_resv_discard() argument
264 __ocfs2_resv_discard(resmap, resv); in ocfs2_resv_discard()
269 static void ocfs2_resmap_clear_all_resv(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_clear_all_resv() argument
276 while ((node = rb_last(&resmap->m_reservations)) != NULL) { in ocfs2_resmap_clear_all_resv()
279 __ocfs2_resv_discard(resmap, resv); in ocfs2_resmap_clear_all_resv()
283 void ocfs2_resmap_restart(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_restart() argument
286 if (ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_restart()
291 ocfs2_resmap_clear_all_resv(resmap); in ocfs2_resmap_restart()
292 resmap->m_bitmap_len = clen; in ocfs2_resmap_restart()
293 resmap->m_disk_bitmap = disk_bitmap; in ocfs2_resmap_restart()
298 void ocfs2_resmap_uninit(struct ocfs2_reservation_map *resmap) in ocfs2_resmap_uninit() argument
303 static void ocfs2_resv_insert(struct ocfs2_reservation_map *resmap, in ocfs2_resv_insert() argument
306 struct rb_root *root = &resmap->m_reservations; in ocfs2_resv_insert()
341 ocfs2_resv_mark_lru(resmap, new); in ocfs2_resv_insert()
343 ocfs2_check_resmap(resmap); in ocfs2_resv_insert()
356 ocfs2_find_resv_lhs(struct ocfs2_reservation_map *resmap, unsigned int goal) in ocfs2_find_resv_lhs() argument
360 struct rb_node *node = resmap->m_reservations.rb_node; in ocfs2_find_resv_lhs()
367 node = rb_first(&resmap->m_reservations); in ocfs2_find_resv_lhs()
403 static int ocfs2_resmap_find_free_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_find_free_bits() argument
410 void *bitmap = resmap->m_disk_bitmap; in ocfs2_resmap_find_free_bits()
415 wanted, resmap->m_bitmap_len); in ocfs2_resmap_find_free_bits()
420 while ((offset = ocfs2_find_next_zero_bit(bitmap, resmap->m_bitmap_len, in ocfs2_resmap_find_free_bits()
459 static void __ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in __ocfs2_resv_find_window() argument
463 struct rb_root *root = &resmap->m_reservations; in __ocfs2_resv_find_window()
488 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
489 resmap->m_bitmap_len - goal, in __ocfs2_resv_find_window()
504 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
508 prev_resv = ocfs2_find_resv_lhs(resmap, goal); in __ocfs2_resv_find_window()
537 ocfs2_dump_resv(resmap); in __ocfs2_resv_find_window()
541 clen = ocfs2_resmap_find_free_bits(resmap, wanted, goal, in __ocfs2_resv_find_window()
578 gap_len = resmap->m_bitmap_len - gap_start; in __ocfs2_resv_find_window()
579 gap_end = resmap->m_bitmap_len - 1; in __ocfs2_resv_find_window()
591 clen = ocfs2_resmap_find_free_bits(resmap, wanted, gap_start, in __ocfs2_resv_find_window()
615 ocfs2_resv_insert(resmap, resv); in __ocfs2_resv_find_window()
619 static void ocfs2_cannibalize_resv(struct ocfs2_reservation_map *resmap, in ocfs2_cannibalize_resv() argument
628 min_bits = ocfs2_resv_window_bits(resmap, resv) >> 1; in ocfs2_cannibalize_resv()
639 lru_resv = list_first_entry(&resmap->m_lru, in ocfs2_cannibalize_resv()
659 __ocfs2_resv_discard(resmap, lru_resv); in ocfs2_cannibalize_resv()
677 ocfs2_resv_insert(resmap, resv); in ocfs2_cannibalize_resv()
680 static void ocfs2_resv_find_window(struct ocfs2_reservation_map *resmap, in ocfs2_resv_find_window() argument
695 if (goal >= resmap->m_bitmap_len) in ocfs2_resv_find_window()
699 __ocfs2_resv_find_window(resmap, resv, goal, wanted); in ocfs2_resv_find_window()
703 __ocfs2_resv_find_window(resmap, resv, 0, wanted); in ocfs2_resv_find_window()
710 ocfs2_cannibalize_resv(resmap, resv, wanted); in ocfs2_resv_find_window()
716 int ocfs2_resmap_resv_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_resv_bits() argument
720 if (resv == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_resv_bits()
731 unsigned int wanted = ocfs2_resv_window_bits(resmap, resv); in ocfs2_resmap_resv_bits()
743 ocfs2_resv_find_window(resmap, resv, wanted); in ocfs2_resmap_resv_bits()
757 ocfs2_adjust_resv_from_alloc(struct ocfs2_reservation_map *resmap, in ocfs2_adjust_resv_from_alloc() argument
770 __ocfs2_resv_discard(resmap, resv); in ocfs2_adjust_resv_from_alloc()
785 void ocfs2_resmap_claimed_bits(struct ocfs2_reservation_map *resmap, in ocfs2_resmap_claimed_bits() argument
791 if (resmap == NULL || ocfs2_resmap_disabled(resmap)) in ocfs2_resmap_claimed_bits()
810 ocfs2_adjust_resv_from_alloc(resmap, resv, cstart, cend); in ocfs2_resmap_claimed_bits()
819 ocfs2_resv_mark_lru(resmap, resv); in ocfs2_resmap_claimed_bits()
825 ocfs2_check_resmap(resmap); in ocfs2_resmap_claimed_bits()