1 ext4: reuse path object in ext4_ext_shift_extents()
3 Now that the semantics of ext4_ext_find_extent() are much cleaner,
4 it's safe and more efficient to reuse the path object across the
5 multiple calls to ext4_ext_find_extent() in ext4_ext_shift_extents().
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
9 fs/ext4/extents.c | 25 ++++++++-----------------
10 1 file changed, 8 insertions(+), 17 deletions(-)
12 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
13 index ecd86e0..ad76d41 100644
14 --- a/fs/ext4/extents.c
15 +++ b/fs/ext4/extents.c
16 @@ -5305,26 +5305,21 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
18 depth = path->p_depth;
19 extent = path[depth].p_ext;
21 - ext4_ext_drop_refs(path);
28 stop_block = le32_to_cpu(extent->ee_block) +
29 ext4_ext_get_actual_len(extent);
30 - ext4_ext_drop_refs(path);
33 /* Nothing to shift, if hole is at the end of file */
34 if (start >= stop_block)
39 * Don't start shifting extents until we make sure the hole is big
40 * enough to accomodate the shift.
42 - path = ext4_ext_find_extent(inode, start - 1, NULL, 0);
43 + path = ext4_ext_find_extent(inode, start - 1, &path, 0);
46 depth = path->p_depth;
47 @@ -5337,8 +5332,6 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
51 - ext4_ext_drop_refs(path);
54 if ((start == ex_start && shift > ex_start) ||
55 (shift > start - ex_end))
56 @@ -5346,7 +5339,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
58 /* Its safe to start updating extents */
59 while (start < stop_block) {
60 - path = ext4_ext_find_extent(inode, start, NULL, 0);
61 + path = ext4_ext_find_extent(inode, start, &path, 0);
64 depth = path->p_depth;
65 @@ -5362,19 +5355,17 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
68 start = ext4_ext_next_allocated_block(path);
69 - ext4_ext_drop_refs(path);
74 ret = ext4_ext_shift_path_extents(path, shift, inode,
76 - ext4_ext_drop_refs(path);
83 + ext4_ext_drop_refs(path);