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()
569 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
579 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_precache()
581 if (path == NULL) { in ext4_ext_precache()
589 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
590 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
593 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
600 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
601 brelse(path[i].p_bh); in ext4_ext_precache()
602 path[i].p_bh = NULL; in ext4_ext_precache()
607 ext4_idx_pblock(path[i].p_idx++), in ext4_ext_precache()
615 path[i].p_bh = bh; in ext4_ext_precache()
616 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
617 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
622 ext4_ext_drop_refs(path); in ext4_ext_precache()
623 kfree(path); in ext4_ext_precache()
628 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
630 int k, l = path->p_depth; in ext4_ext_show_path()
633 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
634 if (path->p_idx) { in ext4_ext_show_path()
635 ext_debug(" %d->%llu", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
636 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
637 } else if (path->p_ext) { in ext4_ext_show_path()
639 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
640 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
641 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
642 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
649 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
656 if (!path) in ext4_ext_show_leaf()
659 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
672 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
680 idx = path[level].p_idx; in ext4_ext_show_move()
681 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
692 ex = path[depth].p_ext; in ext4_ext_show_move()
693 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
705 #define ext4_ext_show_path(inode, path) argument
706 #define ext4_ext_show_leaf(inode, path) argument
707 #define ext4_ext_show_move(inode, path, newblock, level) argument
710 void ext4_ext_drop_refs(struct ext4_ext_path *path) in ext4_ext_drop_refs() argument
714 if (!path) in ext4_ext_drop_refs()
716 depth = path->p_depth; in ext4_ext_drop_refs()
717 for (i = 0; i <= depth; i++, path++) in ext4_ext_drop_refs()
718 if (path->p_bh) { in ext4_ext_drop_refs()
719 brelse(path->p_bh); in ext4_ext_drop_refs()
720 path->p_bh = NULL; in ext4_ext_drop_refs()
731 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
733 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
752 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
753 ext_debug(" -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
754 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
778 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
791 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
793 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
820 path->p_ext = l - 1; in ext4_ext_binsearch()
822 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
823 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
824 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
825 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
840 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
865 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
872 if (path) { in ext4_find_extent()
873 ext4_ext_drop_refs(path); in ext4_find_extent()
874 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
875 kfree(path); in ext4_find_extent()
876 *orig_path = path = NULL; in ext4_find_extent()
879 if (!path) { in ext4_find_extent()
881 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2), in ext4_find_extent()
883 if (unlikely(!path)) in ext4_find_extent()
885 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
887 path[0].p_hdr = eh; in ext4_find_extent()
888 path[0].p_bh = NULL; in ext4_find_extent()
896 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
897 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
898 path[ppos].p_depth = i; in ext4_find_extent()
899 path[ppos].p_ext = NULL; in ext4_find_extent()
901 bh = read_extent_tree_block(inode, path[ppos].p_block, --i, in ext4_find_extent()
917 path[ppos].p_bh = bh; in ext4_find_extent()
918 path[ppos].p_hdr = eh; in ext4_find_extent()
921 path[ppos].p_depth = i; in ext4_find_extent()
922 path[ppos].p_ext = NULL; in ext4_find_extent()
923 path[ppos].p_idx = NULL; in ext4_find_extent()
926 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
928 if (path[ppos].p_ext) in ext4_find_extent()
929 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
931 ext4_ext_show_path(inode, path); in ext4_find_extent()
933 return path; in ext4_find_extent()
936 ext4_ext_drop_refs(path); in ext4_find_extent()
937 kfree(path); in ext4_find_extent()
1026 struct ext4_ext_path *path, in ext4_ext_split() argument
1044 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1048 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1049 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1079 newblock = ext4_ext_new_meta_block(handle, inode, path, in ext4_ext_split()
1111 if (unlikely(path[depth].p_hdr->eh_entries != in ext4_ext_split()
1112 path[depth].p_hdr->eh_max)) { in ext4_ext_split()
1114 path[depth].p_hdr->eh_entries, in ext4_ext_split()
1115 path[depth].p_hdr->eh_max); in ext4_ext_split()
1120 m = EXT_MAX_EXTENT(path[depth].p_hdr) - path[depth].p_ext++; in ext4_ext_split()
1121 ext4_ext_show_move(inode, path, newblock, depth); in ext4_ext_split()
1125 memmove(ex, path[depth].p_ext, sizeof(struct ext4_extent) * m); in ext4_ext_split()
1141 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_split()
1144 le16_add_cpu(&path[depth].p_hdr->eh_entries, -m); in ext4_ext_split()
1145 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_split()
1190 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1191 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1194 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1199 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1200 ext_debug("cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1201 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1202 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1204 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1220 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1223 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1224 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1233 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1353 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1361 curp = path + depth; in ext4_ext_create_new_leaf()
1372 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1377 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1380 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1381 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1389 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1392 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1393 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1402 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1420 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1427 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1431 depth = path->p_depth; in ext4_ext_search_left()
1434 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1441 ex = path[depth].p_ext; in ext4_ext_search_left()
1444 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1451 ix = path[depth].p_idx; in ext4_ext_search_left()
1452 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1456 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? in ext4_ext_search_left()
1457 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, in ext4_ext_search_left()
1485 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1497 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1501 depth = path->p_depth; in ext4_ext_search_right()
1504 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1511 ex = path[depth].p_ext; in ext4_ext_search_right()
1514 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1521 ix = path[depth].p_idx; in ext4_ext_search_right()
1522 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1539 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1547 ix = path[depth].p_idx; in ext4_ext_search_right()
1548 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1561 while (++depth < path->p_depth) { in ext4_ext_search_right()
1564 path->p_depth - depth, 0); in ext4_ext_search_right()
1573 bh = read_extent_tree_block(inode, block, path->p_depth - depth, 0); in ext4_ext_search_right()
1595 ext4_ext_next_allocated_block(struct ext4_ext_path *path) in ext4_ext_next_allocated_block() argument
1599 BUG_ON(path == NULL); in ext4_ext_next_allocated_block()
1600 depth = path->p_depth; in ext4_ext_next_allocated_block()
1602 if (depth == 0 && path->p_ext == NULL) in ext4_ext_next_allocated_block()
1606 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1608 if (path[depth].p_ext && in ext4_ext_next_allocated_block()
1609 path[depth].p_ext != in ext4_ext_next_allocated_block()
1610 EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1611 return le32_to_cpu(path[depth].p_ext[1].ee_block); in ext4_ext_next_allocated_block()
1614 if (path[depth].p_idx != in ext4_ext_next_allocated_block()
1615 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1616 return le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_allocated_block()
1628 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1632 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1633 depth = path->p_depth; in ext4_ext_next_leaf_block()
1643 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1644 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1646 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1660 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1668 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1669 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1691 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1692 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1695 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1696 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1702 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1704 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1707 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1708 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1762 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1770 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1771 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1804 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1810 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1811 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1812 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1826 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1827 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1831 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1832 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1833 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1834 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1835 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1836 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1838 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1849 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1856 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1857 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1860 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1863 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1865 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1879 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1888 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1890 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1897 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1929 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1945 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1946 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1947 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
1985 path + depth); in ext4_ext_insert_extent()
1993 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2011 path + depth); in ext4_ext_insert_extent()
2022 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2029 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2037 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2044 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2049 path = npath; in ext4_ext_insert_extent()
2067 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2070 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2072 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2122 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2130 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2134 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2138 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2150 struct ext4_ext_path *path = NULL; in ext4_fill_fiemap_extents() local
2164 path = ext4_find_extent(inode, block, &path, 0); in ext4_fill_fiemap_extents()
2165 if (IS_ERR(path)) { in ext4_fill_fiemap_extents()
2167 err = PTR_ERR(path); in ext4_fill_fiemap_extents()
2168 path = NULL; in ext4_fill_fiemap_extents()
2173 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_fill_fiemap_extents()
2179 ex = path[depth].p_ext; in ext4_fill_fiemap_extents()
2180 next = ext4_ext_next_allocated_block(path); in ext4_fill_fiemap_extents()
2290 ext4_ext_drop_refs(path); in ext4_fill_fiemap_extents()
2291 kfree(path); in ext4_fill_fiemap_extents()
2301 ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_put_gap_in_cache() argument
2310 ex = path[depth].p_ext; in ext4_ext_put_gap_in_cache()
2329 next = ext4_ext_next_allocated_block(path); in ext4_ext_put_gap_in_cache()
2356 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2363 path = path + depth; in ext4_ext_rm_idx()
2364 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2365 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2369 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2373 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2374 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2376 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2379 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2380 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2390 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2392 path--; in ext4_ext_rm_idx()
2393 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2396 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2397 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2412 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2414 if (path) { in ext4_ext_calc_credits_for_single_extent()
2419 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2420 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2593 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2611 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2612 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2613 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2614 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2619 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2638 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2696 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2737 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2749 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2771 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2772 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2783 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2785 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2787 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2794 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2804 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2832 path = ext4_find_extent(inode, end, NULL, EXT4_EX_NOCACHE); in ext4_ext_remove_space()
2833 if (IS_ERR(path)) { in ext4_ext_remove_space()
2835 return PTR_ERR(path); in ext4_ext_remove_space()
2839 ex = path[depth].p_ext; in ext4_ext_remove_space()
2878 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2893 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2907 if (path) { in ext4_ext_remove_space()
2910 path[k].p_block = in ext4_ext_remove_space()
2911 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2913 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_remove_space()
2915 if (path == NULL) { in ext4_ext_remove_space()
2919 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2920 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2923 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2933 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2937 brelse(path[i].p_bh); in ext4_ext_remove_space()
2938 path[i].p_bh = NULL; in ext4_ext_remove_space()
2944 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2946 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2949 if (!path[i].p_idx) { in ext4_ext_remove_space()
2951 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2952 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2954 path[i].p_hdr, in ext4_ext_remove_space()
2955 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2958 path[i].p_idx--; in ext4_ext_remove_space()
2962 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2963 path[i].p_idx); in ext4_ext_remove_space()
2964 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2968 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2969 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2971 ext4_idx_pblock(path[i].p_idx), depth - i - 1, in ext4_ext_remove_space()
2985 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
2989 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
2993 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
2997 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
3000 brelse(path[i].p_bh); in ext4_ext_remove_space()
3001 path[i].p_bh = NULL; in ext4_ext_remove_space()
3008 partial_cluster, path->p_hdr->eh_entries); in ext4_ext_remove_space()
3025 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3030 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3035 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3039 ext4_ext_drop_refs(path); in ext4_ext_remove_space()
3040 kfree(path); in ext4_ext_remove_space()
3041 path = NULL; in ext4_ext_remove_space()
3165 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3179 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3182 ex = path[depth].p_ext; in ext4_split_extent_at()
3193 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3209 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3211 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3225 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3267 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3268 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3280 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3285 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3307 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3317 ex = path[depth].p_ext; in ext4_split_extent()
3341 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_split_extent()
3342 if (IS_ERR(path)) in ext4_split_extent()
3343 return PTR_ERR(path); in ext4_split_extent()
3345 ex = path[depth].p_ext; in ext4_split_extent()
3367 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3398 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3421 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3422 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3475 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3521 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3543 ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3546 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3574 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3578 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_ext_convert_to_initialized()
3579 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_convert_to_initialized()
3666 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3686 ex = path[depth].p_ext; in ext4_split_convert_extents()
3708 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3716 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3741 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3742 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3743 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3745 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3748 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3757 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3760 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3762 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3779 struct ext4_ext_path *path, in check_eofblocks_fl() argument
3790 eh = path[depth].p_hdr; in check_eofblocks_fl()
3820 if (path[i].p_idx != EXT_LAST_INDEX(path[i].p_hdr)) in check_eofblocks_fl()
3941 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3956 ex = path[depth].p_ext; in convert_initialized_extent()
3969 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3970 if (IS_ERR(path)) in convert_initialized_extent()
3971 return PTR_ERR(path); in convert_initialized_extent()
3973 ex = path[depth].p_ext; in convert_initialized_extent()
3981 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3990 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3993 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3996 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3999 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, map->m_len); in convert_initialized_extent()
4015 struct ext4_ext_path *path = *ppath; in ext4_ext_handle_unwritten_extents() local
4024 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4060 path, map->m_len); in ext4_ext_handle_unwritten_extents()
4139 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, in ext4_ext_handle_unwritten_extents()
4147 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4198 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4244 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4278 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4296 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4297 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4298 err = PTR_ERR(path); in ext4_ext_map_blocks()
4299 path = NULL; in ext4_ext_map_blocks()
4310 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4314 path[depth].p_block); in ext4_ext_map_blocks()
4319 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4349 handle, inode, map, &path, in ext4_ext_map_blocks()
4356 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4375 ext4_ext_put_gap_in_cache(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4390 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4399 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4404 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4411 get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) { in ext4_ext_map_blocks()
4433 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4441 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4499 path, ar.len); in ext4_ext_map_blocks()
4501 err = ext4_ext_insert_extent(handle, inode, &path, in ext4_ext_map_blocks()
4617 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4622 ext4_ext_drop_refs(path); in ext4_ext_map_blocks()
4623 kfree(path); in ext4_ext_map_blocks()
5231 struct ext4_ext_path *path) in ext4_access_path() argument
5252 err = ext4_ext_get_access(handle, inode, path); in ext4_access_path()
5263 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5270 depth = path->p_depth; in ext4_ext_shift_path_extents()
5273 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5274 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5278 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5280 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5284 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5293 EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5296 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5302 ext4_ext_try_to_merge_right(inode, path, in ext4_ext_shift_path_extents()
5307 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5316 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5321 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5323 le32_add_cpu(&path[depth].p_idx->ei_block, shift); in ext4_ext_shift_path_extents()
5324 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5329 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5351 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5357 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, 0); in ext4_ext_shift_extents()
5358 if (IS_ERR(path)) in ext4_ext_shift_extents()
5359 return PTR_ERR(path); in ext4_ext_shift_extents()
5361 depth = path->p_depth; in ext4_ext_shift_extents()
5362 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5374 path = ext4_find_extent(inode, start - 1, &path, 0); in ext4_ext_shift_extents()
5375 if (IS_ERR(path)) in ext4_ext_shift_extents()
5376 return PTR_ERR(path); in ext4_ext_shift_extents()
5377 depth = path->p_depth; in ext4_ext_shift_extents()
5378 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5390 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5391 kfree(path); in ext4_ext_shift_extents()
5408 path = ext4_find_extent(inode, *iterator, &path, 0); in ext4_ext_shift_extents()
5409 if (IS_ERR(path)) in ext4_ext_shift_extents()
5410 return PTR_ERR(path); in ext4_ext_shift_extents()
5411 depth = path->p_depth; in ext4_ext_shift_extents()
5412 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5421 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5422 path[depth].p_ext++; in ext4_ext_shift_extents()
5424 *iterator = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5430 extent = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5434 extent = EXT_FIRST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_extents()
5440 path[depth].p_ext = extent; in ext4_ext_shift_extents()
5442 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5448 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5449 kfree(path); in ext4_ext_shift_extents()
5606 struct ext4_ext_path *path; in ext4_insert_range() local
5699 path = ext4_find_extent(inode, offset_lblk, NULL, 0); in ext4_insert_range()
5700 if (IS_ERR(path)) { in ext4_insert_range()
5706 extent = path[depth].p_ext; in ext4_insert_range()
5720 ret = ext4_split_extent_at(handle, inode, &path, in ext4_insert_range()
5727 ext4_ext_drop_refs(path); in ext4_insert_range()
5728 kfree(path); in ext4_insert_range()