summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2024-02-12 16:21:19 -0500
committerDavid Sterba <dsterba@suse.com>2024-05-07 21:31:09 +0200
commit7c9acd440f4d1124122639928ac4ff69082bbd3a (patch)
treeb41642a9b7d21411a6c01f79764afbf7bdf1393d /fs/btrfs/inode.c
parentc0707c9e1e36d56cef7b3c8de5c5fdcb14f34aa5 (diff)
downloadlinux-7c9acd440f4d1124122639928ac4ff69082bbd3a.tar.gz
linux-7c9acd440f4d1124122639928ac4ff69082bbd3a.tar.bz2
linux-7c9acd440f4d1124122639928ac4ff69082bbd3a.zip
btrfs: push extent lock into run_delalloc_nocow
run_delalloc_nocow is a bit special as it walks through the file extents for the inode and determines what it can nocow and what it can't. This is the more complicated area for extent locking, so start with this function. Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 347de4e3a331..d8037775ab75 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1977,6 +1977,8 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
*/
ASSERT(!btrfs_is_zoned(fs_info) || btrfs_is_data_reloc_root(root));
+ lock_extent(&inode->io_tree, start, end, NULL);
+
path = btrfs_alloc_path();
if (!path) {
ret = -ENOMEM;
@@ -2250,11 +2252,6 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
int ret;
/*
- * We're unlocked by the different fill functions below.
- */
- lock_extent(&inode->io_tree, start, end, NULL);
-
- /*
* The range must cover part of the @locked_page, or a return of 1
* can confuse the caller.
*/
@@ -2266,6 +2263,11 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
goto out;
}
+ /*
+ * We're unlocked by the different fill functions below.
+ */
+ lock_extent(&inode->io_tree, start, end, NULL);
+
if (btrfs_inode_can_compress(inode) &&
inode_need_compress(inode, start, end) &&
run_delalloc_compressed(inode, locked_page, start, end, wbc))