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 if (ac->ac_find_loc_priv) { in ocfs2_free_ac_resource()
153 kfree(ac->ac_find_loc_priv); in ocfs2_free_ac_resource()
154 ac->ac_find_loc_priv = NULL; in ocfs2_free_ac_resource()
158 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) in ocfs2_free_alloc_context() argument
160 ocfs2_free_ac_resource(ac); in ocfs2_free_alloc_context()
161 kfree(ac); in ocfs2_free_alloc_context()
453 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_contig() argument
462 status = ocfs2_claim_clusters(handle, ac, in ocfs2_block_group_alloc_contig()
497 struct ocfs2_alloc_context *ac, in ocfs2_block_group_claim_bits() argument
504 status = ocfs2_claim_clusters(handle, ac, min_bits, in ocfs2_block_group_claim_bits()
518 struct ocfs2_alloc_context *ac, in ocfs2_block_group_grow_discontig() argument
545 status = ocfs2_block_group_claim_bits(osb, handle, ac, in ocfs2_block_group_grow_discontig()
610 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_discontig() argument
639 ac->ac_disable_chain_relink = 1; in ocfs2_block_group_alloc_discontig()
642 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits, in ocfs2_block_group_alloc_discontig()
672 bg_bh, ac, cl, min_bits); in ocfs2_block_group_alloc_discontig()
678 ocfs2_bg_alloc_cleanup(handle, ac, alloc_inode, bg_bh); in ocfs2_block_group_alloc_discontig()
695 struct ocfs2_alloc_context *ac = NULL; in ocfs2_block_group_alloc() local
706 max_block, flags, &ac); in ocfs2_block_group_alloc()
726 ac->ac_last_group = *last_alloc_group; in ocfs2_block_group_alloc()
730 ac, cl); in ocfs2_block_group_alloc()
734 ac, cl); in ocfs2_block_group_alloc()
780 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
786 if (ac) in ocfs2_block_group_alloc()
787 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
797 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
804 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
827 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
828 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
863 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
879 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
945 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
962 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
971 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
978 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
980 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
984 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
986 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
991 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
996 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
997 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
1003 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
1004 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
1005 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
1012 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
1028 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
1031 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1041 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1042 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1043 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1053 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1057 ac); in ocfs2_reserve_new_metadata()
1061 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1067 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1068 if (!(*ac)) { in ocfs2_reserve_new_inode()
1074 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1075 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1077 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1085 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1102 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1129 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1132 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1142 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1143 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1144 *ac = NULL; in ocfs2_reserve_new_inode()
1155 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1159 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1160 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1162 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1181 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1185 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1186 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1192 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1193 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1200 *ac); in ocfs2_reserve_clusters_with_limit()
1208 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1218 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1219 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1220 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1230 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1233 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1645 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1652 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1655 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1662 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1675 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1685 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1686 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1696 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1697 ac->ac_max_block, res); in ocfs2_search_one_group()
1705 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1713 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1716 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1727 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1742 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1752 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1755 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1759 chain = ac->ac_chain; in ocfs2_search_chain()
1776 while ((status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1778 ac->ac_max_block, in ocfs2_search_chain()
1810 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1831 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1835 ac->ac_bh, group_bh, in ocfs2_search_chain()
1843 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1847 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1862 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1883 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1892 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1896 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1897 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1898 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1900 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1908 ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1924 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1937 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
1939 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1956 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
1963 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
1964 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1982 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
1984 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
1994 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
2004 BUG_ON(!ac); in ocfs2_claim_metadata()
2005 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
2006 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
2008 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2017 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2022 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2033 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2047 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2048 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2049 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2051 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2053 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2060 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2062 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2063 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2068 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2075 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2076 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2077 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2078 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2087 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2106 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2108 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2114 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2129 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2136 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2139 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2149 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2159 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2160 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2168 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2174 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2175 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2183 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2189 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2190 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2201 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2209 BUG_ON(!ac); in ocfs2_claim_new_inode()
2210 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2211 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2212 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2214 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2216 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2225 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2232 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2233 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2303 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2312 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2314 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2316 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2317 && ac->ac_which != OCFS2_AC_USE_MAIN); in __ocfs2_claim_clusters()
2319 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2324 ac, in __ocfs2_claim_clusters()
2344 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2352 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2365 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2374 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2379 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2381 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()