Lines Matching full: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()
161 /* path points to block */ 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()
174 /* path points to leaf/index in inode body */ 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()
194 /* path points to block */ in __ext4_ext_dirty()
196 inode, path->p_bh); in __ext4_ext_dirty()
199 set_buffer_verified(path->p_bh); in __ext4_ext_dirty()
201 /* path points to leaf/index in inode body */ 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()
667 ext_debug(inode, "path:"); 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()
1044 * inserts new subtree into the path, using free index entry
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()
1145 /* move remainder of path[depth] to the new leaf */ 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()
1230 /* move remainder of path[i] to the new index block */ 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()
1427 /* refill path */ 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()
1439 /* refill 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()
1479 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical); 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()
1488 /* usually extent in the path covers blocks smaller 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()
1547 EXT4_ERROR_INODE(inode, "path == NULL *logical %d!", *logical); 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()
1556 /* usually extent in the path covers blocks smaller 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()
1565 "first_extent(path[%d].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()
1935 * get the next allocated block if the extent in the path 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()
1990 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); 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()
2234 * @path: path in extent tree to @lblk
2238 * block. We don't try too hard to find the beginning of the hole but @path
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()
2312 EXT4_ERROR_INODE(inode, "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()
2354 * When pass the actual path, the caller should calculate credits
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()
2581 * @path: The path to the leaf
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()
2613 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth); 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()
2707 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2747 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2759 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2786 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2787 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2798 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2800 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2802 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2809 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2819 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2853 path = ext4_find_extent(inode, end, NULL, in ext4_ext_remove_space()
2855 if (IS_ERR(path)) { in ext4_ext_remove_space()
2857 return PTR_ERR(path); in ext4_ext_remove_space()
2861 ex = path[depth].p_ext; in ext4_ext_remove_space()
2865 "path[%d].p_hdr == NULL", in ext4_ext_remove_space()
2900 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2918 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2933 if (path) { in ext4_ext_remove_space()
2936 path[k].p_block = in ext4_ext_remove_space()
2937 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2939 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_remove_space()
2941 if (path == NULL) { in ext4_ext_remove_space()
2945 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2946 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2949 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2959 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2962 brelse(path[i].p_bh); in ext4_ext_remove_space()
2963 path[i].p_bh = NULL; in ext4_ext_remove_space()
2969 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2971 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2974 if (!path[i].p_idx) { in ext4_ext_remove_space()
2976 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2977 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2979 path[i].p_hdr, in ext4_ext_remove_space()
2980 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2983 path[i].p_idx--; in ext4_ext_remove_space()
2987 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2988 path[i].p_idx); in ext4_ext_remove_space()
2989 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2993 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2994 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2995 bh = read_extent_tree_block(inode, path[i].p_idx, in ext4_ext_remove_space()
3010 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
3014 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
3018 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
3022 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
3025 brelse(path[i].p_bh); in ext4_ext_remove_space()
3026 path[i].p_bh = NULL; in ext4_ext_remove_space()
3033 path->p_hdr->eh_entries); in ext4_ext_remove_space()
3053 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3058 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3063 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3067 ext4_free_ext_path(path); in ext4_ext_remove_space()
3068 path = NULL; in ext4_ext_remove_space()
3161 * @path: the path to the extent
3184 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3197 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3200 ex = path[depth].p_ext; in ext4_split_extent_at()
3211 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3227 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3229 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3240 * path may lead to new leaf, not to original leaf any more in ext4_split_extent_at()
3243 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3287 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3288 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3304 * Ignore ext4_ext_dirty return value since we are already in error path in ext4_split_extent_at()
3307 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3310 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3332 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3342 ex = path[depth].p_ext; in ext4_split_extent()
3363 * Update path is required because previous ext4_split_extent_at() may in ext4_split_extent()
3366 path = ext4_find_extent(inode, map->m_lblk, ppath, flags); in ext4_split_extent()
3367 if (IS_ERR(path)) in ext4_split_extent()
3368 return PTR_ERR(path); in ext4_split_extent()
3370 ex = path[depth].p_ext; in ext4_split_extent()
3391 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3407 * - The extent pointed to by 'path' is unwritten.
3408 * - The extent pointed to by 'path' contains a superset
3422 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3444 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3445 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3499 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3545 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3567 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3569 /* Update path to point to the right extent */ in ext4_ext_convert_to_initialized()
3570 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3681 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3700 ex = path[depth].p_ext; in ext4_split_convert_extents()
3722 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3730 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3754 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3755 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3756 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3758 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3761 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3770 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3773 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3775 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3785 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3800 ex = path[depth].p_ext; in convert_initialized_extent()
3812 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3813 if (IS_ERR(path)) in convert_initialized_extent()
3814 return PTR_ERR(path); in convert_initialized_extent()
3816 ex = path[depth].p_ext; in convert_initialized_extent()
3824 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3833 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3836 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3839 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3856 struct ext4_ext_path __maybe_unused *path = *ppath; in ext4_ext_handle_unwritten_extents() local
3863 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
3960 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4009 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4055 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4089 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4103 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4104 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4105 err = PTR_ERR(path); in ext4_ext_map_blocks()
4106 path = NULL; in ext4_ext_map_blocks()
4117 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4121 path[depth].p_block); in ext4_ext_map_blocks()
4126 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4156 inode, map, &path, &allocated); in ext4_ext_map_blocks()
4164 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4169 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4187 hole_len = ext4_ext_determine_hole(inode, path, &hole_start); in ext4_ext_map_blocks()
4214 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4222 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4226 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4233 get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { in ext4_ext_map_blocks()
4254 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4262 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4308 err = ext4_ext_insert_extent(handle, inode, &path, &newex, flags); in ext4_ext_map_blocks()
4378 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4380 ext4_free_ext_path(path); in ext4_ext_map_blocks()
5021 * Shift the extents of a path structure lying between path[depth].p_ext
5022 * and EXT_LAST_EXTENT(path[depth].p_hdr), by @shift blocks. @SHIFT tells
5026 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5034 depth = path->p_depth; in ext4_ext_shift_path_extents()
5037 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5038 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5042 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5045 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_path_extents()
5060 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5070 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5073 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5079 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5084 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5093 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5098 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5100 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5101 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5106 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5128 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5134 /* Let path point to the last extent */ in ext4_ext_shift_extents()
5135 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_shift_extents()
5137 if (IS_ERR(path)) in ext4_ext_shift_extents()
5138 return PTR_ERR(path); in ext4_ext_shift_extents()
5140 depth = path->p_depth; in ext4_ext_shift_extents()
5141 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5153 path = ext4_find_extent(inode, start - 1, &path, in ext4_ext_shift_extents()
5155 if (IS_ERR(path)) in ext4_ext_shift_extents()
5156 return PTR_ERR(path); in ext4_ext_shift_extents()
5157 depth = path->p_depth; in ext4_ext_shift_extents()
5158 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5202 path = ext4_find_extent(inode, *iterator, &path, in ext4_ext_shift_extents()
5204 if (IS_ERR(path)) in ext4_ext_shift_extents()
5205 return PTR_ERR(path); in ext4_ext_shift_extents()
5206 depth = path->p_depth; in ext4_ext_shift_extents()
5207 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5216 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5217 path[depth].p_ext++; in ext4_ext_shift_extents()
5219 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5226 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5230 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5236 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5240 if (extent == EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_extents()
5246 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5248 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5257 ext4_free_ext_path(path); in ext4_ext_shift_extents()
5423 struct ext4_ext_path *path; in ext4_insert_range() local
5521 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5522 if (IS_ERR(path)) { in ext4_insert_range()
5528 extent = path[depth].p_ext; in ext4_insert_range()
5542 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5549 ext4_free_ext_path(path); in ext4_insert_range()
5555 ext4_free_ext_path(path); in ext4_insert_range()
5704 * path must to be revalidated. */ in ext4_swap_extents()
5730 * path must to be revalidated. */ in ext4_swap_extents()
5797 struct ext4_ext_path *path; in ext4_clu_mapped() local
5803 path = ext4_find_extent(inode, EXT4_C2B(sbi, lclu), NULL, 0); in ext4_clu_mapped()
5804 if (IS_ERR(path)) { in ext4_clu_mapped()
5805 err = PTR_ERR(path); in ext4_clu_mapped()
5806 path = NULL; in ext4_clu_mapped()
5817 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_clu_mapped()
5821 depth, path[depth].p_block); in ext4_clu_mapped()
5826 extent = path[depth].p_ext; in ext4_clu_mapped()
5847 first_lblk = ext4_ext_next_allocated_block(path); in ext4_clu_mapped()
5855 ext4_free_ext_path(path); in ext4_clu_mapped()
5865 * replay path. Returns 0 on success and error on failure.
5870 struct ext4_ext_path *path = NULL, *ppath; in ext4_ext_replay_update_ex() local
5874 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5875 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5876 return PTR_ERR(path); in ext4_ext_replay_update_ex()
5877 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5886 ppath = path; 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 ppath = path; in ext4_ext_replay_update_ex()
5897 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5906 kfree(path); in ext4_ext_replay_update_ex()
5907 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5908 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5910 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5919 ret = ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_update_ex()
5922 ext4_free_ext_path(path); in ext4_ext_replay_update_ex()
5930 struct ext4_ext_path *path = NULL; in ext4_ext_replay_shrink_inode() local
5935 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_shrink_inode()
5936 if (IS_ERR(path)) in ext4_ext_replay_shrink_inode()
5938 ex = path[path->p_depth].p_ext; in ext4_ext_replay_shrink_inode()
5940 ext4_free_ext_path(path); in ext4_ext_replay_shrink_inode()
5948 ext4_ext_try_to_merge(NULL, inode, path, ex); in ext4_ext_replay_shrink_inode()
5950 ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_shrink_inode()
5953 ext4_free_ext_path(path); in ext4_ext_replay_shrink_inode()
5978 struct ext4_ext_path *path = NULL, *path2 = NULL; in ext4_ext_replay_set_iblocks() local
5986 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_replay_set_iblocks()
5988 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
5989 return PTR_ERR(path); in ext4_ext_replay_set_iblocks()
5990 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
5992 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
5996 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6014 * their paths. When path is different for 2 successive extents in ext4_ext_replay_set_iblocks()
6015 * we compare the blocks in the path at each level and increment in ext4_ext_replay_set_iblocks()
6022 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6023 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6025 numblks += path->p_depth; in ext4_ext_replay_set_iblocks()
6026 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 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
6033 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6040 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6045 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6048 for (i = 0; i <= max(path->p_depth, path2->p_depth); i++) { in ext4_ext_replay_set_iblocks()
6050 if (i <= path->p_depth) in ext4_ext_replay_set_iblocks()
6051 cmp1 = path[i].p_bh ? in ext4_ext_replay_set_iblocks()
6052 path[i].p_bh->b_blocknr : 0; in ext4_ext_replay_set_iblocks()
6059 ext4_free_ext_path(path); in ext4_ext_replay_set_iblocks()
6071 struct ext4_ext_path *path = NULL; in ext4_ext_clear_bb() local
6081 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_clear_bb()
6083 if (IS_ERR(path)) in ext4_ext_clear_bb()
6084 return PTR_ERR(path); in ext4_ext_clear_bb()
6085 ex = path[path->p_depth].p_ext; in ext4_ext_clear_bb()
6087 ext4_free_ext_path(path); in ext4_ext_clear_bb()
6091 ext4_free_ext_path(path); in ext4_ext_clear_bb()
6101 path = ext4_find_extent(inode, map.m_lblk, NULL, 0); in ext4_ext_clear_bb()
6102 if (!IS_ERR_OR_NULL(path)) { in ext4_ext_clear_bb()
6103 for (j = 0; j < path->p_depth; j++) { in ext4_ext_clear_bb()
6106 path[j].p_block, 1, 0); in ext4_ext_clear_bb()
6108 0, path[j].p_block, 1, 1); in ext4_ext_clear_bb()
6110 ext4_free_ext_path(path); in ext4_ext_clear_bb()