diff options
author | Theodore Ts'o <tytso@mit.edu> | 2014-09-01 14:42:09 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2014-09-01 14:42:09 -0400 |
commit | 3bdf14b4d7a3a7416577e9f9f421dbf29b5b6747 (patch) | |
tree | ee40c6911acc6ba9a52af237befa4c9cf926611e /fs/ext4/move_extent.c | |
parent | ee4bd0d963b75cbad9bfb59b547146671c7a655a (diff) |
ext4: reuse path object in ext4_move_extents()
Reuse the path object in ext4_move_extents() so we don't unnecessarily
free and reallocate it.
Also clean up the get_ext_path() wrapper so that it has the same
semantics of freeing the path object on error as ext4_ext_find_extent().
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/move_extent.c')
-rw-r--r-- | fs/ext4/move_extent.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index a34c0760276c..7bf970dd61f5 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c | |||
@@ -32,20 +32,21 @@ | |||
32 | */ | 32 | */ |
33 | static inline int | 33 | static inline int |
34 | get_ext_path(struct inode *inode, ext4_lblk_t lblock, | 34 | get_ext_path(struct inode *inode, ext4_lblk_t lblock, |
35 | struct ext4_ext_path **orig_path) | 35 | struct ext4_ext_path **ppath) |
36 | { | 36 | { |
37 | int ret = 0; | ||
38 | struct ext4_ext_path *path; | 37 | struct ext4_ext_path *path; |
39 | 38 | ||
40 | path = ext4_ext_find_extent(inode, lblock, orig_path, EXT4_EX_NOCACHE); | 39 | path = ext4_ext_find_extent(inode, lblock, ppath, EXT4_EX_NOCACHE); |
41 | if (IS_ERR(path)) | 40 | if (IS_ERR(path)) |
42 | ret = PTR_ERR(path); | 41 | return PTR_ERR(path); |
43 | else if (path[ext_depth(inode)].p_ext == NULL) | 42 | if (path[ext_depth(inode)].p_ext == NULL) { |
44 | ret = -ENODATA; | 43 | ext4_ext_drop_refs(path); |
45 | else | 44 | kfree(path); |
46 | *orig_path = path; | 45 | *ppath = NULL; |
47 | 46 | return -ENODATA; | |
48 | return ret; | 47 | } |
48 | *ppath = path; | ||
49 | return 0; | ||
49 | } | 50 | } |
50 | 51 | ||
51 | /** | 52 | /** |
@@ -667,7 +668,7 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk, | |||
667 | } | 668 | } |
668 | d_start += next_blk - o_start; | 669 | d_start += next_blk - o_start; |
669 | o_start = next_blk; | 670 | o_start = next_blk; |
670 | goto repeat; | 671 | continue; |
671 | /* Check hole after the start pos */ | 672 | /* Check hole after the start pos */ |
672 | } else if (cur_blk > o_start) { | 673 | } else if (cur_blk > o_start) { |
673 | /* Skip hole */ | 674 | /* Skip hole */ |
@@ -708,10 +709,6 @@ ext4_move_extents(struct file *o_filp, struct file *d_filp, __u64 orig_blk, | |||
708 | break; | 709 | break; |
709 | o_start += cur_len; | 710 | o_start += cur_len; |
710 | d_start += cur_len; | 711 | d_start += cur_len; |
711 | repeat: | ||
712 | ext4_ext_drop_refs(path); | ||
713 | kfree(path); | ||
714 | path = NULL; | ||
715 | } | 712 | } |
716 | *moved_len = o_start - orig_blk; | 713 | *moved_len = o_start - orig_blk; |
717 | if (*moved_len > len) | 714 | if (*moved_len > len) |