aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-09-01 14:41:09 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-09-01 14:41:09 -0400
commitee4bd0d963b75cbad9bfb59b547146671c7a655a (patch)
tree45b8284324939d19a418c6ab1ec4e94dff44c53f /fs/ext4
parent10809df84a4d868db61af621bae3658494165279 (diff)
ext4: reuse path object in ext4_ext_shift_extents()
Now that the semantics of ext4_ext_find_extent() are much cleaner, it's safe and more efficient to reuse the path object across the multiple calls to ext4_ext_find_extent() in ext4_ext_shift_extents(). Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index c94c7480053e..22828e44a70d 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5306,26 +5306,21 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5306 5306
5307 depth = path->p_depth; 5307 depth = path->p_depth;
5308 extent = path[depth].p_ext; 5308 extent = path[depth].p_ext;
5309 if (!extent) { 5309 if (!extent)
5310 ext4_ext_drop_refs(path); 5310 goto out;
5311 kfree(path);
5312 return ret;
5313 }
5314 5311
5315 stop_block = le32_to_cpu(extent->ee_block) + 5312 stop_block = le32_to_cpu(extent->ee_block) +
5316 ext4_ext_get_actual_len(extent); 5313 ext4_ext_get_actual_len(extent);
5317 ext4_ext_drop_refs(path);
5318 kfree(path);
5319 5314
5320 /* Nothing to shift, if hole is at the end of file */ 5315 /* Nothing to shift, if hole is at the end of file */
5321 if (start >= stop_block) 5316 if (start >= stop_block)
5322 return ret; 5317 goto out;
5323 5318
5324 /* 5319 /*
5325 * Don't start shifting extents until we make sure the hole is big 5320 * Don't start shifting extents until we make sure the hole is big
5326 * enough to accomodate the shift. 5321 * enough to accomodate the shift.
5327 */ 5322 */
5328 path = ext4_ext_find_extent(inode, start - 1, NULL, 0); 5323 path = ext4_ext_find_extent(inode, start - 1, &path, 0);
5329 if (IS_ERR(path)) 5324 if (IS_ERR(path))
5330 return PTR_ERR(path); 5325 return PTR_ERR(path);
5331 depth = path->p_depth; 5326 depth = path->p_depth;
@@ -5338,8 +5333,6 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5338 ex_start = 0; 5333 ex_start = 0;
5339 ex_end = 0; 5334 ex_end = 0;
5340 } 5335 }
5341 ext4_ext_drop_refs(path);
5342 kfree(path);
5343 5336
5344 if ((start == ex_start && shift > ex_start) || 5337 if ((start == ex_start && shift > ex_start) ||
5345 (shift > start - ex_end)) 5338 (shift > start - ex_end))
@@ -5347,7 +5340,7 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5347 5340
5348 /* Its safe to start updating extents */ 5341 /* Its safe to start updating extents */
5349 while (start < stop_block) { 5342 while (start < stop_block) {
5350 path = ext4_ext_find_extent(inode, start, NULL, 0); 5343 path = ext4_ext_find_extent(inode, start, &path, 0);
5351 if (IS_ERR(path)) 5344 if (IS_ERR(path))
5352 return PTR_ERR(path); 5345 return PTR_ERR(path);
5353 depth = path->p_depth; 5346 depth = path->p_depth;
@@ -5363,19 +5356,17 @@ ext4_ext_shift_extents(struct inode *inode, handle_t *handle,
5363 path[depth].p_ext++; 5356 path[depth].p_ext++;
5364 } else { 5357 } else {
5365 start = ext4_ext_next_allocated_block(path); 5358 start = ext4_ext_next_allocated_block(path);
5366 ext4_ext_drop_refs(path);
5367 kfree(path);
5368 continue; 5359 continue;
5369 } 5360 }
5370 } 5361 }
5371 ret = ext4_ext_shift_path_extents(path, shift, inode, 5362 ret = ext4_ext_shift_path_extents(path, shift, inode,
5372 handle, &start); 5363 handle, &start);
5373 ext4_ext_drop_refs(path);
5374 kfree(path);
5375 if (ret) 5364 if (ret)
5376 break; 5365 break;
5377 } 5366 }
5378 5367out:
5368 ext4_ext_drop_refs(path);
5369 kfree(path);
5379 return ret; 5370 return ret;
5380} 5371}
5381 5372