Lines Matching refs:ac
91 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
116 struct ocfs2_alloc_context **ac);
118 void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) in ocfs2_free_ac_resource() argument
120 struct inode *inode = ac->ac_inode; in ocfs2_free_ac_resource()
123 if (ac->ac_which != OCFS2_AC_USE_LOCAL) in ocfs2_free_ac_resource()
129 ac->ac_inode = NULL; in ocfs2_free_ac_resource()
131 brelse(ac->ac_bh); in ocfs2_free_ac_resource()
132 ac->ac_bh = NULL; in ocfs2_free_ac_resource()
133 ac->ac_resv = NULL; in ocfs2_free_ac_resource()
134 kfree(ac->ac_find_loc_priv); in ocfs2_free_ac_resource()
135 ac->ac_find_loc_priv = NULL; in ocfs2_free_ac_resource()
138 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) in ocfs2_free_alloc_context() argument
140 ocfs2_free_ac_resource(ac); in ocfs2_free_alloc_context()
141 kfree(ac); in ocfs2_free_alloc_context()
419 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_contig() argument
428 status = ocfs2_claim_clusters(handle, ac, in ocfs2_block_group_alloc_contig()
463 struct ocfs2_alloc_context *ac, in ocfs2_block_group_claim_bits() argument
470 status = ocfs2_claim_clusters(handle, ac, min_bits, in ocfs2_block_group_claim_bits()
484 struct ocfs2_alloc_context *ac, in ocfs2_block_group_grow_discontig() argument
511 status = ocfs2_block_group_claim_bits(osb, handle, ac, in ocfs2_block_group_grow_discontig()
576 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_discontig() argument
605 ac->ac_disable_chain_relink = 1; in ocfs2_block_group_alloc_discontig()
608 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits, in ocfs2_block_group_alloc_discontig()
638 bg_bh, ac, cl, min_bits); in ocfs2_block_group_alloc_discontig()
644 ocfs2_bg_alloc_cleanup(handle, ac, alloc_inode, bg_bh); in ocfs2_block_group_alloc_discontig()
661 struct ocfs2_alloc_context *ac = NULL; in ocfs2_block_group_alloc() local
672 max_block, flags, &ac); in ocfs2_block_group_alloc()
692 ac->ac_last_group = *last_alloc_group; in ocfs2_block_group_alloc()
696 ac, cl); in ocfs2_block_group_alloc()
700 ac, cl); in ocfs2_block_group_alloc()
746 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
752 if (ac) in ocfs2_block_group_alloc()
753 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
763 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
770 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
793 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
794 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
829 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
845 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
911 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
928 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
937 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
944 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
946 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
950 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
952 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
957 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
962 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
963 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
969 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
970 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
971 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
978 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
994 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
997 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1007 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1008 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1009 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1019 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1023 ac); in ocfs2_reserve_new_metadata()
1027 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1033 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1034 if (!(*ac)) { in ocfs2_reserve_new_inode()
1040 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1041 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1043 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1051 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1068 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1095 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1098 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1108 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1109 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1110 *ac = NULL; in ocfs2_reserve_new_inode()
1121 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1125 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1126 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1128 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1144 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1149 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1150 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1156 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1157 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1164 *ac); in ocfs2_reserve_clusters_with_limit()
1173 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1177 ocfs2_inode_unlock((*ac)->ac_inode, 1); in ocfs2_reserve_clusters_with_limit()
1178 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1182 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1183 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1190 inode_lock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1191 ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1); in ocfs2_reserve_clusters_with_limit()
1194 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1195 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1196 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1209 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1210 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1211 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1221 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1224 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1638 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1645 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1648 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1655 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1668 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1678 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1679 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1689 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1690 ac->ac_max_block, res); in ocfs2_search_one_group()
1698 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1706 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1709 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1720 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1735 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1745 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1748 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1752 chain = ac->ac_chain; in ocfs2_search_chain()
1769 while ((status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1771 ac->ac_max_block, in ocfs2_search_chain()
1803 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1824 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1828 ac->ac_bh, group_bh, in ocfs2_search_chain()
1836 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1840 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1855 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1876 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1885 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1889 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1890 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1891 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1893 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1901 status = ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1915 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1928 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
1930 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1933 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) in ocfs2_claim_suballoc_bits()
1950 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
1957 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
1958 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1976 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
1978 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
1988 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
1998 BUG_ON(!ac); in ocfs2_claim_metadata()
1999 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
2000 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
2002 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2011 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2016 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2027 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2041 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2042 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2043 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2045 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2047 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2054 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2056 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2057 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2062 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2069 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2070 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2071 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2072 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2081 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2100 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2102 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2108 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2123 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2130 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2133 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2143 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2153 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2154 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2162 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2168 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2169 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2177 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2183 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2184 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2195 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2203 BUG_ON(!ac); in ocfs2_claim_new_inode()
2204 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2205 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2206 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2208 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2210 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2219 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2226 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2227 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2297 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2306 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2308 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2310 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2311 && ac->ac_which != OCFS2_AC_USE_MAIN); in __ocfs2_claim_clusters()
2313 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2318 ac, in __ocfs2_claim_clusters()
2338 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2346 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2359 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2368 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2373 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2375 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()