Lines Matching refs:path

140 				struct ext4_ext_path *path)  in ext4_ext_get_access()  argument
142 if (path->p_bh) { in ext4_ext_get_access()
144 BUFFER_TRACE(path->p_bh, "get_write_access"); in ext4_ext_get_access()
145 return ext4_journal_get_write_access(handle, path->p_bh); in ext4_ext_get_access()
159 struct inode *inode, struct ext4_ext_path *path) in __ext4_ext_dirty() argument
164 if (path->p_bh) { in __ext4_ext_dirty()
165 ext4_extent_block_csum_set(inode, ext_block_hdr(path->p_bh)); in __ext4_ext_dirty()
168 inode, path->p_bh); in __ext4_ext_dirty()
177 struct ext4_ext_path *path, in ext4_ext_find_goal() argument
180 if (path) { in ext4_ext_find_goal()
181 int depth = path->p_depth; in ext4_ext_find_goal()
201 ex = path[depth].p_ext; in ext4_ext_find_goal()
214 if (path[depth].p_bh) in ext4_ext_find_goal()
215 return path[depth].p_bh->b_blocknr; in ext4_ext_find_goal()
227 struct ext4_ext_path *path, in ext4_ext_new_meta_block() argument
232 goal = ext4_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block)); in ext4_ext_new_meta_block()
297 struct ext4_ext_path *path = *ppath; in ext4_force_split_extent_at() local
298 int unwritten = ext4_ext_is_unwritten(path[path->p_depth].p_ext); in ext4_force_split_extent_at()
567 struct ext4_ext_path *path = NULL; in ext4_ext_precache() local
577 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_precache()
579 if (path == NULL) { in ext4_ext_precache()
587 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_precache()
588 ret = ext4_ext_check(inode, path[0].p_hdr, depth, 0); in ext4_ext_precache()
591 path[0].p_idx = EXT_FIRST_INDEX(path[0].p_hdr); in ext4_ext_precache()
598 path[i].p_idx > EXT_LAST_INDEX(path[i].p_hdr)) { in ext4_ext_precache()
599 brelse(path[i].p_bh); in ext4_ext_precache()
600 path[i].p_bh = NULL; in ext4_ext_precache()
605 ext4_idx_pblock(path[i].p_idx++), in ext4_ext_precache()
613 path[i].p_bh = bh; in ext4_ext_precache()
614 path[i].p_hdr = ext_block_hdr(bh); in ext4_ext_precache()
615 path[i].p_idx = EXT_FIRST_INDEX(path[i].p_hdr); in ext4_ext_precache()
620 ext4_ext_drop_refs(path); in ext4_ext_precache()
621 kfree(path); in ext4_ext_precache()
626 static void ext4_ext_show_path(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_path() argument
628 int k, l = path->p_depth; in ext4_ext_show_path()
631 for (k = 0; k <= l; k++, path++) { in ext4_ext_show_path()
632 if (path->p_idx) { in ext4_ext_show_path()
633 ext_debug(" %d->%llu", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_show_path()
634 ext4_idx_pblock(path->p_idx)); in ext4_ext_show_path()
635 } else if (path->p_ext) { in ext4_ext_show_path()
637 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_show_path()
638 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_show_path()
639 ext4_ext_get_actual_len(path->p_ext), in ext4_ext_show_path()
640 ext4_ext_pblock(path->p_ext)); in ext4_ext_show_path()
647 static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path) in ext4_ext_show_leaf() argument
654 if (!path) in ext4_ext_show_leaf()
657 eh = path[depth].p_hdr; in ext4_ext_show_leaf()
670 static void ext4_ext_show_move(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_show_move() argument
678 idx = path[level].p_idx; in ext4_ext_show_move()
679 while (idx <= EXT_MAX_INDEX(path[level].p_hdr)) { in ext4_ext_show_move()
690 ex = path[depth].p_ext; in ext4_ext_show_move()
691 while (ex <= EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_show_move()
703 #define ext4_ext_show_path(inode, path) argument
704 #define ext4_ext_show_leaf(inode, path) argument
705 #define ext4_ext_show_move(inode, path, newblock, level) argument
708 void ext4_ext_drop_refs(struct ext4_ext_path *path) in ext4_ext_drop_refs() argument
712 if (!path) in ext4_ext_drop_refs()
714 depth = path->p_depth; in ext4_ext_drop_refs()
715 for (i = 0; i <= depth; i++, path++) in ext4_ext_drop_refs()
716 if (path->p_bh) { in ext4_ext_drop_refs()
717 brelse(path->p_bh); in ext4_ext_drop_refs()
718 path->p_bh = NULL; in ext4_ext_drop_refs()
729 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch_idx() argument
731 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch_idx()
750 path->p_idx = l - 1; in ext4_ext_binsearch_idx()
751 ext_debug(" -> %u->%lld ", le32_to_cpu(path->p_idx->ei_block), in ext4_ext_binsearch_idx()
752 ext4_idx_pblock(path->p_idx)); in ext4_ext_binsearch_idx()
776 BUG_ON(chix != path->p_idx); in ext4_ext_binsearch_idx()
789 struct ext4_ext_path *path, ext4_lblk_t block) in ext4_ext_binsearch() argument
791 struct ext4_extent_header *eh = path->p_hdr; in ext4_ext_binsearch()
818 path->p_ext = l - 1; in ext4_ext_binsearch()
820 le32_to_cpu(path->p_ext->ee_block), in ext4_ext_binsearch()
821 ext4_ext_pblock(path->p_ext), in ext4_ext_binsearch()
822 ext4_ext_is_unwritten(path->p_ext), in ext4_ext_binsearch()
823 ext4_ext_get_actual_len(path->p_ext)); in ext4_ext_binsearch()
838 BUG_ON(chex != path->p_ext); in ext4_ext_binsearch()
863 struct ext4_ext_path *path = orig_path ? *orig_path : NULL; in ext4_find_extent() local
870 if (path) { in ext4_find_extent()
871 ext4_ext_drop_refs(path); in ext4_find_extent()
872 if (depth > path[0].p_maxdepth) { in ext4_find_extent()
873 kfree(path); in ext4_find_extent()
874 *orig_path = path = NULL; in ext4_find_extent()
877 if (!path) { in ext4_find_extent()
879 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2), in ext4_find_extent()
881 if (unlikely(!path)) in ext4_find_extent()
883 path[0].p_maxdepth = depth + 1; in ext4_find_extent()
885 path[0].p_hdr = eh; in ext4_find_extent()
886 path[0].p_bh = NULL; in ext4_find_extent()
894 ext4_ext_binsearch_idx(inode, path + ppos, block); in ext4_find_extent()
895 path[ppos].p_block = ext4_idx_pblock(path[ppos].p_idx); in ext4_find_extent()
896 path[ppos].p_depth = i; in ext4_find_extent()
897 path[ppos].p_ext = NULL; in ext4_find_extent()
899 bh = read_extent_tree_block(inode, path[ppos].p_block, --i, in ext4_find_extent()
915 path[ppos].p_bh = bh; in ext4_find_extent()
916 path[ppos].p_hdr = eh; in ext4_find_extent()
919 path[ppos].p_depth = i; in ext4_find_extent()
920 path[ppos].p_ext = NULL; in ext4_find_extent()
921 path[ppos].p_idx = NULL; in ext4_find_extent()
924 ext4_ext_binsearch(inode, path + ppos, block); in ext4_find_extent()
926 if (path[ppos].p_ext) in ext4_find_extent()
927 path[ppos].p_block = ext4_ext_pblock(path[ppos].p_ext); in ext4_find_extent()
929 ext4_ext_show_path(inode, path); in ext4_find_extent()
931 return path; in ext4_find_extent()
934 ext4_ext_drop_refs(path); in ext4_find_extent()
935 kfree(path); in ext4_find_extent()
1024 struct ext4_ext_path *path, in ext4_ext_split() argument
1042 if (unlikely(path[depth].p_ext > EXT_MAX_EXTENT(path[depth].p_hdr))) { in ext4_ext_split()
1046 if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) { in ext4_ext_split()
1047 border = path[depth].p_ext[1].ee_block; in ext4_ext_split()
1077 newblock = ext4_ext_new_meta_block(handle, inode, path, in ext4_ext_split()
1109 if (unlikely(path[depth].p_hdr->eh_entries != in ext4_ext_split()
1110 path[depth].p_hdr->eh_max)) { in ext4_ext_split()
1112 path[depth].p_hdr->eh_entries, in ext4_ext_split()
1113 path[depth].p_hdr->eh_max); in ext4_ext_split()
1118 m = EXT_MAX_EXTENT(path[depth].p_hdr) - path[depth].p_ext++; in ext4_ext_split()
1119 ext4_ext_show_move(inode, path, newblock, depth); in ext4_ext_split()
1123 memmove(ex, path[depth].p_ext, sizeof(struct ext4_extent) * m); in ext4_ext_split()
1139 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_split()
1142 le16_add_cpu(&path[depth].p_hdr->eh_entries, -m); in ext4_ext_split()
1143 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_split()
1188 if (unlikely(EXT_MAX_INDEX(path[i].p_hdr) != in ext4_ext_split()
1189 EXT_LAST_INDEX(path[i].p_hdr))) { in ext4_ext_split()
1192 le32_to_cpu(path[i].p_ext->ee_block)); in ext4_ext_split()
1197 m = EXT_MAX_INDEX(path[i].p_hdr) - path[i].p_idx++; in ext4_ext_split()
1198 ext_debug("cur 0x%p, last 0x%p\n", path[i].p_idx, in ext4_ext_split()
1199 EXT_MAX_INDEX(path[i].p_hdr)); in ext4_ext_split()
1200 ext4_ext_show_move(inode, path, newblock, i); in ext4_ext_split()
1202 memmove(++fidx, path[i].p_idx, in ext4_ext_split()
1218 err = ext4_ext_get_access(handle, inode, path + i); in ext4_ext_split()
1221 le16_add_cpu(&path[i].p_hdr->eh_entries, -m); in ext4_ext_split()
1222 err = ext4_ext_dirty(handle, inode, path + i); in ext4_ext_split()
1231 err = ext4_ext_insert_index(handle, inode, path + at, in ext4_ext_split()
1351 struct ext4_ext_path *path = *ppath; in ext4_ext_create_new_leaf() local
1359 curp = path + depth; in ext4_ext_create_new_leaf()
1370 err = ext4_ext_split(handle, inode, mb_flags, path, newext, i); in ext4_ext_create_new_leaf()
1375 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1378 if (IS_ERR(path)) in ext4_ext_create_new_leaf()
1379 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1387 path = ext4_find_extent(inode, in ext4_ext_create_new_leaf()
1390 if (IS_ERR(path)) { in ext4_ext_create_new_leaf()
1391 err = PTR_ERR(path); in ext4_ext_create_new_leaf()
1400 if (path[depth].p_hdr->eh_entries == path[depth].p_hdr->eh_max) { in ext4_ext_create_new_leaf()
1418 struct ext4_ext_path *path, in ext4_ext_search_left() argument
1425 if (unlikely(path == NULL)) { in ext4_ext_search_left()
1429 depth = path->p_depth; in ext4_ext_search_left()
1432 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_left()
1439 ex = path[depth].p_ext; in ext4_ext_search_left()
1442 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_left()
1449 ix = path[depth].p_idx; in ext4_ext_search_left()
1450 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_left()
1454 EXT_FIRST_INDEX(path[depth].p_hdr) != NULL ? in ext4_ext_search_left()
1455 le32_to_cpu(EXT_FIRST_INDEX(path[depth].p_hdr)->ei_block) : 0, in ext4_ext_search_left()
1483 struct ext4_ext_path *path, in ext4_ext_search_right() argument
1495 if (unlikely(path == NULL)) { in ext4_ext_search_right()
1499 depth = path->p_depth; in ext4_ext_search_right()
1502 if (depth == 0 && path->p_ext == NULL) in ext4_ext_search_right()
1509 ex = path[depth].p_ext; in ext4_ext_search_right()
1512 if (unlikely(EXT_FIRST_EXTENT(path[depth].p_hdr) != ex)) { in ext4_ext_search_right()
1519 ix = path[depth].p_idx; in ext4_ext_search_right()
1520 if (unlikely(ix != EXT_FIRST_INDEX(path[depth].p_hdr))) { in ext4_ext_search_right()
1537 if (ex != EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_search_right()
1545 ix = path[depth].p_idx; in ext4_ext_search_right()
1546 if (ix != EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_search_right()
1559 while (++depth < path->p_depth) { in ext4_ext_search_right()
1562 path->p_depth - depth, 0); in ext4_ext_search_right()
1571 bh = read_extent_tree_block(inode, block, path->p_depth - depth, 0); in ext4_ext_search_right()
1593 ext4_ext_next_allocated_block(struct ext4_ext_path *path) in ext4_ext_next_allocated_block() argument
1597 BUG_ON(path == NULL); in ext4_ext_next_allocated_block()
1598 depth = path->p_depth; in ext4_ext_next_allocated_block()
1600 if (depth == 0 && path->p_ext == NULL) in ext4_ext_next_allocated_block()
1604 if (depth == path->p_depth) { in ext4_ext_next_allocated_block()
1606 if (path[depth].p_ext && in ext4_ext_next_allocated_block()
1607 path[depth].p_ext != in ext4_ext_next_allocated_block()
1608 EXT_LAST_EXTENT(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1609 return le32_to_cpu(path[depth].p_ext[1].ee_block); in ext4_ext_next_allocated_block()
1612 if (path[depth].p_idx != in ext4_ext_next_allocated_block()
1613 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_allocated_block()
1614 return le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_allocated_block()
1626 static ext4_lblk_t ext4_ext_next_leaf_block(struct ext4_ext_path *path) in ext4_ext_next_leaf_block() argument
1630 BUG_ON(path == NULL); in ext4_ext_next_leaf_block()
1631 depth = path->p_depth; in ext4_ext_next_leaf_block()
1641 if (path[depth].p_idx != in ext4_ext_next_leaf_block()
1642 EXT_LAST_INDEX(path[depth].p_hdr)) in ext4_ext_next_leaf_block()
1644 le32_to_cpu(path[depth].p_idx[1].ei_block); in ext4_ext_next_leaf_block()
1658 struct ext4_ext_path *path) in ext4_ext_correct_indexes() argument
1666 eh = path[depth].p_hdr; in ext4_ext_correct_indexes()
1667 ex = path[depth].p_ext; in ext4_ext_correct_indexes()
1689 border = path[depth].p_ext->ee_block; in ext4_ext_correct_indexes()
1690 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1693 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1694 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1700 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) in ext4_ext_correct_indexes()
1702 err = ext4_ext_get_access(handle, inode, path + k); in ext4_ext_correct_indexes()
1705 path[k].p_idx->ei_block = border; in ext4_ext_correct_indexes()
1706 err = ext4_ext_dirty(handle, inode, path + k); in ext4_ext_correct_indexes()
1760 struct ext4_ext_path *path, in ext4_ext_try_to_merge_right() argument
1768 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge_right()
1769 eh = path[depth].p_hdr; in ext4_ext_try_to_merge_right()
1802 struct ext4_ext_path *path) in ext4_ext_try_to_merge_up() argument
1808 if ((path[0].p_depth != 1) || in ext4_ext_try_to_merge_up()
1809 (le16_to_cpu(path[0].p_hdr->eh_entries) != 1) || in ext4_ext_try_to_merge_up()
1810 (le16_to_cpu(path[1].p_hdr->eh_entries) > max_root)) in ext4_ext_try_to_merge_up()
1824 blk = ext4_idx_pblock(path[0].p_idx); in ext4_ext_try_to_merge_up()
1825 s = le16_to_cpu(path[1].p_hdr->eh_entries) * in ext4_ext_try_to_merge_up()
1829 path[1].p_maxdepth = path[0].p_maxdepth; in ext4_ext_try_to_merge_up()
1830 memcpy(path[0].p_hdr, path[1].p_hdr, s); in ext4_ext_try_to_merge_up()
1831 path[0].p_depth = 0; in ext4_ext_try_to_merge_up()
1832 path[0].p_ext = EXT_FIRST_EXTENT(path[0].p_hdr) + in ext4_ext_try_to_merge_up()
1833 (path[1].p_ext - EXT_FIRST_EXTENT(path[1].p_hdr)); in ext4_ext_try_to_merge_up()
1834 path[0].p_hdr->eh_max = cpu_to_le16(max_root); in ext4_ext_try_to_merge_up()
1836 brelse(path[1].p_bh); in ext4_ext_try_to_merge_up()
1847 struct ext4_ext_path *path, in ext4_ext_try_to_merge() argument
1854 BUG_ON(path[depth].p_hdr == NULL); in ext4_ext_try_to_merge()
1855 eh = path[depth].p_hdr; in ext4_ext_try_to_merge()
1858 merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); in ext4_ext_try_to_merge()
1861 (void) ext4_ext_try_to_merge_right(inode, path, ex); in ext4_ext_try_to_merge()
1863 ext4_ext_try_to_merge_up(handle, inode, path); in ext4_ext_try_to_merge()
1877 struct ext4_ext_path *path) in ext4_ext_check_overlap() argument
1886 if (!path[depth].p_ext) in ext4_ext_check_overlap()
1888 b2 = EXT4_LBLK_CMASK(sbi, le32_to_cpu(path[depth].p_ext->ee_block)); in ext4_ext_check_overlap()
1895 b2 = ext4_ext_next_allocated_block(path); in ext4_ext_check_overlap()
1927 struct ext4_ext_path *path = *ppath; in ext4_ext_insert_extent() local
1943 ex = path[depth].p_ext; in ext4_ext_insert_extent()
1944 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
1945 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_insert_extent()
1983 path + depth); in ext4_ext_insert_extent()
1991 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2009 path + depth); in ext4_ext_insert_extent()
2020 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2027 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2035 next = ext4_ext_next_leaf_block(path); in ext4_ext_insert_extent()
2042 BUG_ON(npath->p_depth != path->p_depth); in ext4_ext_insert_extent()
2047 path = npath; in ext4_ext_insert_extent()
2065 eh = path[depth].p_hdr; in ext4_ext_insert_extent()
2068 nearex = path[depth].p_ext; in ext4_ext_insert_extent()
2070 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_insert_extent()
2120 path[depth].p_ext = nearex; in ext4_ext_insert_extent()
2128 ext4_ext_try_to_merge(handle, inode, path, nearex); in ext4_ext_insert_extent()
2132 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_insert_extent()
2136 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_insert_extent()
2148 struct ext4_ext_path *path = NULL; in ext4_fill_fiemap_extents() local
2162 path = ext4_find_extent(inode, block, &path, 0); in ext4_fill_fiemap_extents()
2163 if (IS_ERR(path)) { in ext4_fill_fiemap_extents()
2165 err = PTR_ERR(path); in ext4_fill_fiemap_extents()
2166 path = NULL; in ext4_fill_fiemap_extents()
2171 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_fill_fiemap_extents()
2177 ex = path[depth].p_ext; in ext4_fill_fiemap_extents()
2178 next = ext4_ext_next_allocated_block(path); in ext4_fill_fiemap_extents()
2288 ext4_ext_drop_refs(path); in ext4_fill_fiemap_extents()
2289 kfree(path); in ext4_fill_fiemap_extents()
2299 ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, in ext4_ext_put_gap_in_cache() argument
2308 ex = path[depth].p_ext; in ext4_ext_put_gap_in_cache()
2327 next = ext4_ext_next_allocated_block(path); in ext4_ext_put_gap_in_cache()
2354 struct ext4_ext_path *path, int depth) in ext4_ext_rm_idx() argument
2361 path = path + depth; in ext4_ext_rm_idx()
2362 leaf = ext4_idx_pblock(path->p_idx); in ext4_ext_rm_idx()
2363 if (unlikely(path->p_hdr->eh_entries == 0)) { in ext4_ext_rm_idx()
2367 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2371 if (path->p_idx != EXT_LAST_INDEX(path->p_hdr)) { in ext4_ext_rm_idx()
2372 int len = EXT_LAST_INDEX(path->p_hdr) - path->p_idx; in ext4_ext_rm_idx()
2374 memmove(path->p_idx, path->p_idx + 1, len); in ext4_ext_rm_idx()
2377 le16_add_cpu(&path->p_hdr->eh_entries, -1); in ext4_ext_rm_idx()
2378 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2388 if (path->p_idx != EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_rm_idx()
2390 path--; in ext4_ext_rm_idx()
2391 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_rm_idx()
2394 path->p_idx->ei_block = (path+1)->p_idx->ei_block; in ext4_ext_rm_idx()
2395 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_rm_idx()
2410 struct ext4_ext_path *path) in ext4_ext_calc_credits_for_single_extent() argument
2412 if (path) { in ext4_ext_calc_credits_for_single_extent()
2417 if (le16_to_cpu(path[depth].p_hdr->eh_entries) in ext4_ext_calc_credits_for_single_extent()
2418 < le16_to_cpu(path[depth].p_hdr->eh_max)) { in ext4_ext_calc_credits_for_single_extent()
2591 struct ext4_ext_path *path, in ext4_ext_rm_leaf() argument
2609 if (!path[depth].p_hdr) in ext4_ext_rm_leaf()
2610 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh); in ext4_ext_rm_leaf()
2611 eh = path[depth].p_hdr; in ext4_ext_rm_leaf()
2612 if (unlikely(path[depth].p_hdr == NULL)) { in ext4_ext_rm_leaf()
2617 ex = path[depth].p_ext; in ext4_ext_rm_leaf()
2636 path[depth].p_ext = ex; in ext4_ext_rm_leaf()
2694 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_rm_leaf()
2735 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_rm_leaf()
2747 err = ext4_ext_correct_indexes(handle, inode, path); in ext4_ext_rm_leaf()
2769 if (err == 0 && eh->eh_entries == 0 && path[depth].p_bh != NULL) in ext4_ext_rm_leaf()
2770 err = ext4_ext_rm_idx(handle, inode, path, depth); in ext4_ext_rm_leaf()
2781 ext4_ext_more_to_rm(struct ext4_ext_path *path) in ext4_ext_more_to_rm() argument
2783 BUG_ON(path->p_idx == NULL); in ext4_ext_more_to_rm()
2785 if (path->p_idx < EXT_FIRST_INDEX(path->p_hdr)) in ext4_ext_more_to_rm()
2792 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block) in ext4_ext_more_to_rm()
2802 struct ext4_ext_path *path = NULL; in ext4_ext_remove_space() local
2830 path = ext4_find_extent(inode, end, NULL, EXT4_EX_NOCACHE); in ext4_ext_remove_space()
2831 if (IS_ERR(path)) { in ext4_ext_remove_space()
2833 return PTR_ERR(path); in ext4_ext_remove_space()
2837 ex = path[depth].p_ext; in ext4_ext_remove_space()
2876 err = ext4_force_split_extent_at(handle, inode, &path, in ext4_ext_remove_space()
2891 err = ext4_ext_search_right(inode, path, &lblk, &pblk, in ext4_ext_remove_space()
2905 if (path) { in ext4_ext_remove_space()
2908 path[k].p_block = in ext4_ext_remove_space()
2909 le16_to_cpu(path[k].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2911 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), in ext4_ext_remove_space()
2913 if (path == NULL) { in ext4_ext_remove_space()
2917 path[0].p_maxdepth = path[0].p_depth = depth; in ext4_ext_remove_space()
2918 path[0].p_hdr = ext_inode_hdr(inode); in ext4_ext_remove_space()
2921 if (ext4_ext_check(inode, path[0].p_hdr, depth, 0)) { in ext4_ext_remove_space()
2931 err = ext4_ext_rm_leaf(handle, inode, path, in ext4_ext_remove_space()
2935 brelse(path[i].p_bh); in ext4_ext_remove_space()
2936 path[i].p_bh = NULL; in ext4_ext_remove_space()
2942 if (!path[i].p_hdr) { in ext4_ext_remove_space()
2944 path[i].p_hdr = ext_block_hdr(path[i].p_bh); in ext4_ext_remove_space()
2947 if (!path[i].p_idx) { in ext4_ext_remove_space()
2949 path[i].p_idx = EXT_LAST_INDEX(path[i].p_hdr); in ext4_ext_remove_space()
2950 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1; in ext4_ext_remove_space()
2952 path[i].p_hdr, in ext4_ext_remove_space()
2953 le16_to_cpu(path[i].p_hdr->eh_entries)); in ext4_ext_remove_space()
2956 path[i].p_idx--; in ext4_ext_remove_space()
2960 i, EXT_FIRST_INDEX(path[i].p_hdr), in ext4_ext_remove_space()
2961 path[i].p_idx); in ext4_ext_remove_space()
2962 if (ext4_ext_more_to_rm(path + i)) { in ext4_ext_remove_space()
2966 i + 1, ext4_idx_pblock(path[i].p_idx)); in ext4_ext_remove_space()
2967 memset(path + i + 1, 0, sizeof(*path)); in ext4_ext_remove_space()
2969 ext4_idx_pblock(path[i].p_idx), depth - i - 1, in ext4_ext_remove_space()
2983 path[i + 1].p_bh = bh; in ext4_ext_remove_space()
2987 path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries); in ext4_ext_remove_space()
2991 if (path[i].p_hdr->eh_entries == 0 && i > 0) { in ext4_ext_remove_space()
2995 err = ext4_ext_rm_idx(handle, inode, path, i); in ext4_ext_remove_space()
2998 brelse(path[i].p_bh); in ext4_ext_remove_space()
2999 path[i].p_bh = NULL; in ext4_ext_remove_space()
3006 partial_cluster, path->p_hdr->eh_entries); in ext4_ext_remove_space()
3023 if (path->p_hdr->eh_entries == 0) { in ext4_ext_remove_space()
3028 err = ext4_ext_get_access(handle, inode, path); in ext4_ext_remove_space()
3033 err = ext4_ext_dirty(handle, inode, path); in ext4_ext_remove_space()
3037 ext4_ext_drop_refs(path); in ext4_ext_remove_space()
3038 kfree(path); in ext4_ext_remove_space()
3039 path = NULL; in ext4_ext_remove_space()
3163 struct ext4_ext_path *path = *ppath; in ext4_split_extent_at() local
3177 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3180 ex = path[depth].p_ext; in ext4_split_extent_at()
3191 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_split_extent_at()
3207 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3209 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3223 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_split_extent_at()
3265 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_split_extent_at()
3266 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3278 ext4_ext_show_leaf(inode, path); in ext4_split_extent_at()
3283 ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_split_extent_at()
3305 struct ext4_ext_path *path = *ppath; in ext4_split_extent() local
3315 ex = path[depth].p_ext; in ext4_split_extent()
3339 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_split_extent()
3340 if (IS_ERR(path)) in ext4_split_extent()
3341 return PTR_ERR(path); in ext4_split_extent()
3343 ex = path[depth].p_ext; in ext4_split_extent()
3365 ext4_ext_show_leaf(inode, path); in ext4_split_extent()
3396 struct ext4_ext_path *path = *ppath; in ext4_ext_convert_to_initialized() local
3419 eh = path[depth].p_hdr; in ext4_ext_convert_to_initialized()
3420 ex = path[depth].p_ext; in ext4_ext_convert_to_initialized()
3473 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3519 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3541 ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3544 path[depth].p_ext = abut_ex; in ext4_ext_convert_to_initialized()
3569 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_ext_convert_to_initialized()
3573 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_ext_convert_to_initialized()
3574 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_ext_convert_to_initialized()
3661 struct ext4_ext_path *path = *ppath; in ext4_split_convert_extents() local
3681 ex = path[depth].p_ext; in ext4_split_convert_extents()
3703 struct ext4_ext_path *path = *ppath; in ext4_convert_unwritten_extents_endio() local
3711 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3736 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in ext4_convert_unwritten_extents_endio()
3737 if (IS_ERR(path)) in ext4_convert_unwritten_extents_endio()
3738 return PTR_ERR(path); in ext4_convert_unwritten_extents_endio()
3740 ex = path[depth].p_ext; in ext4_convert_unwritten_extents_endio()
3743 err = ext4_ext_get_access(handle, inode, path + depth); in ext4_convert_unwritten_extents_endio()
3752 ext4_ext_try_to_merge(handle, inode, path, ex); in ext4_convert_unwritten_extents_endio()
3755 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in ext4_convert_unwritten_extents_endio()
3757 ext4_ext_show_leaf(inode, path); in ext4_convert_unwritten_extents_endio()
3774 struct ext4_ext_path *path, in check_eofblocks_fl() argument
3785 eh = path[depth].p_hdr; in check_eofblocks_fl()
3815 if (path[i].p_idx != EXT_LAST_INDEX(path[i].p_hdr)) in check_eofblocks_fl()
3936 struct ext4_ext_path *path = *ppath; in convert_initialized_extent() local
3951 ex = path[depth].p_ext; in convert_initialized_extent()
3964 path = ext4_find_extent(inode, map->m_lblk, ppath, 0); in convert_initialized_extent()
3965 if (IS_ERR(path)) in convert_initialized_extent()
3966 return PTR_ERR(path); in convert_initialized_extent()
3968 ex = path[depth].p_ext; in convert_initialized_extent()
3976 err = ext4_ext_get_access(handle, inode, path + depth); in convert_initialized_extent()
3985 ext4_ext_try_to_merge(handle, inode, path, ex); in convert_initialized_extent()
3988 err = ext4_ext_dirty(handle, inode, path + path->p_depth); in convert_initialized_extent()
3991 ext4_ext_show_leaf(inode, path); in convert_initialized_extent()
3994 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, map->m_len); in convert_initialized_extent()
4010 struct ext4_ext_path *path = *ppath; in ext4_ext_handle_unwritten_extents() local
4019 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4055 path, map->m_len); in ext4_ext_handle_unwritten_extents()
4134 err = check_eofblocks_fl(handle, inode, map->m_lblk, path, in ext4_ext_handle_unwritten_extents()
4142 ext4_ext_show_leaf(inode, path); in ext4_ext_handle_unwritten_extents()
4193 struct ext4_ext_path *path) in get_implied_cluster_alloc() argument
4239 ext4_lblk_t next = ext4_ext_next_allocated_block(path); in get_implied_cluster_alloc()
4273 struct ext4_ext_path *path = NULL; in ext4_ext_map_blocks() local
4291 path = ext4_find_extent(inode, map->m_lblk, NULL, 0); in ext4_ext_map_blocks()
4292 if (IS_ERR(path)) { in ext4_ext_map_blocks()
4293 err = PTR_ERR(path); in ext4_ext_map_blocks()
4294 path = NULL; in ext4_ext_map_blocks()
4305 if (unlikely(path[depth].p_ext == NULL && depth != 0)) { in ext4_ext_map_blocks()
4309 path[depth].p_block); in ext4_ext_map_blocks()
4314 ex = path[depth].p_ext; in ext4_ext_map_blocks()
4344 handle, inode, map, &path, in ext4_ext_map_blocks()
4351 handle, inode, map, &path, flags, in ext4_ext_map_blocks()
4370 ext4_ext_put_gap_in_cache(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4385 get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { in ext4_ext_map_blocks()
4394 err = ext4_ext_search_left(inode, path, &ar.lleft, &ar.pleft); in ext4_ext_map_blocks()
4399 err = ext4_ext_search_right(inode, path, &ar.lright, &ar.pright, &ex2); in ext4_ext_map_blocks()
4406 get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) { in ext4_ext_map_blocks()
4428 err = ext4_ext_check_overlap(sbi, inode, &newex, path); in ext4_ext_map_blocks()
4436 ar.goal = ext4_ext_find_goal(inode, path, map->m_lblk); in ext4_ext_map_blocks()
4492 path, ar.len); in ext4_ext_map_blocks()
4494 err = ext4_ext_insert_extent(handle, inode, &path, in ext4_ext_map_blocks()
4610 ext4_ext_show_leaf(inode, path); in ext4_ext_map_blocks()
4615 ext4_ext_drop_refs(path); in ext4_ext_map_blocks()
4616 kfree(path); in ext4_ext_map_blocks()
5203 struct ext4_ext_path *path) in ext4_access_path() argument
5224 err = ext4_ext_get_access(handle, inode, path); in ext4_access_path()
5235 ext4_ext_shift_path_extents(struct ext4_ext_path *path, ext4_lblk_t shift, in ext4_ext_shift_path_extents() argument
5242 depth = path->p_depth; in ext4_ext_shift_path_extents()
5245 if (depth == path->p_depth) { in ext4_ext_shift_path_extents()
5246 ex_start = path[depth].p_ext; in ext4_ext_shift_path_extents()
5250 ex_last = EXT_LAST_EXTENT(path[depth].p_hdr); in ext4_ext_shift_path_extents()
5252 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5256 if (ex_start == EXT_FIRST_EXTENT(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5266 EXT_FIRST_EXTENT(path[depth].p_hdr)) && in ext4_ext_shift_path_extents()
5268 path, ex_start - 1)) in ext4_ext_shift_path_extents()
5273 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5282 err = ext4_access_path(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5286 le32_add_cpu(&path[depth].p_idx->ei_block, -shift); in ext4_ext_shift_path_extents()
5287 err = ext4_ext_dirty(handle, inode, path + depth); in ext4_ext_shift_path_extents()
5292 if (path[depth].p_idx != EXT_FIRST_INDEX(path[depth].p_hdr)) in ext4_ext_shift_path_extents()
5312 struct ext4_ext_path *path; in ext4_ext_shift_extents() local
5319 path = ext4_find_extent(inode, EXT_MAX_BLOCKS - 1, NULL, 0); in ext4_ext_shift_extents()
5320 if (IS_ERR(path)) in ext4_ext_shift_extents()
5321 return PTR_ERR(path); in ext4_ext_shift_extents()
5323 depth = path->p_depth; in ext4_ext_shift_extents()
5324 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5339 path = ext4_find_extent(inode, start - 1, &path, 0); in ext4_ext_shift_extents()
5340 if (IS_ERR(path)) in ext4_ext_shift_extents()
5341 return PTR_ERR(path); in ext4_ext_shift_extents()
5342 depth = path->p_depth; in ext4_ext_shift_extents()
5343 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5359 path = ext4_find_extent(inode, start, &path, 0); in ext4_ext_shift_extents()
5360 if (IS_ERR(path)) in ext4_ext_shift_extents()
5361 return PTR_ERR(path); in ext4_ext_shift_extents()
5362 depth = path->p_depth; in ext4_ext_shift_extents()
5363 extent = path[depth].p_ext; in ext4_ext_shift_extents()
5371 if (extent < EXT_LAST_EXTENT(path[depth].p_hdr)) { in ext4_ext_shift_extents()
5372 path[depth].p_ext++; in ext4_ext_shift_extents()
5374 start = ext4_ext_next_allocated_block(path); in ext4_ext_shift_extents()
5378 ret = ext4_ext_shift_path_extents(path, shift, inode, in ext4_ext_shift_extents()
5384 ext4_ext_drop_refs(path); in ext4_ext_shift_extents()
5385 kfree(path); in ext4_ext_shift_extents()