Lines Matching refs:osb

39 static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
46 static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
52 static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
57 static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
61 static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
103 unsigned int ocfs2_la_default_mb(struct ocfs2_super *osb) in ocfs2_la_default_mb() argument
109 struct super_block *sb = osb->sb; in ocfs2_la_default_mb()
111 gd_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
112 8 * ocfs2_group_bitmap_size(sb, 0, osb->s_feature_incompat)); in ocfs2_la_default_mb()
119 if ((sb->s_blocksize == 512 && osb->s_clustersize <= 8192) in ocfs2_la_default_mb()
120 || (sb->s_blocksize == 1024 && osb->s_clustersize == 4096)) in ocfs2_la_default_mb()
166 megs_per_slot = osb->osb_clusters_at_boot / osb->max_slots; in ocfs2_la_default_mb()
167 megs_per_slot = ocfs2_clusters_to_megabytes(osb->sb, megs_per_slot); in ocfs2_la_default_mb()
173 la_max_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
181 void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) in ocfs2_la_set_sizes() argument
183 struct super_block *sb = osb->sb; in ocfs2_la_set_sizes()
184 unsigned int la_default_mb = ocfs2_la_default_mb(osb); in ocfs2_la_set_sizes()
194 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
198 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
201 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
205 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_la_set_sizes()
208 static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb) in ocfs2_la_state_enabled() argument
210 return (osb->local_alloc_state == OCFS2_LA_THROTTLED || in ocfs2_la_state_enabled()
211 osb->local_alloc_state == OCFS2_LA_ENABLED); in ocfs2_la_state_enabled()
214 void ocfs2_local_alloc_seen_free_bits(struct ocfs2_super *osb, in ocfs2_local_alloc_seen_free_bits() argument
217 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
218 if (osb->local_alloc_state == OCFS2_LA_DISABLED || in ocfs2_local_alloc_seen_free_bits()
219 osb->local_alloc_state == OCFS2_LA_THROTTLED) in ocfs2_local_alloc_seen_free_bits()
220 if (num_clusters >= osb->local_alloc_default_bits) { in ocfs2_local_alloc_seen_free_bits()
221 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_local_alloc_seen_free_bits()
222 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_local_alloc_seen_free_bits()
224 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
229 struct ocfs2_super *osb = in ocfs2_la_enable_worker() local
232 spin_lock(&osb->osb_lock); in ocfs2_la_enable_worker()
233 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_la_enable_worker()
234 spin_unlock(&osb->osb_lock); in ocfs2_la_enable_worker()
244 int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) in ocfs2_alloc_should_use_local() argument
249 spin_lock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
250 la_bits = osb->local_alloc_bits; in ocfs2_alloc_should_use_local()
252 if (!ocfs2_la_state_enabled(osb)) in ocfs2_alloc_should_use_local()
265 (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); in ocfs2_alloc_should_use_local()
266 spin_unlock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
270 int ocfs2_load_local_alloc(struct ocfs2_super *osb) in ocfs2_load_local_alloc() argument
279 if (osb->local_alloc_bits == 0) in ocfs2_load_local_alloc()
282 if (osb->local_alloc_bits >= osb->bitmap_cpg) { in ocfs2_load_local_alloc()
285 osb->local_alloc_bits, (osb->bitmap_cpg - 1)); in ocfs2_load_local_alloc()
286 osb->local_alloc_bits = in ocfs2_load_local_alloc()
287 ocfs2_megabytes_to_clusters(osb->sb, in ocfs2_load_local_alloc()
288 ocfs2_la_default_mb(osb)); in ocfs2_load_local_alloc()
292 inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, in ocfs2_load_local_alloc()
293 osb->slot_num); in ocfs2_load_local_alloc()
346 osb->local_alloc_bh = alloc_bh; in ocfs2_load_local_alloc()
347 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_load_local_alloc()
354 trace_ocfs2_load_local_alloc(osb->local_alloc_bits); in ocfs2_load_local_alloc()
368 void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) in ocfs2_shutdown_local_alloc() argument
379 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_shutdown_local_alloc()
380 if (osb->ocfs2_wq) in ocfs2_shutdown_local_alloc()
381 flush_workqueue(osb->ocfs2_wq); in ocfs2_shutdown_local_alloc()
383 if (osb->local_alloc_state == OCFS2_LA_UNUSED) in ocfs2_shutdown_local_alloc()
387 ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
389 osb->slot_num); in ocfs2_shutdown_local_alloc()
396 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_shutdown_local_alloc()
398 ocfs2_resmap_uninit(&osb->osb_la_resmap); in ocfs2_shutdown_local_alloc()
400 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
418 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_shutdown_local_alloc()
425 bh = osb->local_alloc_bh; in ocfs2_shutdown_local_alloc()
445 osb->local_alloc_bh = NULL; in ocfs2_shutdown_local_alloc()
446 osb->local_alloc_state = OCFS2_LA_UNUSED; in ocfs2_shutdown_local_alloc()
448 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_shutdown_local_alloc()
454 ocfs2_commit_trans(osb, handle); in ocfs2_shutdown_local_alloc()
478 int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_begin_local_alloc_recovery() argument
491 inode = ocfs2_get_system_file_inode(osb, in ocfs2_begin_local_alloc_recovery()
519 ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); in ocfs2_begin_local_alloc_recovery()
520 status = ocfs2_write_block(osb, alloc_bh, INODE_CACHE(inode)); in ocfs2_begin_local_alloc_recovery()
548 int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_complete_local_alloc_recovery() argument
556 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_complete_local_alloc_recovery()
573 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_complete_local_alloc_recovery()
584 status = ocfs2_sync_local_to_main(osb, handle, alloc, in ocfs2_complete_local_alloc_recovery()
589 ocfs2_commit_trans(osb, handle); in ocfs2_complete_local_alloc_recovery()
603 ocfs2_init_steal_slots(osb); in ocfs2_complete_local_alloc_recovery()
616 int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_reserve_local_alloc_bits() argument
628 ocfs2_get_system_file_inode(osb, in ocfs2_reserve_local_alloc_bits()
630 osb->slot_num); in ocfs2_reserve_local_alloc_bits()
643 spin_lock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
644 if (!ocfs2_la_state_enabled(osb) || in ocfs2_reserve_local_alloc_bits()
645 (bits_wanted > osb->local_alloc_bits)) { in ocfs2_reserve_local_alloc_bits()
646 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
650 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
652 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_reserve_local_alloc_bits()
657 …status = ocfs2_error(osb->sb, "local alloc inode %llu says it has %u used bits, but a count shows … in ocfs2_reserve_local_alloc_bits()
670 ocfs2_local_alloc_slide_window(osb, local_alloc_inode); in ocfs2_reserve_local_alloc_bits()
684 if (!ocfs2_la_state_enabled(osb)) in ocfs2_reserve_local_alloc_bits()
695 ac->ac_alloc_slot = osb->slot_num; in ocfs2_reserve_local_alloc_bits()
697 get_bh(osb->local_alloc_bh); in ocfs2_reserve_local_alloc_bits()
698 ac->ac_bh = osb->local_alloc_bh; in ocfs2_reserve_local_alloc_bits()
708 bits_wanted, osb->slot_num, status); in ocfs2_reserve_local_alloc_bits()
715 int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_claim_local_alloc_bits() argument
731 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_claim_local_alloc_bits()
734 start = ocfs2_local_alloc_find_clear_bits(osb, alloc, &bits_wanted, in ocfs2_claim_local_alloc_bits()
749 osb->local_alloc_bh, in ocfs2_claim_local_alloc_bits()
756 ocfs2_resmap_claimed_bits(&osb->osb_la_resmap, ac->ac_resv, start, in ocfs2_claim_local_alloc_bits()
763 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_claim_local_alloc_bits()
771 int ocfs2_free_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_free_local_alloc_bits() argument
787 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_free_local_alloc_bits()
796 osb->local_alloc_bh, in ocfs2_free_local_alloc_bits()
807 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_free_local_alloc_bits()
824 static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, in ocfs2_local_alloc_find_clear_bits() argument
833 struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; in ocfs2_local_alloc_find_clear_bits()
858 BUG_ON(osb->osb_resv_level != 0); in ocfs2_local_alloc_find_clear_bits()
949 static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, in ocfs2_sync_local_to_main() argument
975 la_start_blk = ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
990 ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
1041 static int ocfs2_recalc_la_window(struct ocfs2_super *osb, in ocfs2_recalc_la_window() argument
1047 spin_lock(&osb->osb_lock); in ocfs2_recalc_la_window()
1048 if (osb->local_alloc_state == OCFS2_LA_DISABLED) { in ocfs2_recalc_la_window()
1049 WARN_ON_ONCE(osb->local_alloc_state == OCFS2_LA_DISABLED); in ocfs2_recalc_la_window()
1063 bits = osb->local_alloc_bits >> 1; in ocfs2_recalc_la_window()
1064 if (bits > ocfs2_megabytes_to_clusters(osb->sb, 1)) { in ocfs2_recalc_la_window()
1072 osb->local_alloc_state = OCFS2_LA_THROTTLED; in ocfs2_recalc_la_window()
1073 osb->local_alloc_bits = bits; in ocfs2_recalc_la_window()
1075 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_recalc_la_window()
1077 queue_delayed_work(osb->ocfs2_wq, &osb->la_enable_wq, in ocfs2_recalc_la_window()
1088 if (osb->local_alloc_state != OCFS2_LA_THROTTLED) in ocfs2_recalc_la_window()
1089 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_recalc_la_window()
1092 state = osb->local_alloc_state; in ocfs2_recalc_la_window()
1093 spin_unlock(&osb->osb_lock); in ocfs2_recalc_la_window()
1098 static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, in ocfs2_local_alloc_reserve_for_window() argument
1113 (*ac)->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_reserve_for_window()
1114 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_local_alloc_reserve_for_window()
1116 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_ENOSPC) == in ocfs2_local_alloc_reserve_for_window()
1148 static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, in ocfs2_local_alloc_new_window() argument
1157 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_new_window()
1162 osb->local_alloc_bits); in ocfs2_local_alloc_new_window()
1167 ac->ac_last_group = osb->la_last_gd; in ocfs2_local_alloc_new_window()
1172 status = ocfs2_claim_clusters(handle, ac, osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1181 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_FRAGMENTED) == in ocfs2_local_alloc_new_window()
1185 ac->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_new_window()
1187 osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1198 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1199 osb->local_alloc_bits = cluster_count; in ocfs2_local_alloc_new_window()
1200 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1209 osb->la_last_gd = ac->ac_last_group; in ocfs2_local_alloc_new_window()
1221 ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, in ocfs2_local_alloc_new_window()
1236 static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, in ocfs2_local_alloc_slide_window() argument
1247 ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); in ocfs2_local_alloc_slide_window()
1250 status = ocfs2_local_alloc_reserve_for_window(osb, in ocfs2_local_alloc_slide_window()
1260 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_local_alloc_slide_window()
1268 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_slide_window()
1275 alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS); in ocfs2_local_alloc_slide_window()
1284 osb->local_alloc_bh, in ocfs2_local_alloc_slide_window()
1292 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_local_alloc_slide_window()
1294 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_local_alloc_slide_window()
1301 status = ocfs2_local_alloc_new_window(osb, handle, ac); in ocfs2_local_alloc_slide_window()
1308 atomic_inc(&osb->alloc_stats.moves); in ocfs2_local_alloc_slide_window()
1312 ocfs2_commit_trans(osb, handle); in ocfs2_local_alloc_slide_window()