Lines Matching refs:osb

74 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
113 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
318 static void ocfs2_bg_discontig_add_extent(struct ocfs2_super *osb,
326 BUG_ON(!ocfs2_supports_discontig_bg(osb));
328 el->l_count = cpu_to_le16(ocfs2_extent_recs_per_gd(osb->sb));
349 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
372 bg->bg_generation = cpu_to_le32(osb->fs_generation);
374 osb->s_feature_incompat));
382 ocfs2_bg_discontig_add_extent(osb, bg, cl, group_blkno,
417 ocfs2_block_group_alloc_contig(struct ocfs2_super *osb, handle_t *handle,
438 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
442 bg_bh = sb_getblk(osb->sb, bg_blkno);
461 static int ocfs2_block_group_claim_bits(struct ocfs2_super *osb,
489 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
511 status = ocfs2_block_group_claim_bits(osb, handle, ac,
519 p_blkno = ocfs2_clusters_to_blocks(osb->sb, p_cpos);
520 ocfs2_bg_discontig_add_extent(osb, bg, cl, p_blkno,
585 struct ocfs2_super *osb = OCFS2_SB(alloc_inode->i_sb);
587 if (!ocfs2_supports_discontig_bg(osb)) {
593 ocfs2_calc_bg_discontig_credits(osb->sb));
608 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits,
618 bg_blkno = ocfs2_clusters_to_blocks(osb->sb, bit_off);
622 bg_bh = sb_getblk(osb->sb, bg_blkno);
651 static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
670 status = ocfs2_reserve_clusters_with_limit(osb,
679 credits = ocfs2_calc_group_alloc_credits(osb->sb,
681 handle = ocfs2_start_trans(osb, credits);
695 bg_bh = ocfs2_block_group_alloc_contig(osb, handle, alloc_inode,
750 ocfs2_commit_trans(osb, handle);
762 static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
776 alloc_inode = ocfs2_get_system_file_inode(osb, type, slot);
828 status = ocfs2_block_group_alloc(osb, alloc_inode, bh,
836 atomic_inc(&osb->alloc_stats.bg_extends);
854 static void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb)
856 spin_lock(&osb->osb_lock);
857 osb->s_inode_steal_slot = OCFS2_INVALID_SLOT;
858 spin_unlock(&osb->osb_lock);
859 atomic_set(&osb->s_num_inodes_stolen, 0);
862 static void ocfs2_init_meta_steal_slot(struct ocfs2_super *osb)
864 spin_lock(&osb->osb_lock);
865 osb->s_meta_steal_slot = OCFS2_INVALID_SLOT;
866 spin_unlock(&osb->osb_lock);
867 atomic_set(&osb->s_num_meta_stolen, 0);
870 void ocfs2_init_steal_slots(struct ocfs2_super *osb)
872 ocfs2_init_inode_steal_slot(osb);
873 ocfs2_init_meta_steal_slot(osb);
876 static void __ocfs2_set_steal_slot(struct ocfs2_super *osb, int slot, int type)
878 spin_lock(&osb->osb_lock);
880 osb->s_inode_steal_slot = (u16)slot;
882 osb->s_meta_steal_slot = (u16)slot;
883 spin_unlock(&osb->osb_lock);
886 static int __ocfs2_get_steal_slot(struct ocfs2_super *osb, int type)
890 spin_lock(&osb->osb_lock);
892 slot = osb->s_inode_steal_slot;
894 slot = osb->s_meta_steal_slot;
895 spin_unlock(&osb->osb_lock);
900 static int ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
902 return __ocfs2_get_steal_slot(osb, INODE_ALLOC_SYSTEM_INODE);
905 static int ocfs2_get_meta_steal_slot(struct ocfs2_super *osb)
907 return __ocfs2_get_steal_slot(osb, EXTENT_ALLOC_SYSTEM_INODE);
910 static int ocfs2_steal_resource(struct ocfs2_super *osb,
915 int slot = __ocfs2_get_steal_slot(osb, type);
919 slot = osb->slot_num + 1;
921 for (i = 0; i < osb->max_slots; i++, slot++) {
922 if (slot == osb->max_slots)
925 if (slot == osb->slot_num)
928 status = ocfs2_reserve_suballoc_bits(osb, ac,
933 __ocfs2_set_steal_slot(osb, slot, type);
943 static int ocfs2_steal_inode(struct ocfs2_super *osb,
946 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE);
949 static int ocfs2_steal_meta(struct ocfs2_super *osb,
952 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE);
955 int ocfs2_reserve_new_metadata_blocks(struct ocfs2_super *osb,
960 int slot = ocfs2_get_meta_steal_slot(osb);
974 atomic_read(&osb->s_num_meta_stolen) < OCFS2_MAX_TO_STEAL)
977 atomic_set(&osb->s_num_meta_stolen, 0);
978 status = ocfs2_reserve_suballoc_bits(osb, (*ac),
980 (u32)osb->slot_num, NULL,
987 ocfs2_init_meta_steal_slot(osb);
997 status = ocfs2_steal_meta(osb, *ac);
998 atomic_inc(&osb->s_num_meta_stolen);
1017 int ocfs2_reserve_new_metadata(struct ocfs2_super *osb,
1021 return ocfs2_reserve_new_metadata_blocks(osb,
1026 int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
1030 int slot = ocfs2_get_inode_steal_slot(osb);
1050 if (!(osb->s_mount_opt & OCFS2_MOUNT_INODE64))
1063 atomic_read(&osb->s_num_inodes_stolen) < OCFS2_MAX_TO_STEAL)
1066 atomic_set(&osb->s_num_inodes_stolen, 0);
1067 alloc_group = osb->osb_inode_alloc_group;
1068 status = ocfs2_reserve_suballoc_bits(osb, *ac,
1070 (u32)osb->slot_num,
1077 spin_lock(&osb->osb_lock);
1078 osb->osb_inode_alloc_group = alloc_group;
1079 spin_unlock(&osb->osb_lock);
1088 ocfs2_init_inode_steal_slot(osb);
1098 status = ocfs2_steal_inode(osb, *ac);
1099 atomic_inc(&osb->s_num_inodes_stolen);
1120 int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb,
1128 status = ocfs2_reserve_suballoc_bits(osb, ac,
1141 static int ocfs2_reserve_clusters_with_limit(struct ocfs2_super *osb,
1161 ocfs2_alloc_should_use_local(osb, bits_wanted)) {
1162 status = ocfs2_reserve_local_alloc_bits(osb,
1173 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
1180 ret = ocfs2_try_to_free_truncate_log(osb, bits_wanted);
1219 int ocfs2_reserve_clusters(struct ocfs2_super *osb,
1223 return ocfs2_reserve_clusters_with_limit(osb, bits_wanted, 0,
1275 static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb,
1484 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1509 ret = ocfs2_block_group_find_clear_bits(osb,
1538 ocfs2_local_alloc_seen_free_bits(osb, res->sr_bits);
2241 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2246 if (bg_blkno != osb->first_cluster_group_blkno)
2256 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2261 group_no = cluster / osb->bitmap_cpg;
2263 return osb->first_cluster_group_blkno;
2265 group_no * osb->bitmap_cpg);
2275 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2276 u32 data_cluster = ocfs2_blocks_to_clusters(osb->sb, data_blkno);
2283 if (*bg_blkno == osb->first_cluster_group_blkno)
2286 *bg_bit_off = (u16) ocfs2_blocks_to_clusters(osb->sb,
2306 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb);
2316 status = ocfs2_claim_local_alloc_bits(osb,
2323 atomic_inc(&osb->alloc_stats.local_data);
2325 if (min_clusters > (osb->bitmap_cpg - 1)) {
2330 osb->bitmap_cpg);
2335 if (bits_wanted > (osb->bitmap_cpg - 1))
2336 bits_wanted = osb->bitmap_cpg - 1;
2349 atomic_inc(&osb->alloc_stats.bitmap_data);
2628 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2657 (ocfs2_sparse_alloc(osb) && num_free_extents < max_recs_needed)) {
2658 ret = ocfs2_reserve_new_metadata(osb, et->et_root_el, meta_ac);
2669 ret = ocfs2_reserve_clusters(osb, clusters_to_add, data_ac);
2695 static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno,
2706 status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh);
2722 (u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots - 1) {
2752 static int ocfs2_test_suballoc_bit(struct ocfs2_super *osb,
2810 int ocfs2_test_inode_bit(struct ocfs2_super *osb, u64 blkno, int *res)
2820 status = ocfs2_get_suballoc_slot_bit(osb, blkno, &suballoc_slot,
2828 inode_alloc_inode = ocfs2_get_system_file_inode(osb,
2831 inode_alloc_inode = ocfs2_get_system_file_inode(osb,
2852 status = ocfs2_test_suballoc_bit(osb, inode_alloc_inode, alloc_bh,