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()
702 ac->ac_which = OCFS2_AC_USE_MAIN_DISCONTIG; in ocfs2_block_group_alloc()
705 ac, cl); in ocfs2_block_group_alloc()
752 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
758 if (ac) in ocfs2_block_group_alloc()
759 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
769 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
776 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
799 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
800 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
835 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
851 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
917 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
934 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
943 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
950 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
952 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
956 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
958 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
963 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
968 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
969 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
975 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
976 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
977 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
984 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
1000 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
1003 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1013 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1014 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1015 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1025 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1029 ac); in ocfs2_reserve_new_metadata()
1033 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1039 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1040 if (!(*ac)) { in ocfs2_reserve_new_inode()
1046 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1047 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1049 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1057 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1074 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1101 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1104 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1114 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1115 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1116 *ac = NULL; in ocfs2_reserve_new_inode()
1127 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1131 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1132 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1134 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1150 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1155 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1156 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1162 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1163 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1170 *ac); in ocfs2_reserve_clusters_with_limit()
1179 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1183 ocfs2_inode_unlock((*ac)->ac_inode, 1); in ocfs2_reserve_clusters_with_limit()
1184 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1188 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1189 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1196 inode_lock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1197 ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1); in ocfs2_reserve_clusters_with_limit()
1200 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1201 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1202 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1215 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1216 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1217 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1227 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1230 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1692 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1699 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1702 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1709 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1722 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1732 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1733 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1743 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1744 ac->ac_max_block, res); in ocfs2_search_one_group()
1752 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1760 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1763 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1775 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1790 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1801 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1804 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1808 chain = ac->ac_chain; in ocfs2_search_chain()
1826 if (ac->ac_which == OCFS2_AC_USE_MAIN_DISCONTIG) { in ocfs2_search_chain()
1835 status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1837 ac->ac_max_block, res); in ocfs2_search_chain()
1870 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1891 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1895 ac->ac_bh, group_bh, in ocfs2_search_chain()
1903 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1907 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1924 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1945 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1954 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1958 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1959 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1960 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1962 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1970 status = ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1984 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1997 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
2000 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
2003 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) in ocfs2_claim_suballoc_bits()
2020 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
2027 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
2028 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
2044 status == -ENOSPC && ac->ac_which == OCFS2_AC_USE_MAIN) { in ocfs2_claim_suballoc_bits()
2045 ac->ac_which = OCFS2_AC_USE_MAIN_DISCONTIG; in ocfs2_claim_suballoc_bits()
2046 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
2056 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
2058 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
2068 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
2078 BUG_ON(!ac); in ocfs2_claim_metadata()
2079 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
2080 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
2082 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2091 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2096 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2107 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2121 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2122 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2123 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2125 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2127 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2134 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2136 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2137 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2142 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2149 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2150 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2151 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2152 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2161 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2180 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2182 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2188 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2203 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2210 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2213 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2223 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2233 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2234 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2242 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2250 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2251 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2259 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2265 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2266 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2277 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2285 BUG_ON(!ac); in ocfs2_claim_new_inode()
2286 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2287 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2288 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2290 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2292 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2301 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2308 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2309 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2379 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2388 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2390 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2392 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2393 && ac->ac_which != OCFS2_AC_USE_MAIN in __ocfs2_claim_clusters()
2394 && ac->ac_which != OCFS2_AC_USE_MAIN_DISCONTIG); in __ocfs2_claim_clusters()
2396 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2401 ac, in __ocfs2_claim_clusters()
2421 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2429 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2442 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2451 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2456 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2458 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()