Lines Matching refs:path

109 static void ext4_ext_drop_refs(struct ext4_ext_path *path)  in ext4_ext_drop_refs()  argument
113 if (!path) in ext4_ext_drop_refs()
115 depth = path->p_depth; in ext4_ext_drop_refs()
116 for (i = 0; i <= depth; i++, path++) { in ext4_ext_drop_refs()
117 brelse(path->p_bh); in ext4_ext_drop_refs()
118 path->p_bh = NULL; in ext4_ext_drop_refs()
122 void ext4_free_ext_path(struct ext4_ext_path *path) in ext4_free_ext_path() argument
124 ext4_ext_drop_refs(path); in ext4_free_ext_path()
125 kfree(path); in ext4_free_ext_path()
156 struct ext4_ext_path *path) in ext4_ext_get_access() argument
160 if (path->p_bh) { in ext4_ext_get_access()
162 BUFFER_TRACE(path->p_bh, "get_write_access"); in ext4_ext_get_access()
164 path->p_bh, EXT4_JTR_NONE); in ext4_ext_get_access()
172 clear_buffer_verified(path->p_bh); in ext4_ext_get_access()
187 struct ext4_ext_path *path) in __ext4_ext_dirty() argument
192 if (path->p_bh) { in __ext4_ext_dirty()
193 ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh)); in __ext4_ext_dirty()
196 inode, path->p_bh); in __ext4_ext_dirty()
199 set_buffer_verified(path->p_bh); in __ext4_ext_dirty()
207 #define ext4_ext_dirty(handle, inode, path) \ argument
208 __ext4_ext_dirty(__func__, __LINE__, (handle), (inode), (path))
211 struct ext4_ext_path *path, in ext4_ext_find_goal() argument
214 if (path) { in ext4_ext_find_goal()
215 int depth = path->p_depth; in ext4_ext_find_goal()
235 ex = path[depth].p_ext; in ext4_ext_find_goal()
248 if (path[depth].p_bh) in ext4_ext_find_goal()
249 return path[depth].p_bh->b_blocknr; in ext4_ext_find_goal()
261 struct ext4_ext_path *path, in ext4_ext_new_meta_block() argument
266 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); in ext4_ext_new_meta_block()
331 struct ext4_ext_path *path = *ppath; in ext4_force_split_extent_at() local
332 int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); in ext4_force_split_extent_at()
603 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
619 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_precache()
621 if (path == NULL) { in ext4_ext_precache()
626 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
627 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
630 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
637 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
638 brelse(path[i].p_bh); in ext4_ext_precache()
639 path[i].p_bh = NULL; in ext4_ext_precache()
643 bh = read_extent_tree_block(inode, path[i].p_idx++, in ext4_ext_precache()
651 path[i].p_bh = bh; in ext4_ext_precache()
652 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
653 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
658 ext4_free_ext_path(path); in ext4_ext_precache()
663 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
665 int k, l = path->p_depth; in ext4_ext_show_path()
668 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
669 if (path->p_idx) { in ext4_ext_show_path()
671 le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
672 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
673 } else if (path->p_ext) { in ext4_ext_show_path()
675 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
676 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
677 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
678 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
685 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
692 if (!path) in ext4_ext_show_leaf()
695 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
708 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
716 idx = path[level].p_idx; in ext4_ext_show_move()
717 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
727 ex = path[depth].p_ext; in ext4_ext_show_move()
728 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
740 #define ext4_ext_show_path(inode, path) argument
741 #define ext4_ext_show_leaf(inode, path) argument
742 #define ext4_ext_show_move(inode, path, newblock, level) argument
752 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
754 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
774 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
775 ext_debug(inode, " -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
776 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
800 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
813 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
815 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
843 path->p_ext = l - 1; in ext4_ext_binsearch()
845 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
846 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
847 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
848 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
863 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
888 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
905 if (path) { in ext4_find_extent()
906 ext4_ext_drop_refs(path); in ext4_find_extent()
907 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
908 kfree(path); in ext4_find_extent()
909 *orig_path = path = NULL; in ext4_find_extent()
912 if (!path) { in ext4_find_extent()
914 path = kcalloc(depth + 2, sizeof(struct ext4_ext_path), in ext4_find_extent()
916 if (unlikely(!path)) in ext4_find_extent()
918 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
920 path[0].p_hdr = eh; in ext4_find_extent()
921 path[0].p_bh = NULL; in ext4_find_extent()
931 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
932 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
933 path[ppos].p_depth = i; in ext4_find_extent()
934 path[ppos].p_ext = NULL; in ext4_find_extent()
936 bh = read_extent_tree_block(inode, path[ppos].p_idx, --i, flags); in ext4_find_extent()
944 path[ppos].p_bh = bh; in ext4_find_extent()
945 path[ppos].p_hdr = eh; in ext4_find_extent()
948 path[ppos].p_depth = i; in ext4_find_extent()
949 path[ppos].p_ext = NULL; in ext4_find_extent()
950 path[ppos].p_idx = NULL; in ext4_find_extent()
953 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
955 if (path[ppos].p_ext) in ext4_find_extent()
956 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
958 ext4_ext_show_path(inode, path); in ext4_find_extent()
960 return path; in ext4_find_extent()
963 ext4_free_ext_path(path); in ext4_find_extent()
1054 struct ext4_ext_path *path, in ext4_ext_split() argument
1077 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1081 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1082 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1112 newblock = ext4_ext_new_meta_block(handle, inode, path, in ext4_ext_split()
1146 if (unlikely(path[depth].p_hdr->eh_entries != in ext4_ext_split()
1147 path[depth].p_hdr->eh_max)) { in ext4_ext_split()
1149 path[depth].p_hdr->eh_entries, in ext4_ext_split()
1150 path[depth].p_hdr->eh_max); in ext4_ext_split()
1155 m = EXT_MAX_EXTENT(path[depth].p_hdr) - path[depth].p_ext++; in ext4_ext_split()
1156 ext4_ext_show_move(inode, path, newblock, depth); in ext4_ext_split()
1160 memmove(ex, path[depth].p_ext, sizeof(struct ext4_extent) * m); in ext4_ext_split()
1180 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_split()
1183 le16_add_cpu(&path[depth].p_hdr->eh_entries, -m); in ext4_ext_split()
1184 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_split()
1231 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1232 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1235 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1240 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1241 ext_debug(inode, "cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1242 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1243 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1245 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1266 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1269 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1270 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1279 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1404 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1412 curp = path + depth; in ext4_ext_create_new_leaf()
1423 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1428 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1431 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1432 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1440 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1443 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1444 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1453 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1471 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1478 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1482 depth = path->p_depth; in ext4_ext_search_left()
1485 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1492 ex = path[depth].p_ext; in ext4_ext_search_left()
1495 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1502 ix = path[depth].p_idx; in ext4_ext_search_left()
1503 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1507 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block), in ext4_ext_search_left()
1535 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1546 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1550 depth = path->p_depth; in ext4_ext_search_right()
1553 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1560 ex = path[depth].p_ext; in ext4_ext_search_right()
1563 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1570 ix = path[depth].p_idx; in ext4_ext_search_right()
1571 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1588 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1596 ix = path[depth].p_idx; in ext4_ext_search_right()
1597 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1609 while (++depth < path->p_depth) { in ext4_ext_search_right()
1611 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1619 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1642 ext4_ext_next_allocated_block(struct ext4_ext_path *path) in ext4_ext_next_allocated_block() argument
1646 BUG_ON(path == NULL); in ext4_ext_next_allocated_block()
1647 depth = path->p_depth; in ext4_ext_next_allocated_block()
1649 if (depth == 0 && path->p_ext == NULL) in ext4_ext_next_allocated_block()
1653 struct ext4_ext_path *p = &path[depth]; in ext4_ext_next_allocated_block()
1655 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1674 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1678 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1679 depth = path->p_depth; in ext4_ext_next_leaf_block()
1689 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1690 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1692 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1706 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1714 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1715 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1737 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1738 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1741 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1742 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1748 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1750 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1753 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1754 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1802 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1810 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1811 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1844 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1850 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1851 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1852 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1867 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1868 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1872 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1873 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1874 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1875 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1876 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1877 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1879 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1890 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1898 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1899 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1902 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1905 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1907 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1921 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1930 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1932 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1939 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1971 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1987 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1988 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1989 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
2027 path + depth); in ext4_ext_insert_extent()
2052 path + depth); in ext4_ext_insert_extent()
2069 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2077 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2084 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2089 path = npath; in ext4_ext_insert_extent()
2107 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2110 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2112 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2162 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2170 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2174 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2178 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2245 struct ext4_ext_path *path, in ext4_ext_determine_hole() argument
2252 ex = path[depth].p_ext; in ext4_ext_determine_hole()
2264 next = ext4_ext_next_allocated_block(path); in ext4_ext_determine_hole()
2302 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2309 path = path + depth; in ext4_ext_rm_idx()
2310 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2311 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2315 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2319 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2320 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2322 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2325 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2326 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2336 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2338 path--; in ext4_ext_rm_idx()
2339 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2342 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2343 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2358 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2360 if (path) { in ext4_ext_calc_credits_for_single_extent()
2365 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2366 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2591 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2609 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2610 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2611 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2612 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2617 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2636 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2706 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2746 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2758 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2785 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2786 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2797 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2799 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2801 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2808 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2818 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2852 path = ext4_find_extent(inode, end, NULL, in ext4_ext_remove_space()
2854 if (IS_ERR(path)) { in ext4_ext_remove_space()
2856 return PTR_ERR(path); in ext4_ext_remove_space()
2860 ex = path[depth].p_ext; in ext4_ext_remove_space()
2899 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2917 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2932 if (path) { in ext4_ext_remove_space()
2935 path[k].p_block = in ext4_ext_remove_space()
2936 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2938 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_remove_space()
2940 if (path == NULL) { in ext4_ext_remove_space()
2944 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2945 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2948 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2958 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2961 brelse(path[i].p_bh); in ext4_ext_remove_space()
2962 path[i].p_bh = NULL; in ext4_ext_remove_space()
2968 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2970 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2973 if (!path[i].p_idx) { in ext4_ext_remove_space()
2975 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2976 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2978 path[i].p_hdr, in ext4_ext_remove_space()
2979 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2982 path[i].p_idx--; in ext4_ext_remove_space()
2986 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2987 path[i].p_idx); in ext4_ext_remove_space()
2988 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2992 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2993 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2994 bh = read_extent_tree_block(inode, path[i].p_idx, in ext4_ext_remove_space()
3009 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
3013 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
3017 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
3021 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
3024 brelse(path[i].p_bh); in ext4_ext_remove_space()
3025 path[i].p_bh = NULL; in ext4_ext_remove_space()
3032 path->p_hdr->eh_entries); in ext4_ext_remove_space()
3052 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3057 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3062 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3066 ext4_free_ext_path(path); in ext4_ext_remove_space()
3067 path = NULL; in ext4_ext_remove_space()
3183 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3196 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3199 ex = path[depth].p_ext; in ext4_split_extent_at()
3210 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3226 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3228 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3242 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3286 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3287 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3306 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3309 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3331 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3341 ex = path[depth].p_ext; in ext4_split_extent()
3365 path = ext4_find_extent(inode, map->m_lblk, ppath, flags); in ext4_split_extent()
3366 if (IS_ERR(path)) in ext4_split_extent()
3367 return PTR_ERR(path); in ext4_split_extent()
3369 ex = path[depth].p_ext; in ext4_split_extent()
3390 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3421 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3443 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3444 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3498 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3544 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3566 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3569 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3680 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3699 ex = path[depth].p_ext; in ext4_split_convert_extents()
3721 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3729 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3753 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3754 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3755 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3757 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3760 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3769 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3772 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3774 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3784 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3799 ex = path[depth].p_ext; in convert_initialized_extent()
3811 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3812 if (IS_ERR(path)) in convert_initialized_extent()
3813 return PTR_ERR(path); in convert_initialized_extent()
3815 ex = path[depth].p_ext; in convert_initialized_extent()
3823 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3832 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3835 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3838 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3855 struct ext4_ext_path __maybe_unused *path = *ppath; in ext4_ext_handle_unwritten_extents() local
3862 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
3959 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4008 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4054 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4088 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4102 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4103 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4104 err = PTR_ERR(path); in ext4_ext_map_blocks()
4105 path = NULL; in ext4_ext_map_blocks()
4116 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4120 path[depth].p_block); in ext4_ext_map_blocks()
4125 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4155 inode, map, &path, &allocated); in ext4_ext_map_blocks()
4163 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4168 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4186 hole_len = ext4_ext_determine_hole(inode, path, &hole_start); in ext4_ext_map_blocks()
4213 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4221 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4225 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4232 get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { in ext4_ext_map_blocks()
4253 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4261 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4307 err = ext4_ext_insert_extent(handle, inode, &path, &newex, flags); in ext4_ext_map_blocks()
4377 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4379 ext4_free_ext_path(path); in ext4_ext_map_blocks()
5025 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5033 depth = path->p_depth; in ext4_ext_shift_path_extents()
5036 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5037 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5041 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5044 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_path_extents()
5059 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5069 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5072 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5078 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5083 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5092 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5097 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5099 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5100 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5105 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5127 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5134 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_shift_extents()
5136 if (IS_ERR(path)) in ext4_ext_shift_extents()
5137 return PTR_ERR(path); in ext4_ext_shift_extents()
5139 depth = path->p_depth; in ext4_ext_shift_extents()
5140 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5152 path = ext4_find_extent(inode, start - 1, &path, in ext4_ext_shift_extents()
5154 if (IS_ERR(path)) in ext4_ext_shift_extents()
5155 return PTR_ERR(path); in ext4_ext_shift_extents()
5156 depth = path->p_depth; in ext4_ext_shift_extents()
5157 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5201 path = ext4_find_extent(inode, *iterator, &path, in ext4_ext_shift_extents()
5203 if (IS_ERR(path)) in ext4_ext_shift_extents()
5204 return PTR_ERR(path); in ext4_ext_shift_extents()
5205 depth = path->p_depth; in ext4_ext_shift_extents()
5206 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5215 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5216 path[depth].p_ext++; in ext4_ext_shift_extents()
5218 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5225 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5229 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5235 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5239 if (extent == EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_extents()
5245 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5247 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5256 ext4_free_ext_path(path); in ext4_ext_shift_extents()
5422 struct ext4_ext_path *path; in ext4_insert_range() local
5520 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5521 if (IS_ERR(path)) { in ext4_insert_range()
5527 extent = path[depth].p_ext; in ext4_insert_range()
5541 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5548 ext4_free_ext_path(path); in ext4_insert_range()
5554 ext4_free_ext_path(path); in ext4_insert_range()
5795 struct ext4_ext_path *path; in ext4_clu_mapped() local
5809 path = ext4_find_extent(inode, EXT4_C2B(sbi, lclu), NULL, 0); in ext4_clu_mapped()
5810 if (IS_ERR(path)) { in ext4_clu_mapped()
5811 err = PTR_ERR(path); in ext4_clu_mapped()
5812 path = NULL; in ext4_clu_mapped()
5823 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_clu_mapped()
5827 depth, path[depth].p_block); in ext4_clu_mapped()
5832 extent = path[depth].p_ext; in ext4_clu_mapped()
5853 first_lblk = ext4_ext_next_allocated_block(path); in ext4_clu_mapped()
5861 ext4_free_ext_path(path); in ext4_clu_mapped()
5876 struct ext4_ext_path *path = NULL, *ppath; in ext4_ext_replay_update_ex() local
5880 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5881 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5882 return PTR_ERR(path); in ext4_ext_replay_update_ex()
5883 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5892 ppath = path; in ext4_ext_replay_update_ex()
5898 kfree(path); in ext4_ext_replay_update_ex()
5899 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5900 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5902 ppath = path; in ext4_ext_replay_update_ex()
5903 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5912 kfree(path); in ext4_ext_replay_update_ex()
5913 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5914 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5916 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5925 ret = ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_update_ex()
5928 ext4_free_ext_path(path); in ext4_ext_replay_update_ex()
5936 struct ext4_ext_path *path = NULL; in ext4_ext_replay_shrink_inode() local
5941 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_shrink_inode()
5942 if (IS_ERR(path)) in ext4_ext_replay_shrink_inode()
5944 ex = path[path->p_depth].p_ext; in ext4_ext_replay_shrink_inode()
5946 ext4_free_ext_path(path); in ext4_ext_replay_shrink_inode()
5954 ext4_ext_try_to_merge(NULL, inode, path, ex); in ext4_ext_replay_shrink_inode()
5956 ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_shrink_inode()
5959 ext4_free_ext_path(path); in ext4_ext_replay_shrink_inode()
5984 struct ext4_ext_path *path = NULL, *path2 = NULL; in ext4_ext_replay_set_iblocks() local
5992 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_replay_set_iblocks()
5994 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
5995 return PTR_ERR(path); in ext4_ext_replay_set_iblocks()
5996 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
5998 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6002 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6028 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6029 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6031 numblks += path->p_depth; in ext4_ext_replay_set_iblocks()
6032 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6034 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6035 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6037 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
6039 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6046 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6051 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6054 for (i = 0; i <= max(path->p_depth, path2->p_depth); i++) { in ext4_ext_replay_set_iblocks()
6056 if (i <= path->p_depth) in ext4_ext_replay_set_iblocks()
6057 cmp1 = path[i].p_bh ? in ext4_ext_replay_set_iblocks()
6058 path[i].p_bh->b_blocknr : 0; in ext4_ext_replay_set_iblocks()
6065 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6077 struct ext4_ext_path *path = NULL; in ext4_ext_clear_bb() local
6087 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_clear_bb()
6089 if (IS_ERR(path)) in ext4_ext_clear_bb()
6090 return PTR_ERR(path); in ext4_ext_clear_bb()
6091 ex = path[path->p_depth].p_ext; in ext4_ext_clear_bb()
6093 ext4_free_ext_path(path); in ext4_ext_clear_bb()
6097 ext4_free_ext_path(path); in ext4_ext_clear_bb()
6107 path = ext4_find_extent(inode, map.m_lblk, NULL, 0); in ext4_ext_clear_bb()
6108 if (!IS_ERR_OR_NULL(path)) { in ext4_ext_clear_bb()
6109 for (j = 0; j < path->p_depth; j++) { in ext4_ext_clear_bb()
6112 path[j].p_block, 1, 0); in ext4_ext_clear_bb()
6114 0, path[j].p_block, 1, 1); in ext4_ext_clear_bb()
6116 ext4_free_ext_path(path); in ext4_ext_clear_bb()