From a1ba4c080bef187f5bdbc2191092fbe7341a5794 Mon Sep 17 00:00:00 2001 From: Filipe Manana Date: Mon, 19 Sep 2022 15:06:33 +0100 Subject: btrfs: add helper to replace extent map range with a new extent map We have several places that need to drop all the extent maps in a given file range and then add a new extent map for that range. Currently they call btrfs_drop_extent_map_range() to delete all extent maps in the range and then keep trying to add the new extent map in a loop that keeps retrying while the insertion of the new extent map fails with -EEXIST. So instead of repeating this logic, add a helper to extent_map.c that does these steps and name it btrfs_replace_extent_map_range(). Also add a comment about why the retry loop is necessary. Signed-off-by: Filipe Manana Signed-off-by: David Sterba --- fs/btrfs/extent_map.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'fs/btrfs/extent_map.h') diff --git a/fs/btrfs/extent_map.h b/fs/btrfs/extent_map.h index 17f4a9bbee7f..ad311864272a 100644 --- a/fs/btrfs/extent_map.h +++ b/fs/btrfs/extent_map.h @@ -109,5 +109,8 @@ int btrfs_add_extent_mapping(struct btrfs_fs_info *fs_info, void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end, bool skip_pinned); +int btrfs_replace_extent_map_range(struct btrfs_inode *inode, + struct extent_map *new_em, + bool modified); #endif -- cgit v1.2.3