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