• Home
  • Raw
  • Download

Lines Matching +full:1 +full:ac

93 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac,
118 struct ocfs2_alloc_context **ac);
120 void ocfs2_free_ac_resource(struct ocfs2_alloc_context *ac) in ocfs2_free_ac_resource() argument
122 struct inode *inode = ac->ac_inode; in ocfs2_free_ac_resource()
125 if (ac->ac_which != OCFS2_AC_USE_LOCAL) in ocfs2_free_ac_resource()
126 ocfs2_inode_unlock(inode, 1); in ocfs2_free_ac_resource()
131 ac->ac_inode = NULL; in ocfs2_free_ac_resource()
133 brelse(ac->ac_bh); in ocfs2_free_ac_resource()
134 ac->ac_bh = NULL; in ocfs2_free_ac_resource()
135 ac->ac_resv = NULL; in ocfs2_free_ac_resource()
136 kfree(ac->ac_find_loc_priv); in ocfs2_free_ac_resource()
137 ac->ac_find_loc_priv = NULL; in ocfs2_free_ac_resource()
140 void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) in ocfs2_free_alloc_context() argument
142 ocfs2_free_ac_resource(ac); in ocfs2_free_alloc_context()
143 kfree(ac); in ocfs2_free_alloc_context()
261 rc = ocfs2_validate_gd_self(sb, bh, 1); in ocfs2_check_group_descriptor()
263 rc = ocfs2_validate_gd_parent(sb, di, bh, 1); in ocfs2_check_group_descriptor()
339 le16_add_cpu(&el->l_next_free_rec, 1); in ocfs2_bg_discontig_add_extent()
375 bg->bg_size = cpu_to_le16(ocfs2_group_bitmap_size(sb, 1, in ocfs2_block_group_fill()
387 /* set the 1st bit in the bitmap to account for the descriptor block */ in ocfs2_block_group_fill()
389 bg->bg_free_bits_count = cpu_to_le16(le16_to_cpu(bg->bg_bits) - 1); in ocfs2_block_group_fill()
421 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_contig() argument
430 status = ocfs2_claim_clusters(handle, ac, in ocfs2_block_group_alloc_contig()
465 struct ocfs2_alloc_context *ac, in ocfs2_block_group_claim_bits() argument
472 status = ocfs2_claim_clusters(handle, ac, min_bits, in ocfs2_block_group_claim_bits()
477 min_bits >>= 1; in ocfs2_block_group_claim_bits()
486 struct ocfs2_alloc_context *ac, in ocfs2_block_group_grow_discontig() argument
513 status = ocfs2_block_group_claim_bits(osb, handle, ac, in ocfs2_block_group_grow_discontig()
578 struct ocfs2_alloc_context *ac, in ocfs2_block_group_alloc_discontig() argument
584 unsigned int min_bits = le16_to_cpu(cl->cl_cpg) >> 1; in ocfs2_block_group_alloc_discontig()
607 ac->ac_disable_chain_relink = 1; in ocfs2_block_group_alloc_discontig()
610 status = ocfs2_block_group_claim_bits(osb, handle, ac, min_bits, in ocfs2_block_group_alloc_discontig()
640 bg_bh, ac, cl, min_bits); in ocfs2_block_group_alloc_discontig()
646 ocfs2_bg_alloc_cleanup(handle, ac, alloc_inode, bg_bh); in ocfs2_block_group_alloc_discontig()
663 struct ocfs2_alloc_context *ac = NULL; in ocfs2_block_group_alloc() local
674 max_block, flags, &ac); in ocfs2_block_group_alloc()
694 ac->ac_last_group = *last_alloc_group; in ocfs2_block_group_alloc()
698 ac, cl); in ocfs2_block_group_alloc()
702 ac, cl); in ocfs2_block_group_alloc()
726 le16_add_cpu(&cl->cl_next_free_rec, 1); in ocfs2_block_group_alloc()
748 *last_alloc_group = ac->ac_last_group; in ocfs2_block_group_alloc()
754 if (ac) in ocfs2_block_group_alloc()
755 ocfs2_free_alloc_context(ac); in ocfs2_block_group_alloc()
765 struct ocfs2_alloc_context *ac, in ocfs2_reserve_suballoc_bits() argument
772 u32 bits_wanted = ac->ac_bits_wanted; in ocfs2_reserve_suballoc_bits()
786 status = ocfs2_inode_lock(alloc_inode, &bh, 1); in ocfs2_reserve_suballoc_bits()
795 ac->ac_inode = alloc_inode; in ocfs2_reserve_suballoc_bits()
796 ac->ac_alloc_slot = slot; in ocfs2_reserve_suballoc_bits()
831 ac->ac_max_block, in ocfs2_reserve_suballoc_bits()
847 ac->ac_bh = bh; in ocfs2_reserve_suballoc_bits()
913 struct ocfs2_alloc_context *ac, in ocfs2_steal_resource() argument
921 slot = osb->slot_num + 1; in ocfs2_steal_resource()
930 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_steal_resource()
939 ocfs2_free_ac_resource(ac); in ocfs2_steal_resource()
946 struct ocfs2_alloc_context *ac) in ocfs2_steal_inode() argument
948 return ocfs2_steal_resource(osb, ac, INODE_ALLOC_SYSTEM_INODE); in ocfs2_steal_inode()
952 struct ocfs2_alloc_context *ac) in ocfs2_steal_meta() argument
954 return ocfs2_steal_resource(osb, ac, EXTENT_ALLOC_SYSTEM_INODE); in ocfs2_steal_meta()
959 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata_blocks() argument
964 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_metadata_blocks()
965 if (!(*ac)) { in ocfs2_reserve_new_metadata_blocks()
971 (*ac)->ac_bits_wanted = blocks; in ocfs2_reserve_new_metadata_blocks()
972 (*ac)->ac_which = OCFS2_AC_USE_META; in ocfs2_reserve_new_metadata_blocks()
973 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_metadata_blocks()
980 status = ocfs2_reserve_suballoc_bits(osb, (*ac), in ocfs2_reserve_new_metadata_blocks()
996 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_metadata_blocks()
999 status = ocfs2_steal_meta(osb, *ac); in ocfs2_reserve_new_metadata_blocks()
1009 if ((status < 0) && *ac) { in ocfs2_reserve_new_metadata_blocks()
1010 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_metadata_blocks()
1011 *ac = NULL; in ocfs2_reserve_new_metadata_blocks()
1021 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_metadata() argument
1025 ac); in ocfs2_reserve_new_metadata()
1029 struct ocfs2_alloc_context **ac) in ocfs2_reserve_new_inode() argument
1035 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_new_inode()
1036 if (!(*ac)) { in ocfs2_reserve_new_inode()
1042 (*ac)->ac_bits_wanted = 1; in ocfs2_reserve_new_inode()
1043 (*ac)->ac_which = OCFS2_AC_USE_INODE; in ocfs2_reserve_new_inode()
1045 (*ac)->ac_group_search = ocfs2_block_group_search; in ocfs2_reserve_new_inode()
1053 (*ac)->ac_max_block = (u32)~0U; in ocfs2_reserve_new_inode()
1058 * 1. when we flush the truncate log in ocfs2_reserve_new_inode()
1070 status = ocfs2_reserve_suballoc_bits(osb, *ac, in ocfs2_reserve_new_inode()
1097 ocfs2_free_ac_resource(*ac); in ocfs2_reserve_new_inode()
1100 status = ocfs2_steal_inode(osb, *ac); in ocfs2_reserve_new_inode()
1110 if ((status < 0) && *ac) { in ocfs2_reserve_new_inode()
1111 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_new_inode()
1112 *ac = NULL; in ocfs2_reserve_new_inode()
1123 struct ocfs2_alloc_context *ac) in ocfs2_reserve_cluster_bitmap_bits() argument
1127 ac->ac_which = OCFS2_AC_USE_MAIN; in ocfs2_reserve_cluster_bitmap_bits()
1128 ac->ac_group_search = ocfs2_cluster_group_search; in ocfs2_reserve_cluster_bitmap_bits()
1130 status = ocfs2_reserve_suballoc_bits(osb, ac, in ocfs2_reserve_cluster_bitmap_bits()
1146 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters_with_limit() argument
1151 *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); in ocfs2_reserve_clusters_with_limit()
1152 if (!(*ac)) { in ocfs2_reserve_clusters_with_limit()
1158 (*ac)->ac_bits_wanted = bits_wanted; in ocfs2_reserve_clusters_with_limit()
1159 (*ac)->ac_max_block = max_block; in ocfs2_reserve_clusters_with_limit()
1166 *ac); in ocfs2_reserve_clusters_with_limit()
1175 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); in ocfs2_reserve_clusters_with_limit()
1178 retried = 1; in ocfs2_reserve_clusters_with_limit()
1179 ocfs2_inode_unlock((*ac)->ac_inode, 1); in ocfs2_reserve_clusters_with_limit()
1180 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1183 if (ret == 1) { in ocfs2_reserve_clusters_with_limit()
1184 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1185 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1192 inode_lock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1193 ret = ocfs2_inode_lock((*ac)->ac_inode, NULL, 1); in ocfs2_reserve_clusters_with_limit()
1196 inode_unlock((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1197 iput((*ac)->ac_inode); in ocfs2_reserve_clusters_with_limit()
1198 (*ac)->ac_inode = NULL; in ocfs2_reserve_clusters_with_limit()
1211 if ((status < 0) && *ac) { in ocfs2_reserve_clusters_with_limit()
1212 ocfs2_free_alloc_context(*ac); in ocfs2_reserve_clusters_with_limit()
1213 *ac = NULL; in ocfs2_reserve_clusters_with_limit()
1223 struct ocfs2_alloc_context **ac) in ocfs2_reserve_clusters() argument
1226 ALLOC_NEW_GROUP, ac); in ocfs2_reserve_clusters()
1263 return 1; in ocfs2_test_bg_bit_allocatable()
1270 ret = 1; in ocfs2_test_bg_bit_allocatable()
1295 while((offset = ocfs2_find_next_zero_bit(bitmap, total_bits, start)) != -1) { in ocfs2_block_group_find_clear_bits()
1303 start = offset + 1; in ocfs2_block_group_find_clear_bits()
1311 found = 1; in ocfs2_block_group_find_clear_bits()
1312 start = offset + 1; in ocfs2_block_group_find_clear_bits()
1557 BUG_ON(min_bits != 1); in ocfs2_block_group_search()
1637 return 1; in ocfs2_bg_discontig_fix_by_rec()
1640 static void ocfs2_bg_discontig_fix_result(struct ocfs2_alloc_context *ac, in ocfs2_bg_discontig_fix_result() argument
1647 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_bg_discontig_fix_result()
1650 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) { in ocfs2_bg_discontig_fix_result()
1657 if (!ocfs2_supports_discontig_bg(OCFS2_SB(ac->ac_inode->i_sb)) || in ocfs2_bg_discontig_fix_result()
1670 static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, in ocfs2_search_one_group() argument
1680 struct ocfs2_dinode *di = (struct ocfs2_dinode *)ac->ac_bh->b_data; in ocfs2_search_one_group()
1681 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_one_group()
1691 ret = ac->ac_group_search(alloc_inode, group_bh, bits_wanted, min_bits, in ocfs2_search_one_group()
1692 ac->ac_max_block, res); in ocfs2_search_one_group()
1700 ocfs2_bg_discontig_fix_result(ac, gd, res); in ocfs2_search_one_group()
1708 if (ac->ac_find_loc_only) in ocfs2_search_one_group()
1711 ret = ocfs2_alloc_dinode_update_counts(alloc_inode, handle, ac->ac_bh, in ocfs2_search_one_group()
1722 ocfs2_rollback_alloc_dinode_counts(alloc_inode, ac->ac_bh, in ocfs2_search_one_group()
1737 static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, in ocfs2_search_chain() argument
1747 struct inode *alloc_inode = ac->ac_inode; in ocfs2_search_chain()
1750 struct ocfs2_dinode *fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_search_chain()
1754 chain = ac->ac_chain; in ocfs2_search_chain()
1770 * the 1st group with any empty bits. */ in ocfs2_search_chain()
1771 while ((status = ac->ac_group_search(alloc_inode, group_bh, in ocfs2_search_chain()
1773 ac->ac_max_block, in ocfs2_search_chain()
1805 ocfs2_bg_discontig_fix_result(ac, bg, res); in ocfs2_search_chain()
1826 if (!ac->ac_disable_chain_relink && in ocfs2_search_chain()
1830 ac->ac_bh, group_bh, in ocfs2_search_chain()
1838 if (ac->ac_find_loc_only) in ocfs2_search_chain()
1842 ac->ac_bh, res->sr_bits, in ocfs2_search_chain()
1857 ac->ac_bh, res->sr_bits, chain); in ocfs2_search_chain()
1878 static int ocfs2_claim_suballoc_bits(struct ocfs2_alloc_context *ac, in ocfs2_claim_suballoc_bits() argument
1887 u64 hint = ac->ac_last_group; in ocfs2_claim_suballoc_bits()
1891 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in ocfs2_claim_suballoc_bits()
1892 BUG_ON(bits_wanted > (ac->ac_bits_wanted - ac->ac_bits_given)); in ocfs2_claim_suballoc_bits()
1893 BUG_ON(!ac->ac_bh); in ocfs2_claim_suballoc_bits()
1895 fe = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_suballoc_bits()
1903 status = ocfs2_error(ac->ac_inode->i_sb, in ocfs2_claim_suballoc_bits()
1917 status = ocfs2_search_one_group(ac, handle, bits_wanted, in ocfs2_claim_suballoc_bits()
1930 ac->ac_chain = victim; in ocfs2_claim_suballoc_bits()
1932 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1935 if (ocfs2_is_cluster_bitmap(ac->ac_inode)) in ocfs2_claim_suballoc_bits()
1952 ac->ac_disable_chain_relink = 1; in ocfs2_claim_suballoc_bits()
1959 ac->ac_chain = i; in ocfs2_claim_suballoc_bits()
1960 status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, in ocfs2_claim_suballoc_bits()
1978 ac->ac_last_group = 0; in ocfs2_claim_suballoc_bits()
1980 ac->ac_last_group = hint; in ocfs2_claim_suballoc_bits()
1990 struct ocfs2_alloc_context *ac, in ocfs2_claim_metadata() argument
2000 BUG_ON(!ac); in ocfs2_claim_metadata()
2001 BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); in ocfs2_claim_metadata()
2002 BUG_ON(ac->ac_which != OCFS2_AC_USE_META); in ocfs2_claim_metadata()
2004 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_metadata()
2007 1, in ocfs2_claim_metadata()
2013 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_metadata()
2018 ac->ac_bits_given += res.sr_bits; in ocfs2_claim_metadata()
2029 struct ocfs2_alloc_context *ac) in ocfs2_init_inode_ac_group() argument
2043 OCFS2_I(dir)->ip_last_used_slot == ac->ac_alloc_slot) in ocfs2_init_inode_ac_group()
2044 ac->ac_last_group = OCFS2_I(dir)->ip_last_used_group; in ocfs2_init_inode_ac_group()
2045 else if (le16_to_cpu(di->i_suballoc_slot) == ac->ac_alloc_slot) { in ocfs2_init_inode_ac_group()
2047 ac->ac_last_group = le64_to_cpu(di->i_suballoc_loc); in ocfs2_init_inode_ac_group()
2049 ac->ac_last_group = ocfs2_which_suballoc_group( in ocfs2_init_inode_ac_group()
2056 struct ocfs2_alloc_context *ac) in ocfs2_save_inode_ac_group() argument
2058 OCFS2_I(dir)->ip_last_used_group = ac->ac_last_group; in ocfs2_save_inode_ac_group()
2059 OCFS2_I(dir)->ip_last_used_slot = ac->ac_alloc_slot; in ocfs2_save_inode_ac_group()
2064 struct ocfs2_alloc_context *ac, in ocfs2_find_new_inode_loc() argument
2071 BUG_ON(!ac); in ocfs2_find_new_inode_loc()
2072 BUG_ON(ac->ac_bits_given != 0); in ocfs2_find_new_inode_loc()
2073 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_find_new_inode_loc()
2074 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_find_new_inode_loc()
2083 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_find_new_inode_loc()
2102 ac->ac_find_loc_only = 1; in ocfs2_find_new_inode_loc()
2104 ret = ocfs2_claim_suballoc_bits(ac, handle, 1, 1, res); in ocfs2_find_new_inode_loc()
2110 ac->ac_find_loc_priv = res; in ocfs2_find_new_inode_loc()
2125 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode_at_loc() argument
2132 struct ocfs2_suballoc_result *res = ac->ac_find_loc_priv; in ocfs2_claim_new_inode_at_loc()
2135 struct ocfs2_dinode *di = (struct ocfs2_dinode *) ac->ac_bh->b_data; in ocfs2_claim_new_inode_at_loc()
2145 ret = ocfs2_read_group_descriptor(ac->ac_inode, di, in ocfs2_claim_new_inode_at_loc()
2155 ret = ocfs2_alloc_dinode_update_counts(ac->ac_inode, handle, in ocfs2_claim_new_inode_at_loc()
2156 ac->ac_bh, res->sr_bits, in ocfs2_claim_new_inode_at_loc()
2164 ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2170 ocfs2_rollback_alloc_dinode_counts(ac->ac_inode, in ocfs2_claim_new_inode_at_loc()
2171 ac->ac_bh, res->sr_bits, chain); in ocfs2_claim_new_inode_at_loc()
2179 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode_at_loc()
2181 BUG_ON(res->sr_bits != 1); in ocfs2_claim_new_inode_at_loc()
2185 ac->ac_bits_given++; in ocfs2_claim_new_inode_at_loc()
2186 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode_at_loc()
2197 struct ocfs2_alloc_context *ac, in ocfs2_claim_new_inode() argument
2205 BUG_ON(!ac); in ocfs2_claim_new_inode()
2206 BUG_ON(ac->ac_bits_given != 0); in ocfs2_claim_new_inode()
2207 BUG_ON(ac->ac_bits_wanted != 1); in ocfs2_claim_new_inode()
2208 BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); in ocfs2_claim_new_inode()
2210 ocfs2_init_inode_ac_group(dir, parent_fe_bh, ac); in ocfs2_claim_new_inode()
2212 status = ocfs2_claim_suballoc_bits(ac, in ocfs2_claim_new_inode()
2214 1, in ocfs2_claim_new_inode()
2215 1, in ocfs2_claim_new_inode()
2221 atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs); in ocfs2_claim_new_inode()
2223 BUG_ON(res.sr_bits != 1); in ocfs2_claim_new_inode()
2228 ac->ac_bits_given++; in ocfs2_claim_new_inode()
2229 ocfs2_save_inode_ac_group(dir, ac); in ocfs2_claim_new_inode()
2295 * contig. allocation, set to '1' to indicate we can deal with extents
2299 struct ocfs2_alloc_context *ac, in __ocfs2_claim_clusters() argument
2308 struct ocfs2_super *osb = OCFS2_SB(ac->ac_inode->i_sb); in __ocfs2_claim_clusters()
2310 BUG_ON(ac->ac_bits_given >= ac->ac_bits_wanted); in __ocfs2_claim_clusters()
2312 BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL in __ocfs2_claim_clusters()
2313 && ac->ac_which != OCFS2_AC_USE_MAIN); in __ocfs2_claim_clusters()
2315 if (ac->ac_which == OCFS2_AC_USE_LOCAL) { in __ocfs2_claim_clusters()
2316 WARN_ON(min_clusters > 1); in __ocfs2_claim_clusters()
2320 ac, in __ocfs2_claim_clusters()
2327 if (min_clusters > (osb->bitmap_cpg - 1)) { in __ocfs2_claim_clusters()
2337 if (bits_wanted > (osb->bitmap_cpg - 1)) in __ocfs2_claim_clusters()
2338 bits_wanted = osb->bitmap_cpg - 1; in __ocfs2_claim_clusters()
2340 status = ocfs2_claim_suballoc_bits(ac, in __ocfs2_claim_clusters()
2348 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode, in __ocfs2_claim_clusters()
2361 ac->ac_bits_given += *num_clusters; in __ocfs2_claim_clusters()
2370 struct ocfs2_alloc_context *ac, in ocfs2_claim_clusters() argument
2375 unsigned int bits_wanted = ac->ac_bits_wanted - ac->ac_bits_given; in ocfs2_claim_clusters()
2377 return __ocfs2_claim_clusters(handle, ac, min_clusters, in ocfs2_claim_clusters()
2539 inode_alloc_bh, bit, bg_blkno, 1); in ocfs2_free_dinode()
2652 * Most of the time we'll only be seeing this 1 cluster at a time in ocfs2_lock_allocators()
2708 status = ocfs2_read_blocks_sync(osb, blkno, 1, &inode_bh); in ocfs2_get_suballoc_slot_bit()
2724 (u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots - 1) { in ocfs2_get_suballoc_slot_bit()
2749 * is returned and *res is 1 for SET; 0 otherwise. when fails, errno
2770 if ((bit + 1) > ocfs2_bits_per_group(&alloc_di->id2.i_chain)) { in ocfs2_test_suballoc_bit()
2803 * On success, 0 is returned and *res is 1 for SET; 0 otherwise.