Lines Matching refs:osb

37 static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
44 static int ocfs2_sync_local_to_main(struct ocfs2_super *osb,
50 static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
55 static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
59 static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
101 unsigned int ocfs2_la_default_mb(struct ocfs2_super *osb) in ocfs2_la_default_mb() argument
107 struct super_block *sb = osb->sb; in ocfs2_la_default_mb()
109 gd_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
110 8 * ocfs2_group_bitmap_size(sb, 0, osb->s_feature_incompat)); in ocfs2_la_default_mb()
117 if ((sb->s_blocksize == 512 && osb->s_clustersize <= 8192) in ocfs2_la_default_mb()
118 || (sb->s_blocksize == 1024 && osb->s_clustersize == 4096)) in ocfs2_la_default_mb()
164 megs_per_slot = osb->osb_clusters_at_boot / osb->max_slots; in ocfs2_la_default_mb()
165 megs_per_slot = ocfs2_clusters_to_megabytes(osb->sb, megs_per_slot); in ocfs2_la_default_mb()
171 la_max_mb = ocfs2_clusters_to_megabytes(osb->sb, in ocfs2_la_default_mb()
179 void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) in ocfs2_la_set_sizes() argument
181 struct super_block *sb = osb->sb; in ocfs2_la_set_sizes()
182 unsigned int la_default_mb = ocfs2_la_default_mb(osb); in ocfs2_la_set_sizes()
192 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
196 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
199 osb->local_alloc_default_bits = in ocfs2_la_set_sizes()
203 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_la_set_sizes()
206 static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb) in ocfs2_la_state_enabled() argument
208 return (osb->local_alloc_state == OCFS2_LA_THROTTLED || in ocfs2_la_state_enabled()
209 osb->local_alloc_state == OCFS2_LA_ENABLED); in ocfs2_la_state_enabled()
212 void ocfs2_local_alloc_seen_free_bits(struct ocfs2_super *osb, in ocfs2_local_alloc_seen_free_bits() argument
215 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
216 if (osb->local_alloc_state == OCFS2_LA_DISABLED || in ocfs2_local_alloc_seen_free_bits()
217 osb->local_alloc_state == OCFS2_LA_THROTTLED) in ocfs2_local_alloc_seen_free_bits()
218 if (num_clusters >= osb->local_alloc_default_bits) { in ocfs2_local_alloc_seen_free_bits()
219 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_local_alloc_seen_free_bits()
220 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_local_alloc_seen_free_bits()
222 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
227 struct ocfs2_super *osb = in ocfs2_la_enable_worker() local
230 spin_lock(&osb->osb_lock); in ocfs2_la_enable_worker()
231 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_la_enable_worker()
232 spin_unlock(&osb->osb_lock); in ocfs2_la_enable_worker()
242 int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) in ocfs2_alloc_should_use_local() argument
247 spin_lock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
248 la_bits = osb->local_alloc_bits; in ocfs2_alloc_should_use_local()
250 if (!ocfs2_la_state_enabled(osb)) in ocfs2_alloc_should_use_local()
263 (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); in ocfs2_alloc_should_use_local()
264 spin_unlock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
268 int ocfs2_load_local_alloc(struct ocfs2_super *osb) in ocfs2_load_local_alloc() argument
277 if (osb->local_alloc_bits == 0) in ocfs2_load_local_alloc()
280 if (osb->local_alloc_bits >= osb->bitmap_cpg) { in ocfs2_load_local_alloc()
283 osb->local_alloc_bits, (osb->bitmap_cpg - 1)); in ocfs2_load_local_alloc()
284 osb->local_alloc_bits = in ocfs2_load_local_alloc()
285 ocfs2_megabytes_to_clusters(osb->sb, in ocfs2_load_local_alloc()
286 ocfs2_la_default_mb(osb)); in ocfs2_load_local_alloc()
290 inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, in ocfs2_load_local_alloc()
291 osb->slot_num); in ocfs2_load_local_alloc()
344 osb->local_alloc_bh = alloc_bh; in ocfs2_load_local_alloc()
345 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_load_local_alloc()
352 trace_ocfs2_load_local_alloc(osb->local_alloc_bits); in ocfs2_load_local_alloc()
366 void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) in ocfs2_shutdown_local_alloc() argument
377 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_shutdown_local_alloc()
378 if (osb->ocfs2_wq) in ocfs2_shutdown_local_alloc()
379 flush_workqueue(osb->ocfs2_wq); in ocfs2_shutdown_local_alloc()
381 if (osb->local_alloc_state == OCFS2_LA_UNUSED) in ocfs2_shutdown_local_alloc()
385 ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
387 osb->slot_num); in ocfs2_shutdown_local_alloc()
394 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_shutdown_local_alloc()
396 ocfs2_resmap_uninit(&osb->osb_la_resmap); in ocfs2_shutdown_local_alloc()
398 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
416 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_shutdown_local_alloc()
423 bh = osb->local_alloc_bh; in ocfs2_shutdown_local_alloc()
443 osb->local_alloc_bh = NULL; in ocfs2_shutdown_local_alloc()
444 osb->local_alloc_state = OCFS2_LA_UNUSED; in ocfs2_shutdown_local_alloc()
446 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_shutdown_local_alloc()
452 ocfs2_commit_trans(osb, handle); in ocfs2_shutdown_local_alloc()
476 int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_begin_local_alloc_recovery() argument
489 inode = ocfs2_get_system_file_inode(osb, in ocfs2_begin_local_alloc_recovery()
517 ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); in ocfs2_begin_local_alloc_recovery()
518 status = ocfs2_write_block(osb, alloc_bh, INODE_CACHE(inode)); in ocfs2_begin_local_alloc_recovery()
546 int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_complete_local_alloc_recovery() argument
554 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_complete_local_alloc_recovery()
571 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_complete_local_alloc_recovery()
582 status = ocfs2_sync_local_to_main(osb, handle, alloc, in ocfs2_complete_local_alloc_recovery()
587 ocfs2_commit_trans(osb, handle); in ocfs2_complete_local_alloc_recovery()
601 ocfs2_init_steal_slots(osb); in ocfs2_complete_local_alloc_recovery()
614 int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_reserve_local_alloc_bits() argument
626 ocfs2_get_system_file_inode(osb, in ocfs2_reserve_local_alloc_bits()
628 osb->slot_num); in ocfs2_reserve_local_alloc_bits()
641 spin_lock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
642 if (!ocfs2_la_state_enabled(osb) || in ocfs2_reserve_local_alloc_bits()
643 (bits_wanted > osb->local_alloc_bits)) { in ocfs2_reserve_local_alloc_bits()
644 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
648 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
650 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_reserve_local_alloc_bits()
655 …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()
668 ocfs2_local_alloc_slide_window(osb, local_alloc_inode); in ocfs2_reserve_local_alloc_bits()
682 if (!ocfs2_la_state_enabled(osb)) in ocfs2_reserve_local_alloc_bits()
693 ac->ac_alloc_slot = osb->slot_num; in ocfs2_reserve_local_alloc_bits()
695 get_bh(osb->local_alloc_bh); in ocfs2_reserve_local_alloc_bits()
696 ac->ac_bh = osb->local_alloc_bh; in ocfs2_reserve_local_alloc_bits()
706 bits_wanted, osb->slot_num, status); in ocfs2_reserve_local_alloc_bits()
713 int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_claim_local_alloc_bits() argument
729 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_claim_local_alloc_bits()
732 start = ocfs2_local_alloc_find_clear_bits(osb, alloc, &bits_wanted, in ocfs2_claim_local_alloc_bits()
747 osb->local_alloc_bh, in ocfs2_claim_local_alloc_bits()
754 ocfs2_resmap_claimed_bits(&osb->osb_la_resmap, ac->ac_resv, start, in ocfs2_claim_local_alloc_bits()
761 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_claim_local_alloc_bits()
769 int ocfs2_free_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_free_local_alloc_bits() argument
785 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_free_local_alloc_bits()
794 osb->local_alloc_bh, in ocfs2_free_local_alloc_bits()
805 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_free_local_alloc_bits()
822 static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, in ocfs2_local_alloc_find_clear_bits() argument
831 struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; in ocfs2_local_alloc_find_clear_bits()
856 BUG_ON(osb->osb_resv_level != 0); in ocfs2_local_alloc_find_clear_bits()
947 static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, in ocfs2_sync_local_to_main() argument
973 la_start_blk = ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
988 ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
1039 static int ocfs2_recalc_la_window(struct ocfs2_super *osb, in ocfs2_recalc_la_window() argument
1045 spin_lock(&osb->osb_lock); in ocfs2_recalc_la_window()
1046 if (osb->local_alloc_state == OCFS2_LA_DISABLED) { in ocfs2_recalc_la_window()
1047 WARN_ON_ONCE(osb->local_alloc_state == OCFS2_LA_DISABLED); in ocfs2_recalc_la_window()
1061 bits = osb->local_alloc_bits >> 1; in ocfs2_recalc_la_window()
1062 if (bits > ocfs2_megabytes_to_clusters(osb->sb, 1)) { in ocfs2_recalc_la_window()
1070 osb->local_alloc_state = OCFS2_LA_THROTTLED; in ocfs2_recalc_la_window()
1071 osb->local_alloc_bits = bits; in ocfs2_recalc_la_window()
1073 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_recalc_la_window()
1075 queue_delayed_work(osb->ocfs2_wq, &osb->la_enable_wq, in ocfs2_recalc_la_window()
1086 if (osb->local_alloc_state != OCFS2_LA_THROTTLED) in ocfs2_recalc_la_window()
1087 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_recalc_la_window()
1090 state = osb->local_alloc_state; in ocfs2_recalc_la_window()
1091 spin_unlock(&osb->osb_lock); in ocfs2_recalc_la_window()
1096 static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, in ocfs2_local_alloc_reserve_for_window() argument
1111 (*ac)->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_reserve_for_window()
1112 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_local_alloc_reserve_for_window()
1114 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_ENOSPC) == in ocfs2_local_alloc_reserve_for_window()
1146 static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, in ocfs2_local_alloc_new_window() argument
1155 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_new_window()
1160 osb->local_alloc_bits); in ocfs2_local_alloc_new_window()
1165 ac->ac_last_group = osb->la_last_gd; in ocfs2_local_alloc_new_window()
1170 status = ocfs2_claim_clusters(handle, ac, osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1179 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_FRAGMENTED) == in ocfs2_local_alloc_new_window()
1183 ac->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_new_window()
1185 osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1196 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1197 osb->local_alloc_bits = cluster_count; in ocfs2_local_alloc_new_window()
1198 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1207 osb->la_last_gd = ac->ac_last_group; in ocfs2_local_alloc_new_window()
1219 ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, in ocfs2_local_alloc_new_window()
1234 static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, in ocfs2_local_alloc_slide_window() argument
1245 ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); in ocfs2_local_alloc_slide_window()
1248 status = ocfs2_local_alloc_reserve_for_window(osb, in ocfs2_local_alloc_slide_window()
1258 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_local_alloc_slide_window()
1266 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_slide_window()
1273 alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS); in ocfs2_local_alloc_slide_window()
1282 osb->local_alloc_bh, in ocfs2_local_alloc_slide_window()
1290 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_local_alloc_slide_window()
1292 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_local_alloc_slide_window()
1299 status = ocfs2_local_alloc_new_window(osb, handle, ac); in ocfs2_local_alloc_slide_window()
1306 atomic_inc(&osb->alloc_stats.moves); in ocfs2_local_alloc_slide_window()
1310 ocfs2_commit_trans(osb, handle); in ocfs2_local_alloc_slide_window()