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