Lines Matching refs:path
141 struct ext4_ext_path *path) in ext4_ext_get_access() argument
143 if (path->p_bh) { in ext4_ext_get_access()
145 BUFFER_TRACE(path->p_bh, "get_write_access"); in ext4_ext_get_access()
146 return ext4_journal_get_write_access(handle, path->p_bh); in ext4_ext_get_access()
160 struct inode *inode, struct ext4_ext_path *path) in __ext4_ext_dirty() argument
165 if (path->p_bh) { in __ext4_ext_dirty()
166 ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh)); in __ext4_ext_dirty()
169 inode, path->p_bh); in __ext4_ext_dirty()
178 struct ext4_ext_path *path, in ext4_ext_find_goal() argument
181 if (path) { in ext4_ext_find_goal()
182 int depth = path->p_depth; in ext4_ext_find_goal()
202 ex = path[depth].p_ext; in ext4_ext_find_goal()
215 if (path[depth].p_bh) in ext4_ext_find_goal()
216 return path[depth].p_bh->b_blocknr; in ext4_ext_find_goal()
228 struct ext4_ext_path *path, in ext4_ext_new_meta_block() argument
233 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); in ext4_ext_new_meta_block()
298 struct ext4_ext_path *path = *ppath; in ext4_force_split_extent_at() local
299 int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); in ext4_force_split_extent_at()
582 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
592 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_precache()
594 if (path == NULL) { in ext4_ext_precache()
602 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
603 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
606 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
613 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
614 brelse(path[i].p_bh); in ext4_ext_precache()
615 path[i].p_bh = NULL; in ext4_ext_precache()
620 ext4_idx_pblock(path[i].p_idx++), in ext4_ext_precache()
628 path[i].p_bh = bh; in ext4_ext_precache()
629 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
630 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
635 ext4_ext_drop_refs(path); in ext4_ext_precache()
636 kfree(path); in ext4_ext_precache()
641 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
643 int k, l = path->p_depth; in ext4_ext_show_path()
646 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
647 if (path->p_idx) { in ext4_ext_show_path()
648 ext_debug(" %d->%llu", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
649 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
650 } else if (path->p_ext) { in ext4_ext_show_path()
652 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
653 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
654 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
655 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
662 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
669 if (!path) in ext4_ext_show_leaf()
672 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
685 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
693 idx = path[level].p_idx; in ext4_ext_show_move()
694 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
705 ex = path[depth].p_ext; in ext4_ext_show_move()
706 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
718 #define ext4_ext_show_path(inode, path) argument
719 #define ext4_ext_show_leaf(inode, path) argument
720 #define ext4_ext_show_move(inode, path, newblock, level) argument
723 void ext4_ext_drop_refs(struct ext4_ext_path *path) in ext4_ext_drop_refs() argument
727 if (!path) in ext4_ext_drop_refs()
729 depth = path->p_depth; in ext4_ext_drop_refs()
730 for (i = 0; i <= depth; i++, path++) in ext4_ext_drop_refs()
731 if (path->p_bh) { in ext4_ext_drop_refs()
732 brelse(path->p_bh); in ext4_ext_drop_refs()
733 path->p_bh = NULL; in ext4_ext_drop_refs()
744 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
746 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
765 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
766 ext_debug(" -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
767 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
791 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
804 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
806 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
833 path->p_ext = l - 1; in ext4_ext_binsearch()
835 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
836 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
837 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
838 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
853 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
879 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
892 if (path) { in ext4_find_extent()
893 ext4_ext_drop_refs(path); in ext4_find_extent()
894 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
895 kfree(path); in ext4_find_extent()
896 *orig_path = path = NULL; in ext4_find_extent()
899 if (!path) { in ext4_find_extent()
901 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2), in ext4_find_extent()
903 if (unlikely(!path)) in ext4_find_extent()
905 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
907 path[0].p_hdr = eh; in ext4_find_extent()
908 path[0].p_bh = NULL; in ext4_find_extent()
918 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
919 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
920 path[ppos].p_depth = i; in ext4_find_extent()
921 path[ppos].p_ext = NULL; in ext4_find_extent()
923 bh = read_extent_tree_block(inode, path[ppos].p_block, --i, in ext4_find_extent()
939 path[ppos].p_bh = bh; in ext4_find_extent()
940 path[ppos].p_hdr = eh; in ext4_find_extent()
943 path[ppos].p_depth = i; in ext4_find_extent()
944 path[ppos].p_ext = NULL; in ext4_find_extent()
945 path[ppos].p_idx = NULL; in ext4_find_extent()
948 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
950 if (path[ppos].p_ext) in ext4_find_extent()
951 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
953 ext4_ext_show_path(inode, path); in ext4_find_extent()
955 return path; in ext4_find_extent()
958 ext4_ext_drop_refs(path); in ext4_find_extent()
959 kfree(path); in ext4_find_extent()
1048 struct ext4_ext_path *path, in ext4_ext_split() argument
1067 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1071 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1072 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1102 newblock = ext4_ext_new_meta_block(handle, inode, path, in ext4_ext_split()
1135 if (unlikely(path[depth].p_hdr->eh_entries != in ext4_ext_split()
1136 path[depth].p_hdr->eh_max)) { in ext4_ext_split()
1138 path[depth].p_hdr->eh_entries, in ext4_ext_split()
1139 path[depth].p_hdr->eh_max); in ext4_ext_split()
1144 m = EXT_MAX_EXTENT(path[depth].p_hdr) - path[depth].p_ext++; in ext4_ext_split()
1145 ext4_ext_show_move(inode, path, newblock, depth); in ext4_ext_split()
1149 memmove(ex, path[depth].p_ext, sizeof(struct ext4_extent) * m); in ext4_ext_split()
1169 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_split()
1172 le16_add_cpu(&path[depth].p_hdr->eh_entries, -m); in ext4_ext_split()
1173 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_split()
1219 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1220 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1223 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1228 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1229 ext_debug("cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1230 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1231 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1233 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1254 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1257 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1258 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1267 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1390 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1398 curp = path + depth; in ext4_ext_create_new_leaf()
1409 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1414 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1417 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1418 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1426 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1429 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1430 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1439 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1457 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1464 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1468 depth = path->p_depth; in ext4_ext_search_left()
1471 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1478 ex = path[depth].p_ext; in ext4_ext_search_left()
1481 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1488 ix = path[depth].p_idx; in ext4_ext_search_left()
1489 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1493 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? in ext4_ext_search_left()
1494 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, in ext4_ext_search_left()
1522 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1534 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1538 depth = path->p_depth; in ext4_ext_search_right()
1541 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1548 ex = path[depth].p_ext; in ext4_ext_search_right()
1551 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1558 ix = path[depth].p_idx; in ext4_ext_search_right()
1559 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1576 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1584 ix = path[depth].p_idx; in ext4_ext_search_right()
1585 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1598 while (++depth < path->p_depth) { in ext4_ext_search_right()
1601 path->p_depth - depth, 0); in ext4_ext_search_right()
1610 bh = read_extent_tree_block(inode, block, 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 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1645 if (path[depth].p_ext && in ext4_ext_next_allocated_block()
1646 path[depth].p_ext != in ext4_ext_next_allocated_block()
1647 EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1648 return le32_to_cpu(path[depth].p_ext[1].ee_block); in ext4_ext_next_allocated_block()
1651 if (path[depth].p_idx != in ext4_ext_next_allocated_block()
1652 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1653 return le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_allocated_block()
1665 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1669 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1670 depth = path->p_depth; in ext4_ext_next_leaf_block()
1680 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1681 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1683 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1697 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1705 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1706 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1728 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1729 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1732 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1733 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1739 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1741 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1744 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1745 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1799 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1807 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1808 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1841 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1847 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1848 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1849 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1863 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1864 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1868 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1869 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1870 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1871 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1872 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1873 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1875 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1886 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1893 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1894 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1897 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1900 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1902 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1916 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1925 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1927 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1934 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1966 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1982 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1983 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1984 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
2022 path + depth); in ext4_ext_insert_extent()
2030 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2048 path + depth); in ext4_ext_insert_extent()
2059 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2066 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2074 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2081 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2086 path = npath; in ext4_ext_insert_extent()
2104 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2107 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2109 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2159 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2167 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2171 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2175 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2187 struct ext4_ext_path *path = NULL; in ext4_fill_fiemap_extents() local
2201 path = ext4_find_extent(inode, block, &path, 0); in ext4_fill_fiemap_extents()
2202 if (IS_ERR(path)) { in ext4_fill_fiemap_extents()
2204 err = PTR_ERR(path); in ext4_fill_fiemap_extents()
2205 path = NULL; in ext4_fill_fiemap_extents()
2210 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_fill_fiemap_extents()
2216 ex = path[depth].p_ext; in ext4_fill_fiemap_extents()
2217 next = ext4_ext_next_allocated_block(path); in ext4_fill_fiemap_extents()
2327 ext4_ext_drop_refs(path); in ext4_fill_fiemap_extents()
2328 kfree(path); in ext4_fill_fiemap_extents()
2338 ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_put_gap_in_cache() argument
2347 ex = path[depth].p_ext; in ext4_ext_put_gap_in_cache()
2366 next = ext4_ext_next_allocated_block(path); in ext4_ext_put_gap_in_cache()
2393 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2400 path = path + depth; in ext4_ext_rm_idx()
2401 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2402 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2406 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2410 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2411 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2413 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2416 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2417 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2427 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2429 path--; in ext4_ext_rm_idx()
2430 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2433 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2434 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2449 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2451 if (path) { in ext4_ext_calc_credits_for_single_extent()
2456 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2457 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2630 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2648 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2649 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2650 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2651 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2656 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2675 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2733 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2774 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2786 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2808 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2809 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2820 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2822 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2824 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2831 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2841 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2869 path = ext4_find_extent(inode, end, NULL, EXT4_EX_NOCACHE); in ext4_ext_remove_space()
2870 if (IS_ERR(path)) { in ext4_ext_remove_space()
2872 return PTR_ERR(path); in ext4_ext_remove_space()
2876 ex = path[depth].p_ext; in ext4_ext_remove_space()
2915 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2930 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2944 if (path) { in ext4_ext_remove_space()
2947 path[k].p_block = in ext4_ext_remove_space()
2948 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2950 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_remove_space()
2952 if (path == NULL) { in ext4_ext_remove_space()
2956 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2957 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2960 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2970 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2974 brelse(path[i].p_bh); in ext4_ext_remove_space()
2975 path[i].p_bh = NULL; in ext4_ext_remove_space()
2981 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2983 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2986 if (!path[i].p_idx) { in ext4_ext_remove_space()
2988 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2989 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2991 path[i].p_hdr, in ext4_ext_remove_space()
2992 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2995 path[i].p_idx--; in ext4_ext_remove_space()
2999 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
3000 path[i].p_idx); in ext4_ext_remove_space()
3001 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
3005 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
3006 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
3008 ext4_idx_pblock(path[i].p_idx), depth - i - 1, in ext4_ext_remove_space()
3022 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
3026 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
3030 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
3034 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
3037 brelse(path[i].p_bh); in ext4_ext_remove_space()
3038 path[i].p_bh = NULL; in ext4_ext_remove_space()
3045 partial_cluster, path->p_hdr->eh_entries); in ext4_ext_remove_space()
3062 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3067 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3072 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3076 ext4_ext_drop_refs(path); in ext4_ext_remove_space()
3077 kfree(path); in ext4_ext_remove_space()
3078 path = NULL; in ext4_ext_remove_space()
3202 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3216 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3219 ex = path[depth].p_ext; in ext4_split_extent_at()
3230 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3246 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3248 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3262 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3306 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3307 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3322 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3325 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3347 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3357 ex = path[depth].p_ext; in ext4_split_extent()
3381 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_split_extent()
3382 if (IS_ERR(path)) in ext4_split_extent()
3383 return PTR_ERR(path); in ext4_split_extent()
3385 ex = path[depth].p_ext; in ext4_split_extent()
3407 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3438 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3461 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3462 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3515 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3561 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3583 ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3586 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3614 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3618 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_ext_convert_to_initialized()
3619 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_convert_to_initialized()
3706 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3726 ex = path[depth].p_ext; in ext4_split_convert_extents()
3748 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3756 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3781 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3782 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3783 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3785 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3788 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3797 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3800 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3802 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3819 struct ext4_ext_path *path, in check_eofblocks_fl() argument
3830 eh = path[depth].p_hdr; in check_eofblocks_fl()
3860 if (path[i].p_idx != EXT_LAST_INDEX(path[i].p_hdr)) in check_eofblocks_fl()
3981 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3996 ex = path[depth].p_ext; in convert_initialized_extent()
4009 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
4010 if (IS_ERR(path)) in convert_initialized_extent()
4011 return PTR_ERR(path); in convert_initialized_extent()
4013 ex = path[depth].p_ext; in convert_initialized_extent()
4021 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
4030 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
4033 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
4036 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
4039 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, map->m_len); in convert_initialized_extent()
4055 struct ext4_ext_path *path = *ppath; in ext4_ext_handle_unwritten_extents() local
4064 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4100 path, map->m_len); in ext4_ext_handle_unwritten_extents()
4179 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, in ext4_ext_handle_unwritten_extents()
4187 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4238 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4284 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4318 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4336 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4337 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4338 err = PTR_ERR(path); in ext4_ext_map_blocks()
4339 path = NULL; in ext4_ext_map_blocks()
4350 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4354 path[depth].p_block); in ext4_ext_map_blocks()
4359 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4389 handle, inode, map, &path, in ext4_ext_map_blocks()
4396 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4415 ext4_ext_put_gap_in_cache(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4430 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4439 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4444 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4451 get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) { in ext4_ext_map_blocks()
4473 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4481 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4539 path, ar.len); in ext4_ext_map_blocks()
4541 err = ext4_ext_insert_extent(handle, inode, &path, in ext4_ext_map_blocks()
4657 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4662 ext4_ext_drop_refs(path); in ext4_ext_map_blocks()
4663 kfree(path); in ext4_ext_map_blocks()
5276 struct ext4_ext_path *path) in ext4_access_path() argument
5297 err = ext4_ext_get_access(handle, inode, path); in ext4_access_path()
5308 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5315 depth = path->p_depth; in ext4_ext_shift_path_extents()
5318 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5319 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5323 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5325 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5329 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5338 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5341 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5347 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5352 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5361 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5366 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5368 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5369 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5374 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5396 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5402 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, in ext4_ext_shift_extents()
5404 if (IS_ERR(path)) in ext4_ext_shift_extents()
5405 return PTR_ERR(path); in ext4_ext_shift_extents()
5407 depth = path->p_depth; in ext4_ext_shift_extents()
5408 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5420 path = ext4_find_extent(inode, start - 1, &path, in ext4_ext_shift_extents()
5422 if (IS_ERR(path)) in ext4_ext_shift_extents()
5423 return PTR_ERR(path); in ext4_ext_shift_extents()
5424 depth = path->p_depth; in ext4_ext_shift_extents()
5425 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5464 path = ext4_find_extent(inode, *iterator, &path, in ext4_ext_shift_extents()
5466 if (IS_ERR(path)) in ext4_ext_shift_extents()
5467 return PTR_ERR(path); in ext4_ext_shift_extents()
5468 depth = path->p_depth; in ext4_ext_shift_extents()
5469 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5478 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5479 path[depth].p_ext++; in ext4_ext_shift_extents()
5481 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5487 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5491 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5500 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5502 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5508 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5509 kfree(path); in ext4_ext_shift_extents()
5667 struct ext4_ext_path *path; in ext4_insert_range() local
5760 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5761 if (IS_ERR(path)) { in ext4_insert_range()
5767 extent = path[depth].p_ext; in ext4_insert_range()
5781 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5788 ext4_ext_drop_refs(path); in ext4_insert_range()
5789 kfree(path); in ext4_insert_range()
5795 ext4_ext_drop_refs(path); in ext4_insert_range()
5796 kfree(path); in ext4_insert_range()