summaryrefslogtreecommitdiff
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2022-03-23 19:19:27 +0300
committerDavid Sterba <dsterba@suse.com>2022-05-16 18:03:10 +0300
commitc1a548db25c3bafed0b8519cf2f41c6e44bc5dc4 (patch)
treeb84c7ffc4defe57983d2dfeb4bfb67e6db2b8800 /fs/btrfs/inode.c
parent1a89f1738684cac05b4bbea80dd77e8f15176d3a (diff)
downloadlinux-c1a548db25c3bafed0b8519cf2f41c6e44bc5dc4.tar.xz
btrfs: free path at can_nocow_extent() before checking for checksum items
When we look for checksum items, through csum_exist_in_range(), at can_nocow_extent(), we no longer need the path that we have previously allocated. Through csum_exist_in_range() -> btrfs_lookup_csums_range(), we also end up allocating a path, so we are adding unnecessary extra memory usage. So free the path before calling csum_exist_in_range(). Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ca47f7c43ee6..b7a7a94f041d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7230,6 +7230,14 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len,
}
/*
+ * We don't need the path anymore, plus through the csum_exist_in_range()
+ * call below we will end up allocating another path. So free the path
+ * to avoid unnecessary extra memory usage.
+ */
+ btrfs_free_path(path);
+ path = NULL;
+
+ /*
* adjust disk_bytenr and num_bytes to cover just the bytes
* in this extent we are about to write. If there
* are any csums in that range we have to cow in order