summaryrefslogtreecommitdiff
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 21ba5f0bcc44..5c9ef6717f84 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1127,16 +1127,22 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
fs_info->sectorsize));
WARN_ON(!IS_ALIGNED(end, fs_info->sectorsize));
end--;
+ /* Take mmap lock to serialize with reflinks. */
+ if (!down_read_trylock(&BTRFS_I(inode)->i_mmap_lock))
+ continue;
ret = try_lock_extent(&BTRFS_I(inode)->io_tree,
key.offset, end,
&cached_state);
- if (!ret)
+ if (!ret) {
+ up_read(&BTRFS_I(inode)->i_mmap_lock);
continue;
+ }
btrfs_drop_extent_map_range(BTRFS_I(inode),
key.offset, end, true);
unlock_extent(&BTRFS_I(inode)->io_tree,
key.offset, end, &cached_state);
+ up_read(&BTRFS_I(inode)->i_mmap_lock);
}
}