Lines Matching full:ac
95 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
120 struct ocfs2_alloc_context **ac);
122 void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) in ocfs2_free_ac_resource() argument
124 struct inode *inode = ac->ac_inode; in ocfs2_free_ac_resource()
127 if (ac->ac_which != OCFS2_AC_USE_LOCAL) in ocfs2_free_ac_resource()
133 ac->ac_inode = NULL; in ocfs2_free_ac_resource()
135 brelse(ac->ac_bh); in ocfs2_free_ac_resource()
136 ac->ac_bh = NULL; in ocfs2_free_ac_resource()
137 ac->ac_resv = NULL; in ocfs2_free_ac_resource()
138 kfree(ac->ac_find_loc_priv); in ocfs2_free_ac_resource()
139 ac->ac_find_loc_priv = NULL; in ocfs2_free_ac_resource()
142 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) in ocfs2_free_alloc_context() argument
144 ocfs2_free_ac_resource(ac); in ocfs2_free_alloc_context()
145 kfree(ac); in ocfs2_free_alloc_context()
423 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_contig() argument
432 status = ocfs2_claim_clusters(handle, ac, in ocfs2_block_group_alloc_contig()
467 struct ocfs2_alloc_context *ac, in ocfs2_block_group_claim_bits() argument
474 status = ocfs2_claim_clusters(handle, ac, min_bits, in ocfs2_block_group_claim_bits()
488 struct ocfs2_alloc_context *ac, in ocfs2_block_group_grow_discontig() argument
515 status = ocfs2_block_group_claim_bits(osb, handle, ac, in ocfs2_block_group_grow_discontig()
580 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_discontig() argument
609 ac->ac_disable_chain_relink = 1; in ocfs2_block_group_alloc_discontig()
612 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits, in ocfs2_block_group_alloc_discontig()
642 bg_bh, ac, cl, min_bits); in ocfs2_block_group_alloc_discontig()
648 ocfs2_bg_alloc_cleanup(handle, ac, alloc_inode, bg_bh); in ocfs2_block_group_alloc_discontig()
665 struct ocfs2_alloc_context *ac = NULL; in ocfs2_block_group_alloc() local
676 max_block, flags, &ac); in ocfs2_block_group_alloc()
696 ac->ac_last_group = *last_alloc_group; in ocfs2_block_group_alloc()
700 ac, cl); in ocfs2_block_group_alloc()
704 ac, cl); in ocfs2_block_group_alloc()
750 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
756 if (ac) in ocfs2_block_group_alloc()
757 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
767 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
774 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
797 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
798 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
833 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
849 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
915 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
932 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
941 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
948 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
950 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
954 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
956 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
961 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
966 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
967 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
973 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
974 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
975 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
982 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
998 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
1001 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1011 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1012 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1013 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1023 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1027 ac); in ocfs2_reserve_new_metadata()
1031 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1037 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1038 if (!(*ac)) { in ocfs2_reserve_new_inode()
1044 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1045 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1047 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1055 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1072 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1099 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1102 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1112 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1113 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1114 *ac = NULL; in ocfs2_reserve_new_inode()
1125 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1129 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1130 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1132 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1148 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1153 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1154 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1160 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1161 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1168 *ac); in ocfs2_reserve_clusters_with_limit()
1177 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1181 ocfs2_inode_unlock((*ac)->ac_inode, 1); in ocfs2_reserve_clusters_with_limit()
1182 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1186 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1187 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1194 inode_lock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1195 ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1); in ocfs2_reserve_clusters_with_limit()
1198 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1199 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1200 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1213 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1214 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1215 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1225 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1228 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1690 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1697 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1700 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1707 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1720 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1730 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1731 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1741 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1742 ac->ac_max_block, res); in ocfs2_search_one_group()
1750 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1758 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1761 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1773 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1788 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1798 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1801 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1805 chain = ac->ac_chain; in ocfs2_search_chain()
1822 while ((status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1824 ac->ac_max_block, in ocfs2_search_chain()
1856 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1877 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1881 ac->ac_bh, group_bh, in ocfs2_search_chain()
1889 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1893 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1910 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1931 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1940 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1944 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1945 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1946 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1948 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1956 status = ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1970 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1983 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
1985 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1988 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) in ocfs2_claim_suballoc_bits()
2005 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
2012 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
2013 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
2031 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
2033 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
2043 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
2053 BUG_ON(!ac); in ocfs2_claim_metadata()
2054 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
2055 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
2057 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2066 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2071 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2082 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2096 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2097 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2098 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2100 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2102 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2109 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2111 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2112 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2117 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2124 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2125 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2126 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2127 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2136 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2155 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2157 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2163 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2178 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2185 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2188 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2198 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2208 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2209 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2217 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2225 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2226 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2234 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2240 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2241 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2252 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2260 BUG_ON(!ac); in ocfs2_claim_new_inode()
2261 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2262 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2263 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2265 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2267 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2276 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2283 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2284 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2354 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2363 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2365 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2367 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2368 && ac->ac_which != OCFS2_AC_USE_MAIN); in __ocfs2_claim_clusters()
2370 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2375 ac, in __ocfs2_claim_clusters()
2395 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2403 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2416 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2425 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2430 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2432 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()