提交 306bfec0 编写于 作者: F Filipe Manana 提交者: David Sterba

btrfs: rename btrfs_punch_hole_range() to a more generic name

The function btrfs_punch_hole_range() is now used to replace all the file
extents in a given file range with an extent described in the given struct
btrfs_replace_extent_info argument. This extent can either be an existing
extent that is being cloned or it can be a new extent (namely a prealloc
extent). When that argument is NULL it only punches a hole (drops all the
existing extents) in the file range.

So rename the function to btrfs_replace_file_extents().
Reviewed-by: NJosef Bacik <josef@toxicpanda.com>
Signed-off-by: NFilipe Manana <fdmanana@suse.com>
Reviewed-by: NDavid Sterba <dsterba@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 bf385648
...@@ -3088,7 +3088,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -3088,7 +3088,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
int btrfs_drop_extents(struct btrfs_trans_handle *trans, int btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode, u64 start, struct btrfs_root *root, struct inode *inode, u64 start,
u64 end, int drop_cache); u64 end, int drop_cache);
int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
const u64 start, const u64 end, const u64 start, const u64 end,
struct btrfs_replace_extent_info *extent_info, struct btrfs_replace_extent_info *extent_info,
struct btrfs_trans_handle **trans_out); struct btrfs_trans_handle **trans_out);
......
...@@ -2659,7 +2659,7 @@ static int btrfs_insert_clone_extent(struct btrfs_trans_handle *trans, ...@@ -2659,7 +2659,7 @@ static int btrfs_insert_clone_extent(struct btrfs_trans_handle *trans,
* extents without inserting a new one, so we must abort the transaction to avoid * extents without inserting a new one, so we must abort the transaction to avoid
* a corruption. * a corruption.
*/ */
int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path, int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
const u64 start, const u64 end, const u64 start, const u64 end,
struct btrfs_replace_extent_info *extent_info, struct btrfs_replace_extent_info *extent_info,
struct btrfs_trans_handle **trans_out) struct btrfs_trans_handle **trans_out)
...@@ -3007,7 +3007,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len) ...@@ -3007,7 +3007,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
goto out; goto out;
} }
ret = btrfs_punch_hole_range(inode, path, lockstart, lockend, NULL, ret = btrfs_replace_file_extents(inode, path, lockstart, lockend, NULL,
&trans); &trans);
btrfs_free_path(path); btrfs_free_path(path);
if (ret) if (ret)
......
...@@ -9625,7 +9625,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent( ...@@ -9625,7 +9625,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
if (!path) if (!path)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
ret = btrfs_punch_hole_range(inode, path, file_offset, ret = btrfs_replace_file_extents(inode, path, file_offset,
file_offset + len - 1, &extent_info, file_offset + len - 1, &extent_info,
&trans); &trans);
btrfs_free_path(path); btrfs_free_path(path);
......
...@@ -463,7 +463,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -463,7 +463,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
clone_info.file_offset = new_key.offset; clone_info.file_offset = new_key.offset;
clone_info.extent_buf = buf; clone_info.extent_buf = buf;
clone_info.is_new_extent = false; clone_info.is_new_extent = false;
ret = btrfs_punch_hole_range(inode, path, drop_start, ret = btrfs_replace_file_extents(inode, path, drop_start,
new_key.offset + datal - 1, &clone_info, new_key.offset + datal - 1, &clone_info,
&trans); &trans);
if (ret) if (ret)
...@@ -533,7 +533,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode, ...@@ -533,7 +533,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
btrfs_release_path(path); btrfs_release_path(path);
path->leave_spinning = 0; path->leave_spinning = 0;
ret = btrfs_punch_hole_range(inode, path, last_dest_end, ret = btrfs_replace_file_extents(inode, path, last_dest_end,
destoff + len - 1, NULL, &trans); destoff + len - 1, NULL, &trans);
if (ret) if (ret)
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册