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()
144 err = ext4_journal_get_write_access(handle, path->p_bh); in ext4_ext_get_access()
152 clear_buffer_verified(path->p_bh); in ext4_ext_get_access()
167 struct ext4_ext_path *path) in __ext4_ext_dirty() argument
172 if (path->p_bh) { in __ext4_ext_dirty()
173 ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh)); in __ext4_ext_dirty()
176 inode, path->p_bh); in __ext4_ext_dirty()
179 set_buffer_verified(path->p_bh); in __ext4_ext_dirty()
187 #define ext4_ext_dirty(handle, inode, path) \ argument
188 __ext4_ext_dirty(__func__, __LINE__, (handle), (inode), (path))
191 struct ext4_ext_path *path, in ext4_ext_find_goal() argument
194 if (path) { in ext4_ext_find_goal()
195 int depth = path->p_depth; in ext4_ext_find_goal()
215 ex = path[depth].p_ext; in ext4_ext_find_goal()
228 if (path[depth].p_bh) in ext4_ext_find_goal()
229 return path[depth].p_bh->b_blocknr; in ext4_ext_find_goal()
241 struct ext4_ext_path *path, in ext4_ext_new_meta_block() argument
246 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); in ext4_ext_new_meta_block()
311 struct ext4_ext_path *path = *ppath; in ext4_force_split_extent_at() local
312 int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); in ext4_force_split_extent_at()
583 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
599 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_precache()
601 if (path == NULL) { in ext4_ext_precache()
606 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
607 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
610 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
617 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
618 brelse(path[i].p_bh); in ext4_ext_precache()
619 path[i].p_bh = NULL; in ext4_ext_precache()
623 bh = read_extent_tree_block(inode, path[i].p_idx++, in ext4_ext_precache()
631 path[i].p_bh = bh; in ext4_ext_precache()
632 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
633 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
638 ext4_ext_drop_refs(path); in ext4_ext_precache()
639 kfree(path); in ext4_ext_precache()
644 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
646 int k, l = path->p_depth; in ext4_ext_show_path()
649 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
650 if (path->p_idx) { in ext4_ext_show_path()
652 le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
653 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
654 } else if (path->p_ext) { in ext4_ext_show_path()
656 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
657 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
658 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
659 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
666 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
673 if (!path) in ext4_ext_show_leaf()
676 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
689 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
697 idx = path[level].p_idx; in ext4_ext_show_move()
698 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
708 ex = path[depth].p_ext; in ext4_ext_show_move()
709 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
721 #define ext4_ext_show_path(inode, path) argument
722 #define ext4_ext_show_leaf(inode, path) argument
723 #define ext4_ext_show_move(inode, path, newblock, level) argument
726 void ext4_ext_drop_refs(struct ext4_ext_path *path) in ext4_ext_drop_refs() argument
730 if (!path) in ext4_ext_drop_refs()
732 depth = path->p_depth; in ext4_ext_drop_refs()
733 for (i = 0; i <= depth; i++, path++) { in ext4_ext_drop_refs()
734 brelse(path->p_bh); in ext4_ext_drop_refs()
735 path->p_bh = NULL; in ext4_ext_drop_refs()
746 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
748 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
767 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
768 ext_debug(inode, " -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
769 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
793 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
806 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
808 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
835 path->p_ext = l - 1; in ext4_ext_binsearch()
837 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
838 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
839 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
840 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
855 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
880 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
897 if (path) { in ext4_find_extent()
898 ext4_ext_drop_refs(path); in ext4_find_extent()
899 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
900 kfree(path); in ext4_find_extent()
901 *orig_path = path = NULL; in ext4_find_extent()
904 if (!path) { in ext4_find_extent()
906 path = kcalloc(depth + 2, sizeof(struct ext4_ext_path), in ext4_find_extent()
908 if (unlikely(!path)) in ext4_find_extent()
910 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
912 path[0].p_hdr = eh; in ext4_find_extent()
913 path[0].p_bh = NULL; in ext4_find_extent()
923 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
924 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
925 path[ppos].p_depth = i; in ext4_find_extent()
926 path[ppos].p_ext = NULL; in ext4_find_extent()
928 bh = read_extent_tree_block(inode, path[ppos].p_idx, --i, flags); in ext4_find_extent()
936 path[ppos].p_bh = bh; in ext4_find_extent()
937 path[ppos].p_hdr = eh; in ext4_find_extent()
940 path[ppos].p_depth = i; in ext4_find_extent()
941 path[ppos].p_ext = NULL; in ext4_find_extent()
942 path[ppos].p_idx = NULL; in ext4_find_extent()
945 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
947 if (path[ppos].p_ext) in ext4_find_extent()
948 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
950 ext4_ext_show_path(inode, path); in ext4_find_extent()
952 return path; in ext4_find_extent()
955 ext4_ext_drop_refs(path); in ext4_find_extent()
956 kfree(path); in ext4_find_extent()
1047 struct ext4_ext_path *path, in ext4_ext_split() argument
1070 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1074 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1075 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1105 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()
1222 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1223 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1226 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1231 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1232 ext_debug(inode, "cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1233 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1234 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1236 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1257 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1260 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1261 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1270 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1393 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1401 curp = path + depth; in ext4_ext_create_new_leaf()
1412 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1417 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1420 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1421 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1429 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1432 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1433 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1442 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1460 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1467 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1471 depth = path->p_depth; in ext4_ext_search_left()
1474 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1481 ex = path[depth].p_ext; in ext4_ext_search_left()
1484 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1491 ix = path[depth].p_idx; in ext4_ext_search_left()
1492 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1496 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? in ext4_ext_search_left()
1497 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, in ext4_ext_search_left()
1525 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1536 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1540 depth = path->p_depth; in ext4_ext_search_right()
1543 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1550 ex = path[depth].p_ext; in ext4_ext_search_right()
1553 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1560 ix = path[depth].p_idx; in ext4_ext_search_right()
1561 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1578 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1586 ix = path[depth].p_idx; in ext4_ext_search_right()
1587 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1599 while (++depth < path->p_depth) { in ext4_ext_search_right()
1601 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1609 bh = read_extent_tree_block(inode, ix, path->p_depth - depth, 0); in ext4_ext_search_right()
1632 ext4_ext_next_allocated_block(struct ext4_ext_path *path) in ext4_ext_next_allocated_block() argument
1636 BUG_ON(path == NULL); in ext4_ext_next_allocated_block()
1637 depth = path->p_depth; in ext4_ext_next_allocated_block()
1639 if (depth == 0 && path->p_ext == NULL) in ext4_ext_next_allocated_block()
1643 struct ext4_ext_path *p = &path[depth]; in ext4_ext_next_allocated_block()
1645 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1664 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1668 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1669 depth = path->p_depth; in ext4_ext_next_leaf_block()
1679 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1680 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1682 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1696 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1704 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1705 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1727 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1728 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1731 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1732 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1738 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1740 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1743 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1744 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1792 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1800 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1801 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1834 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1840 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1841 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1842 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1857 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1858 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1862 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1863 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1864 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1865 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1866 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1867 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1869 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1880 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1888 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1889 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1892 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1895 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1897 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1911 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1920 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1922 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1929 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1961 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1977 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1978 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1979 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
2017 path + depth); in ext4_ext_insert_extent()
2025 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2043 path + depth); in ext4_ext_insert_extent()
2054 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2061 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2069 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2076 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2081 path = npath; in ext4_ext_insert_extent()
2099 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2102 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2104 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2154 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2162 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2166 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2170 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2238 struct ext4_ext_path *path, in ext4_ext_find_hole() argument
2245 ex = path[depth].p_ext; in ext4_ext_find_hole()
2257 next = ext4_ext_next_allocated_block(path); in ext4_ext_find_hole()
2271 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2278 path = path + depth; in ext4_ext_rm_idx()
2279 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2280 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2284 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2288 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2289 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2291 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2294 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2295 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2305 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2307 path--; in ext4_ext_rm_idx()
2308 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2311 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2312 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2327 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2329 if (path) { in ext4_ext_calc_credits_for_single_extent()
2334 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2335 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2560 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2578 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2579 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2580 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2581 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2586 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2605 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2676 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2716 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2728 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2755 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2756 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2767 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2769 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2771 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2778 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2788 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2822 path = ext4_find_extent(inode, end, NULL, in ext4_ext_remove_space()
2824 if (IS_ERR(path)) { in ext4_ext_remove_space()
2826 return PTR_ERR(path); in ext4_ext_remove_space()
2830 ex = path[depth].p_ext; in ext4_ext_remove_space()
2869 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2887 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2902 if (path) { in ext4_ext_remove_space()
2905 path[k].p_block = in ext4_ext_remove_space()
2906 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2908 path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), in ext4_ext_remove_space()
2910 if (path == NULL) { in ext4_ext_remove_space()
2914 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2915 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2918 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2928 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2931 brelse(path[i].p_bh); in ext4_ext_remove_space()
2932 path[i].p_bh = NULL; in ext4_ext_remove_space()
2938 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2940 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2943 if (!path[i].p_idx) { in ext4_ext_remove_space()
2945 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2946 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2948 path[i].p_hdr, in ext4_ext_remove_space()
2949 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2952 path[i].p_idx--; in ext4_ext_remove_space()
2956 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2957 path[i].p_idx); in ext4_ext_remove_space()
2958 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2962 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2963 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2964 bh = read_extent_tree_block(inode, path[i].p_idx, in ext4_ext_remove_space()
2979 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
2983 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
2987 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
2991 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
2994 brelse(path[i].p_bh); in ext4_ext_remove_space()
2995 path[i].p_bh = NULL; in ext4_ext_remove_space()
3002 path->p_hdr->eh_entries); in ext4_ext_remove_space()
3022 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3027 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3032 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3036 ext4_ext_drop_refs(path); in ext4_ext_remove_space()
3037 kfree(path); in ext4_ext_remove_space()
3038 path = NULL; in ext4_ext_remove_space()
3155 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3168 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3171 ex = path[depth].p_ext; in ext4_split_extent_at()
3182 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3198 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3200 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3214 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3258 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3259 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3278 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3281 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3303 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3313 ex = path[depth].p_ext; in ext4_split_extent()
3337 path = ext4_find_extent(inode, map->m_lblk, ppath, flags); in ext4_split_extent()
3338 if (IS_ERR(path)) in ext4_split_extent()
3339 return PTR_ERR(path); in ext4_split_extent()
3341 ex = path[depth].p_ext; in ext4_split_extent()
3363 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3394 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3416 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3417 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3471 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3517 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3539 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3542 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3652 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3671 ex = path[depth].p_ext; in ext4_split_convert_extents()
3693 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3701 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3725 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3726 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3727 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3729 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3732 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3741 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3744 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3746 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3756 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3771 ex = path[depth].p_ext; in convert_initialized_extent()
3783 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3784 if (IS_ERR(path)) in convert_initialized_extent()
3785 return PTR_ERR(path); in convert_initialized_extent()
3787 ex = path[depth].p_ext; in convert_initialized_extent()
3795 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3804 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3807 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3810 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3827 struct ext4_ext_path __maybe_unused *path = *ppath; in ext4_ext_handle_unwritten_extents() local
3834 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
3931 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
3980 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4026 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4046 struct ext4_ext_path *path, in ext4_ext_determine_insert_hole() argument
4053 len = ext4_ext_find_hole(inode, path, &hole_start); in ext4_ext_determine_insert_hole()
4123 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4137 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4138 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4139 err = PTR_ERR(path); in ext4_ext_map_blocks()
4140 path = NULL; in ext4_ext_map_blocks()
4151 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4155 path[depth].p_block); in ext4_ext_map_blocks()
4160 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4190 inode, map, &path, &allocated); in ext4_ext_map_blocks()
4198 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4203 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4220 len = ext4_ext_determine_insert_hole(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4238 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4246 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4250 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4257 get_implied_cluster_alloc(inode->i_sb, map, &ex2, path)) { in ext4_ext_map_blocks()
4278 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4286 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4332 err = ext4_ext_insert_extent(handle, inode, &path, &newex, flags); in ext4_ext_map_blocks()
4402 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4404 ext4_ext_drop_refs(path); in ext4_ext_map_blocks()
4405 kfree(path); in ext4_ext_map_blocks()
5052 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5060 depth = path->p_depth; in ext4_ext_shift_path_extents()
5063 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5064 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5068 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5071 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_path_extents()
5086 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5096 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5099 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5105 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5110 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5119 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5124 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5126 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5127 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5132 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5154 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5161 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_shift_extents()
5163 if (IS_ERR(path)) in ext4_ext_shift_extents()
5164 return PTR_ERR(path); in ext4_ext_shift_extents()
5166 depth = path->p_depth; in ext4_ext_shift_extents()
5167 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5179 path = ext4_find_extent(inode, start - 1, &path, in ext4_ext_shift_extents()
5181 if (IS_ERR(path)) in ext4_ext_shift_extents()
5182 return PTR_ERR(path); in ext4_ext_shift_extents()
5183 depth = path->p_depth; in ext4_ext_shift_extents()
5184 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5228 path = ext4_find_extent(inode, *iterator, &path, in ext4_ext_shift_extents()
5230 if (IS_ERR(path)) in ext4_ext_shift_extents()
5231 return PTR_ERR(path); in ext4_ext_shift_extents()
5232 depth = path->p_depth; in ext4_ext_shift_extents()
5233 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5242 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5243 path[depth].p_ext++; in ext4_ext_shift_extents()
5245 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5252 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5256 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5262 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5266 if (extent == EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_extents()
5272 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5274 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5283 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5284 kfree(path); in ext4_ext_shift_extents()
5449 struct ext4_ext_path *path; in ext4_insert_range() local
5547 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5548 if (IS_ERR(path)) { in ext4_insert_range()
5554 extent = path[depth].p_ext; in ext4_insert_range()
5568 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5575 ext4_ext_drop_refs(path); in ext4_insert_range()
5576 kfree(path); in ext4_insert_range()
5582 ext4_ext_drop_refs(path); in ext4_insert_range()
5583 kfree(path); in ext4_insert_range()
5828 struct ext4_ext_path *path; in ext4_clu_mapped() local
5843 path = ext4_find_extent(inode, EXT4_C2B(sbi, lclu), NULL, 0); in ext4_clu_mapped()
5844 if (IS_ERR(path)) { in ext4_clu_mapped()
5845 err = PTR_ERR(path); in ext4_clu_mapped()
5846 path = NULL; in ext4_clu_mapped()
5857 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_clu_mapped()
5861 depth, path[depth].p_block); in ext4_clu_mapped()
5866 extent = path[depth].p_ext; in ext4_clu_mapped()
5887 first_lblk = ext4_ext_next_allocated_block(path); in ext4_clu_mapped()
5895 ext4_ext_drop_refs(path); in ext4_clu_mapped()
5896 kfree(path); in ext4_clu_mapped()
5911 struct ext4_ext_path *path = NULL, *ppath; in ext4_ext_replay_update_ex() local
5915 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5916 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5917 return PTR_ERR(path); in ext4_ext_replay_update_ex()
5918 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5927 ppath = path; in ext4_ext_replay_update_ex()
5933 kfree(path); in ext4_ext_replay_update_ex()
5934 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5935 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5937 ppath = path; in ext4_ext_replay_update_ex()
5938 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5947 kfree(path); in ext4_ext_replay_update_ex()
5948 path = ext4_find_extent(inode, start, NULL, 0); in ext4_ext_replay_update_ex()
5949 if (IS_ERR(path)) in ext4_ext_replay_update_ex()
5951 ex = path[path->p_depth].p_ext; in ext4_ext_replay_update_ex()
5960 ret = ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_update_ex()
5963 ext4_ext_drop_refs(path); in ext4_ext_replay_update_ex()
5964 kfree(path); in ext4_ext_replay_update_ex()
5972 struct ext4_ext_path *path = NULL; in ext4_ext_replay_shrink_inode() local
5977 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_shrink_inode()
5978 if (IS_ERR(path)) in ext4_ext_replay_shrink_inode()
5980 ex = path[path->p_depth].p_ext; in ext4_ext_replay_shrink_inode()
5982 ext4_ext_drop_refs(path); in ext4_ext_replay_shrink_inode()
5983 kfree(path); in ext4_ext_replay_shrink_inode()
5991 ext4_ext_try_to_merge(NULL, inode, path, ex); in ext4_ext_replay_shrink_inode()
5993 ext4_ext_dirty(NULL, inode, &path[path->p_depth]); in ext4_ext_replay_shrink_inode()
5996 ext4_ext_drop_refs(path); in ext4_ext_replay_shrink_inode()
5997 kfree(path); in ext4_ext_replay_shrink_inode()
6022 struct ext4_ext_path *path = NULL, *path2 = NULL; in ext4_ext_replay_set_iblocks() local
6030 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_replay_set_iblocks()
6032 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6033 return PTR_ERR(path); in ext4_ext_replay_set_iblocks()
6034 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
6036 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6037 kfree(path); in ext4_ext_replay_set_iblocks()
6041 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6042 kfree(path); in ext4_ext_replay_set_iblocks()
6068 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6069 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6071 numblks += path->p_depth; in ext4_ext_replay_set_iblocks()
6072 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6073 kfree(path); in ext4_ext_replay_set_iblocks()
6075 path = ext4_find_extent(inode, cur, NULL, 0); in ext4_ext_replay_set_iblocks()
6076 if (IS_ERR(path)) in ext4_ext_replay_set_iblocks()
6078 ex = path[path->p_depth].p_ext; in ext4_ext_replay_set_iblocks()
6080 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6081 kfree(path); in ext4_ext_replay_set_iblocks()
6088 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6089 kfree(path); in ext4_ext_replay_set_iblocks()
6094 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6095 kfree(path); in ext4_ext_replay_set_iblocks()
6099 for (i = 0; i <= max(path->p_depth, path2->p_depth); i++) { in ext4_ext_replay_set_iblocks()
6101 if (i <= path->p_depth) in ext4_ext_replay_set_iblocks()
6102 cmp1 = path[i].p_bh ? in ext4_ext_replay_set_iblocks()
6103 path[i].p_bh->b_blocknr : 0; in ext4_ext_replay_set_iblocks()
6110 ext4_ext_drop_refs(path); in ext4_ext_replay_set_iblocks()
6112 kfree(path); in ext4_ext_replay_set_iblocks()
6124 struct ext4_ext_path *path = NULL; in ext4_ext_clear_bb() local
6131 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_clear_bb()
6133 if (IS_ERR(path)) in ext4_ext_clear_bb()
6134 return PTR_ERR(path); in ext4_ext_clear_bb()
6135 ex = path[path->p_depth].p_ext; in ext4_ext_clear_bb()
6137 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6138 kfree(path); in ext4_ext_clear_bb()
6142 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6143 kfree(path); in ext4_ext_clear_bb()
6153 path = ext4_find_extent(inode, map.m_lblk, NULL, 0); in ext4_ext_clear_bb()
6154 if (!IS_ERR_OR_NULL(path)) { in ext4_ext_clear_bb()
6155 for (j = 0; j < path->p_depth; j++) { in ext4_ext_clear_bb()
6158 path[j].p_block, 1, 0); in ext4_ext_clear_bb()
6160 0, path[j].p_block, 1, 1); in ext4_ext_clear_bb()
6162 ext4_ext_drop_refs(path); in ext4_ext_clear_bb()
6163 kfree(path); in ext4_ext_clear_bb()