Lines Matching refs:ac

109 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
134 struct ocfs2_alloc_context **ac);
136 void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) in ocfs2_free_ac_resource() argument
138 struct inode *inode = ac->ac_inode; in ocfs2_free_ac_resource()
141 if (ac->ac_which != OCFS2_AC_USE_LOCAL) in ocfs2_free_ac_resource()
147 ac->ac_inode = NULL; in ocfs2_free_ac_resource()
149 brelse(ac->ac_bh); in ocfs2_free_ac_resource()
150 ac->ac_bh = NULL; in ocfs2_free_ac_resource()
151 ac->ac_resv = NULL; in ocfs2_free_ac_resource()
152 kfree(ac->ac_find_loc_priv); in ocfs2_free_ac_resource()
153 ac->ac_find_loc_priv = NULL; in ocfs2_free_ac_resource()
156 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) in ocfs2_free_alloc_context() argument
158 ocfs2_free_ac_resource(ac); in ocfs2_free_alloc_context()
159 kfree(ac); in ocfs2_free_alloc_context()
437 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_contig() argument
446 status = ocfs2_claim_clusters(handle, ac, in ocfs2_block_group_alloc_contig()
481 struct ocfs2_alloc_context *ac, in ocfs2_block_group_claim_bits() argument
488 status = ocfs2_claim_clusters(handle, ac, min_bits, in ocfs2_block_group_claim_bits()
502 struct ocfs2_alloc_context *ac, in ocfs2_block_group_grow_discontig() argument
529 status = ocfs2_block_group_claim_bits(osb, handle, ac, in ocfs2_block_group_grow_discontig()
594 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_discontig() argument
623 ac->ac_disable_chain_relink = 1; in ocfs2_block_group_alloc_discontig()
626 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits, in ocfs2_block_group_alloc_discontig()
656 bg_bh, ac, cl, min_bits); in ocfs2_block_group_alloc_discontig()
662 ocfs2_bg_alloc_cleanup(handle, ac, alloc_inode, bg_bh); in ocfs2_block_group_alloc_discontig()
679 struct ocfs2_alloc_context *ac = NULL; in ocfs2_block_group_alloc() local
690 max_block, flags, &ac); in ocfs2_block_group_alloc()
710 ac->ac_last_group = *last_alloc_group; in ocfs2_block_group_alloc()
714 ac, cl); in ocfs2_block_group_alloc()
718 ac, cl); in ocfs2_block_group_alloc()
764 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
770 if (ac) in ocfs2_block_group_alloc()
771 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
781 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
788 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
811 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
812 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
847 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
863 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
929 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
946 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
955 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
962 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
964 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
968 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
970 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
975 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
980 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
981 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
987 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
988 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
989 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
996 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
1012 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
1015 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1025 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1026 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1027 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1037 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1041 ac); in ocfs2_reserve_new_metadata()
1045 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1051 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1052 if (!(*ac)) { in ocfs2_reserve_new_inode()
1058 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1059 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1061 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1069 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1086 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1113 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1116 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1126 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1127 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1128 *ac = NULL; in ocfs2_reserve_new_inode()
1139 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1143 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1144 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1146 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1165 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1169 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1170 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1176 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1177 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1184 *ac); in ocfs2_reserve_clusters_with_limit()
1192 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1202 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1203 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1204 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1214 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1217 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1628 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1635 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1638 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1645 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1658 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1668 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1669 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1679 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1680 ac->ac_max_block, res); in ocfs2_search_one_group()
1688 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1696 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1699 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1710 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1725 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1735 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1738 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1742 chain = ac->ac_chain; in ocfs2_search_chain()
1759 while ((status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1761 ac->ac_max_block, in ocfs2_search_chain()
1793 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1814 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1818 ac->ac_bh, group_bh, in ocfs2_search_chain()
1826 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1830 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1845 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1866 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1875 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1879 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1880 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1881 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1883 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1891 status = ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1905 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1918 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
1920 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1923 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) in ocfs2_claim_suballoc_bits()
1940 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
1947 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
1948 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1966 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
1968 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
1978 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
1988 BUG_ON(!ac); in ocfs2_claim_metadata()
1989 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
1990 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
1992 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2001 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2006 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2017 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2031 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2032 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2033 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2035 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2037 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2044 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2046 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2047 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2052 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2059 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2060 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2061 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2062 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2071 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2090 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2092 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2098 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2113 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2120 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2123 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2133 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2143 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2144 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2152 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2158 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2159 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2167 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2173 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2174 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2185 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2193 BUG_ON(!ac); in ocfs2_claim_new_inode()
2194 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2195 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2196 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2198 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2200 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2209 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2216 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2217 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2287 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2296 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2298 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2300 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2301 && ac->ac_which != OCFS2_AC_USE_MAIN); in __ocfs2_claim_clusters()
2303 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2308 ac, in __ocfs2_claim_clusters()
2328 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2336 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2349 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2358 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2363 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2365 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()