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 if (num_clusters >= osb->local_alloc_default_bits) { in ocfs2_local_alloc_seen_free_bits()
216 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_seen_free_bits()
217 if (osb->local_alloc_state == OCFS2_LA_DISABLED || in ocfs2_local_alloc_seen_free_bits()
218 osb->local_alloc_state == OCFS2_LA_THROTTLED) { 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()
228 struct ocfs2_super *osb = in ocfs2_la_enable_worker() local
231 spin_lock(&osb->osb_lock); in ocfs2_la_enable_worker()
232 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_la_enable_worker()
233 spin_unlock(&osb->osb_lock); in ocfs2_la_enable_worker()
243 int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) in ocfs2_alloc_should_use_local() argument
248 spin_lock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
249 la_bits = osb->local_alloc_bits; in ocfs2_alloc_should_use_local()
251 if (!ocfs2_la_state_enabled(osb)) in ocfs2_alloc_should_use_local()
264 (unsigned long long)bits, osb->local_alloc_state, la_bits, ret); in ocfs2_alloc_should_use_local()
265 spin_unlock(&osb->osb_lock); in ocfs2_alloc_should_use_local()
269 int ocfs2_load_local_alloc(struct ocfs2_super *osb) in ocfs2_load_local_alloc() argument
278 if (osb->local_alloc_bits == 0) in ocfs2_load_local_alloc()
281 if (osb->local_alloc_bits >= osb->bitmap_cpg) { in ocfs2_load_local_alloc()
284 osb->local_alloc_bits, (osb->bitmap_cpg - 1)); in ocfs2_load_local_alloc()
285 osb->local_alloc_bits = in ocfs2_load_local_alloc()
286 ocfs2_megabytes_to_clusters(osb->sb, in ocfs2_load_local_alloc()
287 ocfs2_la_default_mb(osb)); in ocfs2_load_local_alloc()
291 inode = ocfs2_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, in ocfs2_load_local_alloc()
292 osb->slot_num); in ocfs2_load_local_alloc()
345 osb->local_alloc_bh = alloc_bh; in ocfs2_load_local_alloc()
346 osb->local_alloc_state = OCFS2_LA_ENABLED; in ocfs2_load_local_alloc()
353 trace_ocfs2_load_local_alloc(osb->local_alloc_bits); in ocfs2_load_local_alloc()
367 void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) in ocfs2_shutdown_local_alloc() argument
378 cancel_delayed_work(&osb->la_enable_wq); in ocfs2_shutdown_local_alloc()
379 if (osb->ocfs2_wq) in ocfs2_shutdown_local_alloc()
380 flush_workqueue(osb->ocfs2_wq); in ocfs2_shutdown_local_alloc()
382 if (osb->local_alloc_state == OCFS2_LA_UNUSED) in ocfs2_shutdown_local_alloc()
386 ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
388 osb->slot_num); in ocfs2_shutdown_local_alloc()
395 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_shutdown_local_alloc()
397 ocfs2_resmap_uninit(&osb->osb_la_resmap); in ocfs2_shutdown_local_alloc()
399 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_shutdown_local_alloc()
417 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_shutdown_local_alloc()
424 bh = osb->local_alloc_bh; in ocfs2_shutdown_local_alloc()
444 osb->local_alloc_bh = NULL; in ocfs2_shutdown_local_alloc()
445 osb->local_alloc_state = OCFS2_LA_UNUSED; in ocfs2_shutdown_local_alloc()
447 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_shutdown_local_alloc()
453 ocfs2_commit_trans(osb, handle); in ocfs2_shutdown_local_alloc()
477 int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_begin_local_alloc_recovery() argument
490 inode = ocfs2_get_system_file_inode(osb, in ocfs2_begin_local_alloc_recovery()
518 ocfs2_compute_meta_ecc(osb->sb, alloc_bh->b_data, &alloc->i_check); in ocfs2_begin_local_alloc_recovery()
519 status = ocfs2_write_block(osb, alloc_bh, INODE_CACHE(inode)); in ocfs2_begin_local_alloc_recovery()
547 int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, in ocfs2_complete_local_alloc_recovery() argument
555 main_bm_inode = ocfs2_get_system_file_inode(osb, in ocfs2_complete_local_alloc_recovery()
572 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_complete_local_alloc_recovery()
583 status = ocfs2_sync_local_to_main(osb, handle, alloc, in ocfs2_complete_local_alloc_recovery()
588 ocfs2_commit_trans(osb, handle); in ocfs2_complete_local_alloc_recovery()
602 ocfs2_init_steal_slots(osb); in ocfs2_complete_local_alloc_recovery()
615 int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_reserve_local_alloc_bits() argument
627 ocfs2_get_system_file_inode(osb, in ocfs2_reserve_local_alloc_bits()
629 osb->slot_num); in ocfs2_reserve_local_alloc_bits()
642 spin_lock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
643 if (!ocfs2_la_state_enabled(osb) || in ocfs2_reserve_local_alloc_bits()
644 (bits_wanted > osb->local_alloc_bits)) { in ocfs2_reserve_local_alloc_bits()
645 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
649 spin_unlock(&osb->osb_lock); in ocfs2_reserve_local_alloc_bits()
651 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_reserve_local_alloc_bits()
656 …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()
669 ocfs2_local_alloc_slide_window(osb, local_alloc_inode); in ocfs2_reserve_local_alloc_bits()
683 if (!ocfs2_la_state_enabled(osb)) in ocfs2_reserve_local_alloc_bits()
694 ac->ac_alloc_slot = osb->slot_num; in ocfs2_reserve_local_alloc_bits()
696 get_bh(osb->local_alloc_bh); in ocfs2_reserve_local_alloc_bits()
697 ac->ac_bh = osb->local_alloc_bh; in ocfs2_reserve_local_alloc_bits()
707 bits_wanted, osb->slot_num, status); in ocfs2_reserve_local_alloc_bits()
714 int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_claim_local_alloc_bits() argument
730 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_claim_local_alloc_bits()
733 start = ocfs2_local_alloc_find_clear_bits(osb, alloc, &bits_wanted, in ocfs2_claim_local_alloc_bits()
748 osb->local_alloc_bh, in ocfs2_claim_local_alloc_bits()
755 ocfs2_resmap_claimed_bits(&osb->osb_la_resmap, ac->ac_resv, start, in ocfs2_claim_local_alloc_bits()
762 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_claim_local_alloc_bits()
770 int ocfs2_free_local_alloc_bits(struct ocfs2_super *osb, in ocfs2_free_local_alloc_bits() argument
786 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_free_local_alloc_bits()
795 osb->local_alloc_bh, in ocfs2_free_local_alloc_bits()
806 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_free_local_alloc_bits()
823 static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, in ocfs2_local_alloc_find_clear_bits() argument
832 struct ocfs2_reservation_map *resmap = &osb->osb_la_resmap; in ocfs2_local_alloc_find_clear_bits()
857 BUG_ON(osb->osb_resv_level != 0); in ocfs2_local_alloc_find_clear_bits()
942 static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, in ocfs2_sync_local_to_main() argument
968 la_start_blk = ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
983 ocfs2_clusters_to_blocks(osb->sb, in ocfs2_sync_local_to_main()
1035 static int ocfs2_recalc_la_window(struct ocfs2_super *osb, in ocfs2_recalc_la_window() argument
1041 spin_lock(&osb->osb_lock); in ocfs2_recalc_la_window()
1042 if (osb->local_alloc_state == OCFS2_LA_DISABLED) { in ocfs2_recalc_la_window()
1043 WARN_ON_ONCE(osb->local_alloc_state == OCFS2_LA_DISABLED); in ocfs2_recalc_la_window()
1057 bits = osb->local_alloc_bits >> 1; in ocfs2_recalc_la_window()
1058 if (bits > ocfs2_megabytes_to_clusters(osb->sb, 1)) { in ocfs2_recalc_la_window()
1066 osb->local_alloc_state = OCFS2_LA_THROTTLED; in ocfs2_recalc_la_window()
1067 osb->local_alloc_bits = bits; in ocfs2_recalc_la_window()
1069 osb->local_alloc_state = OCFS2_LA_DISABLED; in ocfs2_recalc_la_window()
1071 queue_delayed_work(osb->ocfs2_wq, &osb->la_enable_wq, in ocfs2_recalc_la_window()
1082 if (osb->local_alloc_state != OCFS2_LA_THROTTLED) in ocfs2_recalc_la_window()
1083 osb->local_alloc_bits = osb->local_alloc_default_bits; in ocfs2_recalc_la_window()
1086 state = osb->local_alloc_state; in ocfs2_recalc_la_window()
1087 spin_unlock(&osb->osb_lock); in ocfs2_recalc_la_window()
1092 static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, in ocfs2_local_alloc_reserve_for_window() argument
1107 (*ac)->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_reserve_for_window()
1108 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_local_alloc_reserve_for_window()
1110 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_ENOSPC) == in ocfs2_local_alloc_reserve_for_window()
1142 static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, in ocfs2_local_alloc_new_window() argument
1151 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_new_window()
1156 osb->local_alloc_bits); in ocfs2_local_alloc_new_window()
1161 ac->ac_last_group = osb->la_last_gd; in ocfs2_local_alloc_new_window()
1166 status = ocfs2_claim_clusters(handle, ac, osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1175 if (ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_FRAGMENTED) == in ocfs2_local_alloc_new_window()
1179 ac->ac_bits_wanted = osb->local_alloc_bits; in ocfs2_local_alloc_new_window()
1181 osb->local_alloc_bits, in ocfs2_local_alloc_new_window()
1192 spin_lock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1193 osb->local_alloc_bits = cluster_count; in ocfs2_local_alloc_new_window()
1194 spin_unlock(&osb->osb_lock); in ocfs2_local_alloc_new_window()
1203 osb->la_last_gd = ac->ac_last_group; in ocfs2_local_alloc_new_window()
1215 ocfs2_resmap_restart(&osb->osb_la_resmap, cluster_count, in ocfs2_local_alloc_new_window()
1230 static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, in ocfs2_local_alloc_slide_window() argument
1241 ocfs2_recalc_la_window(osb, OCFS2_LA_EVENT_SLIDE); in ocfs2_local_alloc_slide_window()
1244 status = ocfs2_local_alloc_reserve_for_window(osb, in ocfs2_local_alloc_slide_window()
1254 handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); in ocfs2_local_alloc_slide_window()
1262 alloc = (struct ocfs2_dinode *) osb->local_alloc_bh->b_data; in ocfs2_local_alloc_slide_window()
1269 alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS); in ocfs2_local_alloc_slide_window()
1278 osb->local_alloc_bh, in ocfs2_local_alloc_slide_window()
1286 ocfs2_journal_dirty(handle, osb->local_alloc_bh); in ocfs2_local_alloc_slide_window()
1288 status = ocfs2_sync_local_to_main(osb, handle, alloc_copy, in ocfs2_local_alloc_slide_window()
1295 status = ocfs2_local_alloc_new_window(osb, handle, ac); in ocfs2_local_alloc_slide_window()
1302 atomic_inc(&osb->alloc_stats.moves); in ocfs2_local_alloc_slide_window()
1306 ocfs2_commit_trans(osb, handle); in ocfs2_local_alloc_slide_window()