Lines Matching refs:osb

76 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
115 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
320 static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb,
328 BUG_ON(!ocfs2_supports_discontig_bg(osb));
330 el->l_count = cpu_to_le16(ocfs2_extent_recs_per_gd(osb->sb));
351 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
374 bg->bg_generation = cpu_to_le32(osb->fs_generation);
376 osb->s_feature_incompat));
384 ocfs2_bg_discontig_add_extent(osb, bg, cl, group_blkno,
419 ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
440 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
444 bg_bh = sb_getblk(osb->sb, bg_blkno);
463 static int ocfs2_block_group_claim_bits(struct ocfs2_super *osb,
491 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
513 status = ocfs2_block_group_claim_bits(osb, handle, ac,
521 p_blkno = ocfs2_clusters_to_blocks(osb->sb, p_cpos);
522 ocfs2_bg_discontig_add_extent(osb, bg, cl, p_blkno,
587 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
589 if (!ocfs2_supports_discontig_bg(osb)) {
595 ocfs2_calc_bg_discontig_credits(osb->sb));
610 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits,
620 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
624 bg_bh = sb_getblk(osb->sb, bg_blkno);
653 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
672 status = ocfs2_reserve_clusters_with_limit(osb,
681 credits = ocfs2_calc_group_alloc_credits(osb->sb,
683 handle = ocfs2_start_trans(osb, credits);
697 bg_bh = ocfs2_block_group_alloc_contig(osb, handle, alloc_inode,
752 ocfs2_commit_trans(osb, handle);
764 static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
778 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
830 status = ocfs2_block_group_alloc(osb, alloc_inode, bh,
838 atomic_inc(&osb->alloc_stats.bg_extends);
856 static void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb)
858 spin_lock(&osb->osb_lock);
859 osb->s_inode_steal_slot = OCFS2_INVALID_SLOT;
860 spin_unlock(&osb->osb_lock);
861 atomic_set(&osb->s_num_inodes_stolen, 0);
864 static void ocfs2_init_meta_steal_slot(struct ocfs2_super *osb)
866 spin_lock(&osb->osb_lock);
867 osb->s_meta_steal_slot = OCFS2_INVALID_SLOT;
868 spin_unlock(&osb->osb_lock);
869 atomic_set(&osb->s_num_meta_stolen, 0);
872 void ocfs2_init_steal_slots(struct ocfs2_super *osb)
874 ocfs2_init_inode_steal_slot(osb);
875 ocfs2_init_meta_steal_slot(osb);
878 static void __ocfs2_set_steal_slot(struct ocfs2_super *osb, int slot, int type)
880 spin_lock(&osb->osb_lock);
882 osb->s_inode_steal_slot = (u16)slot;
884 osb->s_meta_steal_slot = (u16)slot;
885 spin_unlock(&osb->osb_lock);
888 static int __ocfs2_get_steal_slot(struct ocfs2_super *osb, int type)
892 spin_lock(&osb->osb_lock);
894 slot = osb->s_inode_steal_slot;
896 slot = osb->s_meta_steal_slot;
897 spin_unlock(&osb->osb_lock);
902 static int ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
904 return __ocfs2_get_steal_slot(osb, INODE_ALLOC_SYSTEM_INODE);
907 static int ocfs2_get_meta_steal_slot(struct ocfs2_super *osb)
909 return __ocfs2_get_steal_slot(osb, EXTENT_ALLOC_SYSTEM_INODE);
912 static int ocfs2_steal_resource(struct ocfs2_super *osb,
917 int slot = __ocfs2_get_steal_slot(osb, type);
921 slot = osb->slot_num + 1;
923 for (i = 0; i < osb->max_slots; i++, slot++) {
924 if (slot == osb->max_slots)
927 if (slot == osb->slot_num)
930 status = ocfs2_reserve_suballoc_bits(osb, ac,
935 __ocfs2_set_steal_slot(osb, slot, type);
945 static int ocfs2_steal_inode(struct ocfs2_super *osb,
948 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE);
951 static int ocfs2_steal_meta(struct ocfs2_super *osb,
954 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE);
957 int ocfs2_reserve_new_metadata_blocks(struct ocfs2_super *osb,
962 int slot = ocfs2_get_meta_steal_slot(osb);
976 atomic_read(&osb->s_num_meta_stolen) < OCFS2_MAX_TO_STEAL)
979 atomic_set(&osb->s_num_meta_stolen, 0);
980 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
982 (u32)osb->slot_num, NULL,
989 ocfs2_init_meta_steal_slot(osb);
999 status = ocfs2_steal_meta(osb, *ac);
1000 atomic_inc(&osb->s_num_meta_stolen);
1019 int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
1023 return ocfs2_reserve_new_metadata_blocks(osb,
1028 int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
1032 int slot = ocfs2_get_inode_steal_slot(osb);
1052 if (!(osb->s_mount_opt & OCFS2_MOUNT_INODE64))
1065 atomic_read(&osb->s_num_inodes_stolen) < OCFS2_MAX_TO_STEAL)
1068 atomic_set(&osb->s_num_inodes_stolen, 0);
1069 alloc_group = osb->osb_inode_alloc_group;
1070 status = ocfs2_reserve_suballoc_bits(osb, *ac,
1072 (u32)osb->slot_num,
1079 spin_lock(&osb->osb_lock);
1080 osb->osb_inode_alloc_group = alloc_group;
1081 spin_unlock(&osb->osb_lock);
1090 ocfs2_init_inode_steal_slot(osb);
1100 status = ocfs2_steal_inode(osb, *ac);
1101 atomic_inc(&osb->s_num_inodes_stolen);
1122 int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
1130 status = ocfs2_reserve_suballoc_bits(osb, ac,
1143 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
1163 ocfs2_alloc_should_use_local(osb, bits_wanted)) {
1164 status = ocfs2_reserve_local_alloc_bits(osb,
1175 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
1182 ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted);
1221 int ocfs2_reserve_clusters(struct ocfs2_super *osb,
1225 return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0,
1277 static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
1486 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1511 ret = ocfs2_block_group_find_clear_bits(osb,
1540 ocfs2_local_alloc_seen_free_bits(osb, res->sr_bits);
2243 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2248 if (bg_blkno != osb->first_cluster_group_blkno)
2258 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2263 group_no = cluster / osb->bitmap_cpg;
2265 return osb->first_cluster_group_blkno;
2267 group_no * osb->bitmap_cpg);
2277 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2278 u32 data_cluster = ocfs2_blocks_to_clusters(osb->sb, data_blkno);
2285 if (*bg_blkno == osb->first_cluster_group_blkno)
2288 *bg_bit_off = (u16) ocfs2_blocks_to_clusters(osb->sb,
2308 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb);
2318 status = ocfs2_claim_local_alloc_bits(osb,
2325 atomic_inc(&osb->alloc_stats.local_data);
2327 if (min_clusters > (osb->bitmap_cpg - 1)) {
2332 osb->bitmap_cpg);
2337 if (bits_wanted > (osb->bitmap_cpg - 1))
2338 bits_wanted = osb->bitmap_cpg - 1;
2351 atomic_inc(&osb->alloc_stats.bitmap_data);
2630 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2659 (ocfs2_sparse_alloc(osb) && num_free_extents < max_recs_needed)) {
2660 ret = ocfs2_reserve_new_metadata(osb, et->et_root_el, meta_ac);
2671 ret = ocfs2_reserve_clusters(osb, clusters_to_add, data_ac);
2697 static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno,
2708 status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh);
2724 (u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots - 1) {
2754 static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb,
2812 int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
2822 status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot,
2830 inode_alloc_inode = ocfs2_get_system_file_inode(osb,
2833 inode_alloc_inode = ocfs2_get_system_file_inode(osb,
2854 status = ocfs2_test_suballoc_bit(osb, inode_alloc_inode, alloc_bh,