Lines Matching refs:path

137 				struct ext4_ext_path *path)  in ext4_ext_get_access()  argument
141 if (path->p_bh) { in ext4_ext_get_access()
143 BUFFER_TRACE(path->p_bh, "get_write_access"); in ext4_ext_get_access()
145 path->p_bh, EXT4_JTR_NONE); in ext4_ext_get_access()
153 clear_buffer_verified(path->p_bh); in ext4_ext_get_access()
168 struct ext4_ext_path *path) in __ext4_ext_dirty() argument
173 if (path->p_bh) { in __ext4_ext_dirty()
174 ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh)); in __ext4_ext_dirty()
177 inode, path->p_bh); in __ext4_ext_dirty()
180 set_buffer_verified(path->p_bh); in __ext4_ext_dirty()
188 #define ext4_ext_dirty(handle, inode, path) \ argument
189 __ext4_ext_dirty(__func__, __LINE__, (handle), (inode), (path))
192 struct ext4_ext_path *path, in ext4_ext_find_goal() argument
195 if (path) { in ext4_ext_find_goal()
196 int depth = path->p_depth; in ext4_ext_find_goal()
216 ex = path[depth].p_ext; in ext4_ext_find_goal()
229 if (path[depth].p_bh) in ext4_ext_find_goal()
230 return path[depth].p_bh->b_blocknr; in ext4_ext_find_goal()
242 struct ext4_ext_path *path, in ext4_ext_new_meta_block() argument
247 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); in ext4_ext_new_meta_block()
312 struct ext4_ext_path *path = *ppath; in ext4_force_split_extent_at() local
313 int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); in ext4_force_split_extent_at()
580 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
596 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_precache()
598 if (path == NULL) { in ext4_ext_precache()
603 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
604 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
607 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
614 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
615 brelse(path[i].p_bh); in ext4_ext_precache()
616 path[i].p_bh = NULL; in ext4_ext_precache()
620 bh = read_extent_tree_block(inode, path[i].p_idx++, in ext4_ext_precache()
628 path[i].p_bh = bh; in ext4_ext_precache()
629 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
630 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
635 ext4_ext_drop_refs(path); in ext4_ext_precache()
636 kfree(path); in ext4_ext_precache()
641 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
643 int k, l = path->p_depth; in ext4_ext_show_path()
646 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
647 if (path->p_idx) { in ext4_ext_show_path()
649 le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
650 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
651 } else if (path->p_ext) { in ext4_ext_show_path()
653 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
654 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
655 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
656 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
663 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
670 if (!path) in ext4_ext_show_leaf()
673 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
686 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
694 idx = path[level].p_idx; in ext4_ext_show_move()
695 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
705 ex = path[depth].p_ext; in ext4_ext_show_move()
706 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
718 #define ext4_ext_show_path(inode, path) argument
719 #define ext4_ext_show_leaf(inode, path) argument
720 #define ext4_ext_show_move(inode, path, newblock, level) argument
723 void ext4_ext_drop_refs(struct ext4_ext_path *path) in ext4_ext_drop_refs() argument
727 if (!path) in ext4_ext_drop_refs()
729 depth = path->p_depth; in ext4_ext_drop_refs()
730 for (i = 0; i <= depth; i++, path++) { in ext4_ext_drop_refs()
731 brelse(path->p_bh); in ext4_ext_drop_refs()
732 path->p_bh = NULL; in ext4_ext_drop_refs()
743 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
745 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
765 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
766 ext_debug(inode, " -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
767 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
791 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
804 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
806 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
834 path->p_ext = l - 1; in ext4_ext_binsearch()
836 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
837 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
838 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
839 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
854 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
879 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
896 if (path) { in ext4_find_extent()
897 ext4_ext_drop_refs(path); in ext4_find_extent()
898 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
899 kfree(path); in ext4_find_extent()
900 *orig_path = path = NULL; in ext4_find_extent()
903 if (!path) { in ext4_find_extent()
905 path = kcalloc(depth + 2, sizeof(struct ext4_ext_path), in ext4_find_extent()
907 if (unlikely(!path)) in ext4_find_extent()
909 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
911 path[0].p_hdr = eh; in ext4_find_extent()
912 path[0].p_bh = NULL; in ext4_find_extent()
922 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
923 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
924 path[ppos].p_depth = i; in ext4_find_extent()
925 path[ppos].p_ext = NULL; in ext4_find_extent()
927 bh = read_extent_tree_block(inode, path[ppos].p_idx, --i, flags); in ext4_find_extent()
935 path[ppos].p_bh = bh; in ext4_find_extent()
936 path[ppos].p_hdr = eh; in ext4_find_extent()
939 path[ppos].p_depth = i; in ext4_find_extent()
940 path[ppos].p_ext = NULL; in ext4_find_extent()
941 path[ppos].p_idx = NULL; in ext4_find_extent()
944 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
946 if (path[ppos].p_ext) in ext4_find_extent()
947 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
949 ext4_ext_show_path(inode, path); in ext4_find_extent()
951 return path; in ext4_find_extent()
954 ext4_ext_drop_refs(path); in ext4_find_extent()
955 kfree(path); in ext4_find_extent()
1046 struct ext4_ext_path *path, in ext4_ext_split() argument
1069 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1073 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1074 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1104 newblock = ext4_ext_new_meta_block(handle, inode, path, in ext4_ext_split()
1138 if (unlikely(path[depth].p_hdr->eh_entries != in ext4_ext_split()
1139 path[depth].p_hdr->eh_max)) { in ext4_ext_split()
1141 path[depth].p_hdr->eh_entries, in ext4_ext_split()
1142 path[depth].p_hdr->eh_max); in ext4_ext_split()
1147 m = EXT_MAX_EXTENT(path[depth].p_hdr) - path[depth].p_ext++; in ext4_ext_split()
1148 ext4_ext_show_move(inode, path, newblock, depth); in ext4_ext_split()
1152 memmove(ex, path[depth].p_ext, sizeof(struct ext4_extent) * m); in ext4_ext_split()
1172 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_split()
1175 le16_add_cpu(&path[depth].p_hdr->eh_entries, -m); in ext4_ext_split()
1176 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_split()
1223 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1224 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1227 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1232 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1233 ext_debug(inode, "cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1234 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1235 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1237 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1258 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1261 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1262 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1271 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1396 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1404 curp = path + depth; in ext4_ext_create_new_leaf()
1415 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1420 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1423 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1424 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1432 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1435 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1436 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1445 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1463 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1470 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1474 depth = path->p_depth; in ext4_ext_search_left()
1477 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1484 ex = path[depth].p_ext; in ext4_ext_search_left()
1487 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1494 ix = path[depth].p_idx; in ext4_ext_search_left()
1495 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1499 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? in ext4_ext_search_left()
1500 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, in ext4_ext_search_left()
1528 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1539 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1543 depth = path->p_depth; in ext4_ext_search_right()
1546 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1553 ex = path[depth].p_ext; in ext4_ext_search_right()
1556 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1563 ix = path[depth].p_idx; in ext4_ext_search_right()
1564 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1581 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1589 ix = path[depth].p_idx; in ext4_ext_search_right()
1590 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1602 while (++depth < path->p_depth) { in ext4_ext_search_right()
1604 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1612 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1635 ext4_ext_next_allocated_block(struct ext4_ext_path *path) in ext4_ext_next_allocated_block() argument
1639 BUG_ON(path == NULL); in ext4_ext_next_allocated_block()
1640 depth = path->p_depth; in ext4_ext_next_allocated_block()
1642 if (depth == 0 && path->p_ext == NULL) in ext4_ext_next_allocated_block()
1646 struct ext4_ext_path *p = &path[depth]; in ext4_ext_next_allocated_block()
1648 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1667 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1671 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1672 depth = path->p_depth; in ext4_ext_next_leaf_block()
1682 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1683 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1685 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1699 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1707 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1708 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1730 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1731 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1734 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1735 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1741 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1743 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1746 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1747 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1795 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1803 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1804 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1837 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1843 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1844 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1845 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1860 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1861 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1865 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1866 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1867 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1868 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1869 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1870 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1872 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1883 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1891 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1892 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1895 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1898 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1900 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1914 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1923 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1925 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1932 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1964 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1980 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1981 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1982 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
2020 path + depth); in ext4_ext_insert_extent()
2028 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2046 path + depth); in ext4_ext_insert_extent()
2057 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2064 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2072 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2079 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2084 path = npath; in ext4_ext_insert_extent()
2102 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2105 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2107 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2157 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2165 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2169 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2173 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2241 struct ext4_ext_path *path, in ext4_ext_determine_hole() argument
2248 ex = path[depth].p_ext; in ext4_ext_determine_hole()
2260 next = ext4_ext_next_allocated_block(path); in ext4_ext_determine_hole()
2298 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2305 path = path + depth; in ext4_ext_rm_idx()
2306 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2307 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2311 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2315 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2316 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2318 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2321 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2322 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2332 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2334 path--; in ext4_ext_rm_idx()
2335 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2338 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2339 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2354 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2356 if (path) { in ext4_ext_calc_credits_for_single_extent()
2361 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2362 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2587 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2605 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2606 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2607 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2608 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2613 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2632 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2703 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2743 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2755 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2782 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2783 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2794 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2796 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2798 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2805 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2815 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2849 path = ext4_find_extent(inode, end, NULL, in ext4_ext_remove_space()
2851 if (IS_ERR(path)) { in ext4_ext_remove_space()
2853 return PTR_ERR(path); in ext4_ext_remove_space()
2857 ex = path[depth].p_ext; in ext4_ext_remove_space()
2896 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2914 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2929 if (path) { in ext4_ext_remove_space()
2932 path[k].p_block = in ext4_ext_remove_space()
2933 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2935 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_remove_space()
2937 if (path == NULL) { in ext4_ext_remove_space()
2941 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2942 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2945 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2955 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2958 brelse(path[i].p_bh); in ext4_ext_remove_space()
2959 path[i].p_bh = NULL; in ext4_ext_remove_space()
2965 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2967 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2970 if (!path[i].p_idx) { in ext4_ext_remove_space()
2972 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2973 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2975 path[i].p_hdr, in ext4_ext_remove_space()
2976 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2979 path[i].p_idx--; in ext4_ext_remove_space()
2983 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2984 path[i].p_idx); in ext4_ext_remove_space()
2985 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2989 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2990 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2991 bh = read_extent_tree_block(inode, path[i].p_idx, in ext4_ext_remove_space()
3006 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
3010 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
3014 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
3018 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
3021 brelse(path[i].p_bh); in ext4_ext_remove_space()
3022 path[i].p_bh = NULL; in ext4_ext_remove_space()
3029 path->p_hdr->eh_entries); in ext4_ext_remove_space()
3049 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3054 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3059 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3063 ext4_ext_drop_refs(path); in ext4_ext_remove_space()
3064 kfree(path); in ext4_ext_remove_space()
3065 path = NULL; in ext4_ext_remove_space()
3181 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3194 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3197 ex = path[depth].p_ext; in ext4_split_extent_at()
3208 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3224 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3226 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3240 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3284 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3285 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3304 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3307 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3329 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3339 ex = path[depth].p_ext; in ext4_split_extent()
3363 path = ext4_find_extent(inode, map->m_lblk, ppath, flags); in ext4_split_extent()
3364 if (IS_ERR(path)) in ext4_split_extent()
3365 return PTR_ERR(path); in ext4_split_extent()
3367 ex = path[depth].p_ext; in ext4_split_extent()
3389 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3420 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3442 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3443 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3497 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3543 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3565 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3568 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3679 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3698 ex = path[depth].p_ext; in ext4_split_convert_extents()
3720 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3728 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3752 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3753 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3754 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3756 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3759 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3768 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3771 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3773 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3783 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3798 ex = path[depth].p_ext; in convert_initialized_extent()
3810 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3811 if (IS_ERR(path)) in convert_initialized_extent()
3812 return PTR_ERR(path); in convert_initialized_extent()
3814 ex = path[depth].p_ext; in convert_initialized_extent()
3822 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3831 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3834 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3837 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3854 struct ext4_ext_path __maybe_unused *path = *ppath; in ext4_ext_handle_unwritten_extents() local
3861 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
3958 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4007 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4053 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4087 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4101 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4102 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4103 err = PTR_ERR(path); in ext4_ext_map_blocks()
4104 path = NULL; in ext4_ext_map_blocks()
4115 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4119 path[depth].p_block); in ext4_ext_map_blocks()
4124 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4154 inode, map, &path, &allocated); in ext4_ext_map_blocks()
4162 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4167 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4185 hole_len = ext4_ext_determine_hole(inode, path, &hole_start); in ext4_ext_map_blocks()
4212 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4220 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4224 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4231 get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { in ext4_ext_map_blocks()
4252 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4260 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4306 err = ext4_ext_insert_extent(handle, inode, &path, &newex, flags); in ext4_ext_map_blocks()
4376 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4378 ext4_ext_drop_refs(path); in ext4_ext_map_blocks()
4379 kfree(path); in ext4_ext_map_blocks()
5022 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5030 depth = path->p_depth; in ext4_ext_shift_path_extents()
5033 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5034 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5038 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5041 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_path_extents()
5056 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5066 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5069 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5075 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5080 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5089 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5094 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5096 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5097 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5102 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5124 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5131 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_shift_extents()
5133 if (IS_ERR(path)) in ext4_ext_shift_extents()
5134 return PTR_ERR(path); in ext4_ext_shift_extents()
5136 depth = path->p_depth; in ext4_ext_shift_extents()
5137 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5149 path = ext4_find_extent(inode, start - 1, &path, in ext4_ext_shift_extents()
5151 if (IS_ERR(path)) in ext4_ext_shift_extents()
5152 return PTR_ERR(path); in ext4_ext_shift_extents()
5153 depth = path->p_depth; in ext4_ext_shift_extents()
5154 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5197 path = ext4_find_extent(inode, *iterator, &path, in ext4_ext_shift_extents()
5199 if (IS_ERR(path)) in ext4_ext_shift_extents()
5200 return PTR_ERR(path); in ext4_ext_shift_extents()
5201 depth = path->p_depth; in ext4_ext_shift_extents()
5202 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5211 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5212 path[depth].p_ext++; in ext4_ext_shift_extents()
5214 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5221 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5225 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5234 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5236 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5245 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5246 kfree(path); in ext4_ext_shift_extents()
5407 struct ext4_ext_path *path; in ext4_insert_range() local
5501 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5502 if (IS_ERR(path)) { in ext4_insert_range()
5508 extent = path[depth].p_ext; in ext4_insert_range()
5522 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5529 ext4_ext_drop_refs(path); in ext4_insert_range()
5530 kfree(path); in ext4_insert_range()
5536 ext4_ext_drop_refs(path); in ext4_insert_range()
5537 kfree(path); in ext4_insert_range()
5782 struct ext4_ext_path *path; in ext4_clu_mapped() local
5788 path = ext4_find_extent(inode, EXT4_C2B(sbi, lclu), NULL, 0); in ext4_clu_mapped()
5789 if (IS_ERR(path)) { in ext4_clu_mapped()
5790 err = PTR_ERR(path); in ext4_clu_mapped()
5791 path = NULL; in ext4_clu_mapped()
5802 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_clu_mapped()
5806 depth, path[depth].p_block); in ext4_clu_mapped()
5811 extent = path[depth].p_ext; in ext4_clu_mapped()
5832 first_lblk = ext4_ext_next_allocated_block(path); in ext4_clu_mapped()
5840 ext4_ext_drop_refs(path); in ext4_clu_mapped()
5841 kfree(path); in ext4_clu_mapped()
5856 struct ext4_ext_path *path = NULL, *ppath; in ext4_ext_replay_update_ex() local
5860 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5861 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5862 return PTR_ERR(path); in ext4_ext_replay_update_ex()
5863 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5872 ppath = path; in ext4_ext_replay_update_ex()
5878 kfree(path); in ext4_ext_replay_update_ex()
5879 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5880 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5882 ppath = path; in ext4_ext_replay_update_ex()
5883 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5892 kfree(path); in ext4_ext_replay_update_ex()
5893 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5894 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5896 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5905 ret = ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_update_ex()
5908 ext4_ext_drop_refs(path); in ext4_ext_replay_update_ex()
5909 kfree(path); in ext4_ext_replay_update_ex()
5917 struct ext4_ext_path *path = NULL; in ext4_ext_replay_shrink_inode() local
5922 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_shrink_inode()
5923 if (IS_ERR(path)) in ext4_ext_replay_shrink_inode()
5925 ex = path[path->p_depth].p_ext; in ext4_ext_replay_shrink_inode()
5927 ext4_ext_drop_refs(path); in ext4_ext_replay_shrink_inode()
5928 kfree(path); in ext4_ext_replay_shrink_inode()
5936 ext4_ext_try_to_merge(NULL, inode, path, ex); in ext4_ext_replay_shrink_inode()
5938 ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_shrink_inode()
5941 ext4_ext_drop_refs(path); in ext4_ext_replay_shrink_inode()
5942 kfree(path); in ext4_ext_replay_shrink_inode()
5967 struct ext4_ext_path *path = NULL, *path2 = NULL; in ext4_ext_replay_set_iblocks() local
5975 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_replay_set_iblocks()
5977 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
5978 return PTR_ERR(path); in ext4_ext_replay_set_iblocks()
5979 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
5981 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
5982 kfree(path); in ext4_ext_replay_set_iblocks()
5986 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
5987 kfree(path); in ext4_ext_replay_set_iblocks()
6013 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6014 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6016 numblks += path->p_depth; in ext4_ext_replay_set_iblocks()
6017 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6018 kfree(path); in ext4_ext_replay_set_iblocks()
6020 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6021 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6023 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
6025 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6026 kfree(path); in ext4_ext_replay_set_iblocks()
6033 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6034 kfree(path); in ext4_ext_replay_set_iblocks()
6039 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6040 kfree(path); in ext4_ext_replay_set_iblocks()
6043 for (i = 0; i <= max(path->p_depth, path2->p_depth); i++) { in ext4_ext_replay_set_iblocks()
6045 if (i <= path->p_depth) in ext4_ext_replay_set_iblocks()
6046 cmp1 = path[i].p_bh ? in ext4_ext_replay_set_iblocks()
6047 path[i].p_bh->b_blocknr : 0; in ext4_ext_replay_set_iblocks()
6054 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6056 kfree(path); in ext4_ext_replay_set_iblocks()
6068 struct ext4_ext_path *path = NULL; in ext4_ext_clear_bb() local
6078 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_clear_bb()
6080 if (IS_ERR(path)) in ext4_ext_clear_bb()
6081 return PTR_ERR(path); in ext4_ext_clear_bb()
6082 ex = path[path->p_depth].p_ext; in ext4_ext_clear_bb()
6084 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6085 kfree(path); in ext4_ext_clear_bb()
6089 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6090 kfree(path); in ext4_ext_clear_bb()
6100 path = ext4_find_extent(inode, map.m_lblk, NULL, 0); in ext4_ext_clear_bb()
6101 if (!IS_ERR_OR_NULL(path)) { in ext4_ext_clear_bb()
6102 for (j = 0; j < path->p_depth; j++) { in ext4_ext_clear_bb()
6105 path[j].p_block, 1, 0); in ext4_ext_clear_bb()
6107 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6108 kfree(path); in ext4_ext_clear_bb()