Lines Matching refs:pa

763 		struct ext4_prealloc_space *pa;  in __mb_check_buddy()  local
764 pa = list_entry(cur, struct ext4_prealloc_space, pa_group_list); in __mb_check_buddy()
765 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &groupnr, &k); in __mb_check_buddy()
767 for (i = 0; i < pa->pa_len; i++) in __mb_check_buddy()
3740 struct ext4_prealloc_space *pa; in ext4_mb_cleanup_pa() local
3745 pa = list_entry(cur, struct ext4_prealloc_space, pa_group_list); in ext4_mb_cleanup_pa()
3746 list_del(&pa->pa_group_list); in ext4_mb_cleanup_pa()
3748 kmem_cache_free(ext4_pspace_cachep, pa); in ext4_mb_cleanup_pa()
4640 struct ext4_prealloc_space *pa = ac->ac_pa; in ext4_discard_allocated_blocks() local
4644 if (pa == NULL) { in ext4_discard_allocated_blocks()
4663 if (pa->pa_type == MB_INODE_PA) { in ext4_discard_allocated_blocks()
4664 spin_lock(&pa->pa_lock); in ext4_discard_allocated_blocks()
4665 pa->pa_free += ac->ac_b_ex.fe_len; in ext4_discard_allocated_blocks()
4666 spin_unlock(&pa->pa_lock); in ext4_discard_allocated_blocks()
4674 struct ext4_prealloc_space *pa) in ext4_mb_use_inode_pa() argument
4682 start = pa->pa_pstart + (ac->ac_o_ex.fe_logical - pa->pa_lstart); in ext4_mb_use_inode_pa()
4683 end = min(pa->pa_pstart + EXT4_C2B(sbi, pa->pa_len), in ext4_mb_use_inode_pa()
4690 ac->ac_pa = pa; in ext4_mb_use_inode_pa()
4692 BUG_ON(start < pa->pa_pstart); in ext4_mb_use_inode_pa()
4693 BUG_ON(end > pa->pa_pstart + EXT4_C2B(sbi, pa->pa_len)); in ext4_mb_use_inode_pa()
4694 BUG_ON(pa->pa_free < len); in ext4_mb_use_inode_pa()
4696 pa->pa_free -= len; in ext4_mb_use_inode_pa()
4698 mb_debug(ac->ac_sb, "use %llu/%d from inode pa %p\n", start, len, pa); in ext4_mb_use_inode_pa()
4705 struct ext4_prealloc_space *pa) in ext4_mb_use_group_pa() argument
4709 ext4_get_group_no_and_offset(ac->ac_sb, pa->pa_pstart, in ext4_mb_use_group_pa()
4714 ac->ac_pa = pa; in ext4_mb_use_group_pa()
4723 pa->pa_lstart, len, pa); in ext4_mb_use_group_pa()
4734 struct ext4_prealloc_space *pa, in ext4_mb_check_group_pa() argument
4740 atomic_inc(&pa->pa_count); in ext4_mb_check_group_pa()
4741 return pa; in ext4_mb_check_group_pa()
4744 new_distance = abs(goal_block - pa->pa_pstart); in ext4_mb_check_group_pa()
4751 atomic_inc(&pa->pa_count); in ext4_mb_check_group_pa()
4752 return pa; in ext4_mb_check_group_pa()
4760 struct ext4_prealloc_space *pa) in ext4_mb_pa_goal_check() argument
4774 start = pa->pa_pstart + in ext4_mb_pa_goal_check()
4775 (ac->ac_g_ex.fe_logical - pa->pa_lstart); in ext4_mb_pa_goal_check()
4779 if (ac->ac_g_ex.fe_len > pa->pa_len - in ext4_mb_pa_goal_check()
4780 EXT4_B2C(sbi, ac->ac_g_ex.fe_logical - pa->pa_lstart)) in ext4_mb_pa_goal_check()
4999 struct ext4_prealloc_space *pa; in ext4_mb_generate_from_pa() local
5018 pa = list_entry(cur, struct ext4_prealloc_space, pa_group_list); in ext4_mb_generate_from_pa()
5019 spin_lock(&pa->pa_lock); in ext4_mb_generate_from_pa()
5020 ext4_get_group_no_and_offset(sb, pa->pa_pstart, in ext4_mb_generate_from_pa()
5022 len = pa->pa_len; in ext4_mb_generate_from_pa()
5023 spin_unlock(&pa->pa_lock); in ext4_mb_generate_from_pa()
5034 struct ext4_prealloc_space *pa) in ext4_mb_mark_pa_deleted() argument
5038 if (pa->pa_deleted) { in ext4_mb_mark_pa_deleted()
5040 pa->pa_type, pa->pa_pstart, pa->pa_lstart, in ext4_mb_mark_pa_deleted()
5041 pa->pa_len); in ext4_mb_mark_pa_deleted()
5045 pa->pa_deleted = 1; in ext4_mb_mark_pa_deleted()
5047 if (pa->pa_type == MB_INODE_PA) { in ext4_mb_mark_pa_deleted()
5048 ei = EXT4_I(pa->pa_inode); in ext4_mb_mark_pa_deleted()
5053 static inline void ext4_mb_pa_free(struct ext4_prealloc_space *pa) in ext4_mb_pa_free() argument
5055 BUG_ON(!pa); in ext4_mb_pa_free()
5056 BUG_ON(atomic_read(&pa->pa_count)); in ext4_mb_pa_free()
5057 BUG_ON(pa->pa_deleted == 0); in ext4_mb_pa_free()
5058 kmem_cache_free(ext4_pspace_cachep, pa); in ext4_mb_pa_free()
5063 struct ext4_prealloc_space *pa; in ext4_mb_pa_callback() local
5065 pa = container_of(head, struct ext4_prealloc_space, u.pa_rcu); in ext4_mb_pa_callback()
5066 ext4_mb_pa_free(pa); in ext4_mb_pa_callback()
5074 struct super_block *sb, struct ext4_prealloc_space *pa) in ext4_mb_put_pa() argument
5081 spin_lock(&pa->pa_lock); in ext4_mb_put_pa()
5082 if (!atomic_dec_and_test(&pa->pa_count) || pa->pa_free != 0) { in ext4_mb_put_pa()
5083 spin_unlock(&pa->pa_lock); in ext4_mb_put_pa()
5087 if (pa->pa_deleted == 1) { in ext4_mb_put_pa()
5088 spin_unlock(&pa->pa_lock); in ext4_mb_put_pa()
5092 ext4_mb_mark_pa_deleted(sb, pa); in ext4_mb_put_pa()
5093 spin_unlock(&pa->pa_lock); in ext4_mb_put_pa()
5095 grp_blk = pa->pa_pstart; in ext4_mb_put_pa()
5100 if (pa->pa_type == MB_GROUP_PA) in ext4_mb_put_pa()
5120 list_del(&pa->pa_group_list); in ext4_mb_put_pa()
5123 if (pa->pa_type == MB_INODE_PA) { in ext4_mb_put_pa()
5124 write_lock(pa->pa_node_lock.inode_lock); in ext4_mb_put_pa()
5125 rb_erase(&pa->pa_node.inode_node, &ei->i_prealloc_node); in ext4_mb_put_pa()
5126 write_unlock(pa->pa_node_lock.inode_lock); in ext4_mb_put_pa()
5127 ext4_mb_pa_free(pa); in ext4_mb_put_pa()
5129 spin_lock(pa->pa_node_lock.lg_lock); in ext4_mb_put_pa()
5130 list_del_rcu(&pa->pa_node.lg_list); in ext4_mb_put_pa()
5131 spin_unlock(pa->pa_node_lock.lg_lock); in ext4_mb_put_pa()
5132 call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); in ext4_mb_put_pa()
5169 struct ext4_prealloc_space *pa; in ext4_mb_new_inode_pa() local
5179 pa = ac->ac_pa; in ext4_mb_new_inode_pa()
5224 pa->pa_lstart = ac->ac_b_ex.fe_logical; in ext4_mb_new_inode_pa()
5225 pa->pa_pstart = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); in ext4_mb_new_inode_pa()
5226 pa->pa_len = ac->ac_b_ex.fe_len; in ext4_mb_new_inode_pa()
5227 pa->pa_free = pa->pa_len; in ext4_mb_new_inode_pa()
5228 spin_lock_init(&pa->pa_lock); in ext4_mb_new_inode_pa()
5229 INIT_LIST_HEAD(&pa->pa_group_list); in ext4_mb_new_inode_pa()
5230 pa->pa_deleted = 0; in ext4_mb_new_inode_pa()
5231 pa->pa_type = MB_INODE_PA; in ext4_mb_new_inode_pa()
5233 mb_debug(sb, "new inode pa %p: %llu/%d for %u\n", pa, pa->pa_pstart, in ext4_mb_new_inode_pa()
5234 pa->pa_len, pa->pa_lstart); in ext4_mb_new_inode_pa()
5235 trace_ext4_mb_new_inode_pa(ac, pa); in ext4_mb_new_inode_pa()
5237 atomic_add(pa->pa_free, &sbi->s_mb_preallocated); in ext4_mb_new_inode_pa()
5238 ext4_mb_use_inode_pa(ac, pa); in ext4_mb_new_inode_pa()
5245 pa->pa_node_lock.inode_lock = &ei->i_prealloc_lock; in ext4_mb_new_inode_pa()
5246 pa->pa_inode = ac->ac_inode; in ext4_mb_new_inode_pa()
5248 list_add(&pa->pa_group_list, &grp->bb_prealloc_list); in ext4_mb_new_inode_pa()
5250 write_lock(pa->pa_node_lock.inode_lock); in ext4_mb_new_inode_pa()
5251 ext4_mb_pa_rb_insert(&ei->i_prealloc_node, &pa->pa_node.inode_node); in ext4_mb_new_inode_pa()
5252 write_unlock(pa->pa_node_lock.inode_lock); in ext4_mb_new_inode_pa()
5264 struct ext4_prealloc_space *pa; in ext4_mb_new_group_pa() local
5273 pa = ac->ac_pa; in ext4_mb_new_group_pa()
5275 pa->pa_pstart = ext4_grp_offs_to_block(sb, &ac->ac_b_ex); in ext4_mb_new_group_pa()
5276 pa->pa_lstart = pa->pa_pstart; in ext4_mb_new_group_pa()
5277 pa->pa_len = ac->ac_b_ex.fe_len; in ext4_mb_new_group_pa()
5278 pa->pa_free = pa->pa_len; in ext4_mb_new_group_pa()
5279 spin_lock_init(&pa->pa_lock); in ext4_mb_new_group_pa()
5280 INIT_LIST_HEAD(&pa->pa_node.lg_list); in ext4_mb_new_group_pa()
5281 INIT_LIST_HEAD(&pa->pa_group_list); in ext4_mb_new_group_pa()
5282 pa->pa_deleted = 0; in ext4_mb_new_group_pa()
5283 pa->pa_type = MB_GROUP_PA; in ext4_mb_new_group_pa()
5285 mb_debug(sb, "new group pa %p: %llu/%d for %u\n", pa, pa->pa_pstart, in ext4_mb_new_group_pa()
5286 pa->pa_len, pa->pa_lstart); in ext4_mb_new_group_pa()
5287 trace_ext4_mb_new_group_pa(ac, pa); in ext4_mb_new_group_pa()
5289 ext4_mb_use_group_pa(ac, pa); in ext4_mb_new_group_pa()
5290 atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated); in ext4_mb_new_group_pa()
5298 pa->pa_node_lock.lg_lock = &lg->lg_prealloc_lock; in ext4_mb_new_group_pa()
5299 pa->pa_inode = NULL; in ext4_mb_new_group_pa()
5301 list_add(&pa->pa_group_list, &grp->bb_prealloc_list); in ext4_mb_new_group_pa()
5327 struct ext4_prealloc_space *pa) in ext4_mb_release_inode_pa() argument
5338 BUG_ON(pa->pa_deleted == 0); in ext4_mb_release_inode_pa()
5339 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); in ext4_mb_release_inode_pa()
5340 grp_blk_start = pa->pa_pstart - EXT4_C2B(sbi, bit); in ext4_mb_release_inode_pa()
5341 BUG_ON(group != e4b->bd_group && pa->pa_len != 0); in ext4_mb_release_inode_pa()
5342 end = bit + pa->pa_len; in ext4_mb_release_inode_pa()
5355 trace_ext4_mb_release_inode_pa(pa, (grp_blk_start + in ext4_mb_release_inode_pa()
5358 mb_free_blocks(pa->pa_inode, e4b, bit, next - bit); in ext4_mb_release_inode_pa()
5361 if (free != pa->pa_free) { in ext4_mb_release_inode_pa()
5364 pa, (unsigned long) pa->pa_lstart, in ext4_mb_release_inode_pa()
5365 (unsigned long) pa->pa_pstart, in ext4_mb_release_inode_pa()
5366 pa->pa_len); in ext4_mb_release_inode_pa()
5368 free, pa->pa_free); in ext4_mb_release_inode_pa()
5381 struct ext4_prealloc_space *pa) in ext4_mb_release_group_pa() argument
5387 trace_ext4_mb_release_group_pa(sb, pa); in ext4_mb_release_group_pa()
5388 BUG_ON(pa->pa_deleted == 0); in ext4_mb_release_group_pa()
5389 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit); in ext4_mb_release_group_pa()
5390 if (unlikely(group != e4b->bd_group && pa->pa_len != 0)) { in ext4_mb_release_group_pa()
5392 e4b->bd_group, group, pa->pa_pstart); in ext4_mb_release_group_pa()
5395 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len); in ext4_mb_release_group_pa()
5396 atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded); in ext4_mb_release_group_pa()
5397 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len); in ext4_mb_release_group_pa()
5417 struct ext4_prealloc_space *pa, *tmp; in ext4_mb_discard_group_preallocations() local
5448 list_for_each_entry_safe(pa, tmp, in ext4_mb_discard_group_preallocations()
5450 spin_lock(&pa->pa_lock); in ext4_mb_discard_group_preallocations()
5451 if (atomic_read(&pa->pa_count)) { in ext4_mb_discard_group_preallocations()
5452 spin_unlock(&pa->pa_lock); in ext4_mb_discard_group_preallocations()
5456 if (pa->pa_deleted) { in ext4_mb_discard_group_preallocations()
5457 spin_unlock(&pa->pa_lock); in ext4_mb_discard_group_preallocations()
5462 ext4_mb_mark_pa_deleted(sb, pa); in ext4_mb_discard_group_preallocations()
5468 free += pa->pa_free; in ext4_mb_discard_group_preallocations()
5470 spin_unlock(&pa->pa_lock); in ext4_mb_discard_group_preallocations()
5472 list_del(&pa->pa_group_list); in ext4_mb_discard_group_preallocations()
5473 list_add(&pa->u.pa_tmp_list, &list); in ext4_mb_discard_group_preallocations()
5477 list_for_each_entry_safe(pa, tmp, &list, u.pa_tmp_list) { in ext4_mb_discard_group_preallocations()
5480 if (pa->pa_type == MB_GROUP_PA) { in ext4_mb_discard_group_preallocations()
5481 spin_lock(pa->pa_node_lock.lg_lock); in ext4_mb_discard_group_preallocations()
5482 list_del_rcu(&pa->pa_node.lg_list); in ext4_mb_discard_group_preallocations()
5483 spin_unlock(pa->pa_node_lock.lg_lock); in ext4_mb_discard_group_preallocations()
5485 write_lock(pa->pa_node_lock.inode_lock); in ext4_mb_discard_group_preallocations()
5486 ei = EXT4_I(pa->pa_inode); in ext4_mb_discard_group_preallocations()
5487 rb_erase(&pa->pa_node.inode_node, &ei->i_prealloc_node); in ext4_mb_discard_group_preallocations()
5488 write_unlock(pa->pa_node_lock.inode_lock); in ext4_mb_discard_group_preallocations()
5491 list_del(&pa->u.pa_tmp_list); in ext4_mb_discard_group_preallocations()
5493 if (pa->pa_type == MB_GROUP_PA) { in ext4_mb_discard_group_preallocations()
5494 ext4_mb_release_group_pa(&e4b, pa); in ext4_mb_discard_group_preallocations()
5495 call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); in ext4_mb_discard_group_preallocations()
5497 ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); in ext4_mb_discard_group_preallocations()
5498 ext4_mb_pa_free(pa); in ext4_mb_discard_group_preallocations()
5525 struct ext4_prealloc_space *pa, *tmp; in ext4_discard_preallocations() local
5552 pa = rb_entry(iter, struct ext4_prealloc_space, in ext4_discard_preallocations()
5554 BUG_ON(pa->pa_node_lock.inode_lock != &ei->i_prealloc_lock); in ext4_discard_preallocations()
5556 spin_lock(&pa->pa_lock); in ext4_discard_preallocations()
5557 if (atomic_read(&pa->pa_count)) { in ext4_discard_preallocations()
5560 spin_unlock(&pa->pa_lock); in ext4_discard_preallocations()
5569 if (pa->pa_deleted == 0) { in ext4_discard_preallocations()
5570 ext4_mb_mark_pa_deleted(sb, pa); in ext4_discard_preallocations()
5571 spin_unlock(&pa->pa_lock); in ext4_discard_preallocations()
5572 rb_erase(&pa->pa_node.inode_node, &ei->i_prealloc_node); in ext4_discard_preallocations()
5573 list_add(&pa->u.pa_tmp_list, &list); in ext4_discard_preallocations()
5579 spin_unlock(&pa->pa_lock); in ext4_discard_preallocations()
5599 list_for_each_entry_safe(pa, tmp, &list, u.pa_tmp_list) { in ext4_discard_preallocations()
5600 BUG_ON(pa->pa_type != MB_INODE_PA); in ext4_discard_preallocations()
5601 group = ext4_get_group_number(sb, pa->pa_pstart); in ext4_discard_preallocations()
5621 list_del(&pa->pa_group_list); in ext4_discard_preallocations()
5622 ext4_mb_release_inode_pa(&e4b, bitmap_bh, pa); in ext4_discard_preallocations()
5628 list_del(&pa->u.pa_tmp_list); in ext4_discard_preallocations()
5629 ext4_mb_pa_free(pa); in ext4_discard_preallocations()
5635 struct ext4_prealloc_space *pa; in ext4_mb_pa_alloc() local
5638 pa = kmem_cache_zalloc(ext4_pspace_cachep, GFP_NOFS); in ext4_mb_pa_alloc()
5639 if (!pa) in ext4_mb_pa_alloc()
5641 atomic_set(&pa->pa_count, 1); in ext4_mb_pa_alloc()
5642 ac->ac_pa = pa; in ext4_mb_pa_alloc()
5648 struct ext4_prealloc_space *pa = ac->ac_pa; in ext4_mb_pa_put_free() local
5650 BUG_ON(!pa); in ext4_mb_pa_put_free()
5652 WARN_ON(!atomic_dec_and_test(&pa->pa_count)); in ext4_mb_pa_put_free()
5658 pa->pa_deleted = 1; in ext4_mb_pa_put_free()
5659 ext4_mb_pa_free(pa); in ext4_mb_pa_put_free()
5674 struct ext4_prealloc_space *pa; in ext4_mb_show_pa() local
5682 pa = list_entry(cur, struct ext4_prealloc_space, in ext4_mb_show_pa()
5684 spin_lock(&pa->pa_lock); in ext4_mb_show_pa()
5685 ext4_get_group_no_and_offset(sb, pa->pa_pstart, in ext4_mb_show_pa()
5687 spin_unlock(&pa->pa_lock); in ext4_mb_show_pa()
5689 pa->pa_len); in ext4_mb_show_pa()
5860 struct ext4_prealloc_space *pa, *tmp; in ext4_mb_discard_lg_preallocations() local
5865 list_for_each_entry_rcu(pa, &lg->lg_prealloc_list[order], in ext4_mb_discard_lg_preallocations()
5868 spin_lock(&pa->pa_lock); in ext4_mb_discard_lg_preallocations()
5869 if (atomic_read(&pa->pa_count)) { in ext4_mb_discard_lg_preallocations()
5875 spin_unlock(&pa->pa_lock); in ext4_mb_discard_lg_preallocations()
5878 if (pa->pa_deleted) { in ext4_mb_discard_lg_preallocations()
5879 spin_unlock(&pa->pa_lock); in ext4_mb_discard_lg_preallocations()
5883 BUG_ON(pa->pa_type != MB_GROUP_PA); in ext4_mb_discard_lg_preallocations()
5886 ext4_mb_mark_pa_deleted(sb, pa); in ext4_mb_discard_lg_preallocations()
5887 spin_unlock(&pa->pa_lock); in ext4_mb_discard_lg_preallocations()
5889 list_del_rcu(&pa->pa_node.lg_list); in ext4_mb_discard_lg_preallocations()
5890 list_add(&pa->u.pa_tmp_list, &discard_list); in ext4_mb_discard_lg_preallocations()
5905 list_for_each_entry_safe(pa, tmp, &discard_list, u.pa_tmp_list) { in ext4_mb_discard_lg_preallocations()
5908 group = ext4_get_group_number(sb, pa->pa_pstart); in ext4_mb_discard_lg_preallocations()
5917 list_del(&pa->pa_group_list); in ext4_mb_discard_lg_preallocations()
5918 ext4_mb_release_group_pa(&e4b, pa); in ext4_mb_discard_lg_preallocations()
5922 list_del(&pa->u.pa_tmp_list); in ext4_mb_discard_lg_preallocations()
5923 call_rcu(&(pa)->u.pa_rcu, ext4_mb_pa_callback); in ext4_mb_discard_lg_preallocations()
5941 struct ext4_prealloc_space *tmp_pa, *pa = ac->ac_pa; in ext4_mb_add_n_trim() local
5943 order = fls(pa->pa_free) - 1; in ext4_mb_add_n_trim()
5957 if (!added && pa->pa_free < tmp_pa->pa_free) { in ext4_mb_add_n_trim()
5959 list_add_tail_rcu(&pa->pa_node.lg_list, in ext4_mb_add_n_trim()
5971 list_add_tail_rcu(&pa->pa_node.lg_list, in ext4_mb_add_n_trim()
5987 struct ext4_prealloc_space *pa = ac->ac_pa; in ext4_mb_release_context() local
5988 if (pa) { in ext4_mb_release_context()
5989 if (pa->pa_type == MB_GROUP_PA) { in ext4_mb_release_context()
5991 spin_lock(&pa->pa_lock); in ext4_mb_release_context()
5992 pa->pa_pstart += EXT4_C2B(sbi, ac->ac_b_ex.fe_len); in ext4_mb_release_context()
5993 pa->pa_lstart += EXT4_C2B(sbi, ac->ac_b_ex.fe_len); in ext4_mb_release_context()
5994 pa->pa_free -= ac->ac_b_ex.fe_len; in ext4_mb_release_context()
5995 pa->pa_len -= ac->ac_b_ex.fe_len; in ext4_mb_release_context()
5996 spin_unlock(&pa->pa_lock); in ext4_mb_release_context()
6004 if (likely(pa->pa_free)) { in ext4_mb_release_context()
6005 spin_lock(pa->pa_node_lock.lg_lock); in ext4_mb_release_context()
6006 list_del_rcu(&pa->pa_node.lg_list); in ext4_mb_release_context()
6007 spin_unlock(pa->pa_node_lock.lg_lock); in ext4_mb_release_context()
6012 ext4_mb_put_pa(ac, ac->ac_sb, pa); in ext4_mb_release_context()