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