All of lore.kernel.org
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 6/6] btrfs: open code csum_exist_in_range()
Date: Fri, 12 Apr 2024 16:03:20 +0100	[thread overview]
Message-ID: <43c7b46211cc26f0f47ccd8bca522d70e4e563b8.1712933006.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1712933003.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

The csum_exist_in_range() function is now too trivial and is only used in
one place, so open code it in its single caller.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/inode.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1d78e07d082b..f23511428e74 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1737,15 +1737,6 @@ static noinline int run_delalloc_cow(struct btrfs_inode *inode,
 	return 1;
 }
 
-static noinline int csum_exist_in_range(struct btrfs_fs_info *fs_info,
-					u64 bytenr, u64 num_bytes, bool nowait)
-{
-	struct btrfs_root *csum_root = btrfs_csum_root(fs_info, bytenr);
-
-	return btrfs_lookup_csums_list(csum_root, bytenr, bytenr + num_bytes - 1,
-				       NULL, nowait);
-}
-
 static int fallback_to_cow(struct btrfs_inode *inode, struct page *locked_page,
 			   const u64 start, const u64 end)
 {
@@ -1860,6 +1851,7 @@ static int can_nocow_file_extent(struct btrfs_path *path,
 	struct extent_buffer *leaf = path->nodes[0];
 	struct btrfs_root *root = inode->root;
 	struct btrfs_file_extent_item *fi;
+	struct btrfs_root *csum_root;
 	u64 extent_end;
 	u8 extent_type;
 	int can_nocow = 0;
@@ -1920,7 +1912,7 @@ static int can_nocow_file_extent(struct btrfs_path *path,
 	if (args->free_path) {
 		/*
 		 * We don't need the path anymore, plus through the
-		 * csum_exist_in_range() call below we will end up allocating
+		 * btrfs_lookup_csums_list() call below we will end up allocating
 		 * another path. So free the path to avoid unnecessary extra
 		 * memory usage.
 		 */
@@ -1941,8 +1933,11 @@ static int can_nocow_file_extent(struct btrfs_path *path,
 	 * Force COW if csums exist in the range. This ensures that csums for a
 	 * given extent are either valid or do not exist.
 	 */
-	ret = csum_exist_in_range(root->fs_info, args->disk_bytenr, args->num_bytes,
-				  nowait);
+
+	csum_root = btrfs_csum_root(root->fs_info, args->disk_bytenr);
+	ret = btrfs_lookup_csums_list(csum_root, args->disk_bytenr,
+				      args->disk_bytenr + args->num_bytes - 1,
+				      NULL, nowait);
 	WARN_ON_ONCE(ret > 0 && is_freespace_inode);
 	if (ret != 0)
 		goto out;
-- 
2.43.0


  parent reply	other threads:[~2024-04-12 15:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-12 15:03 [PATCH 0/6] btrfs: some speedup for NOCOW write path and cleanups fdmanana
2024-04-12 15:03 ` [PATCH 1/6] btrfs: add function comment to btrfs_lookup_csums_list() fdmanana
2024-04-13 10:11   ` Qu Wenruo
2024-04-12 15:03 ` [PATCH 2/6] btrfs: remove search_commit parameter from btrfs_lookup_csums_list() fdmanana
2024-04-13 10:10   ` Qu Wenruo
2024-04-12 15:03 ` [PATCH 3/6] btrfs: remove use of a temporary list at btrfs_lookup_csums_list() fdmanana
2024-04-13 10:08   ` Qu Wenruo
2024-04-12 15:03 ` [PATCH 4/6] btrfs: simplify error path for btrfs_lookup_csums_list() fdmanana
2024-04-13 10:12   ` Qu Wenruo
2024-04-12 15:03 ` [PATCH 5/6] btrfs: make NOCOW checks for existence of checksums in a range more efficient fdmanana
2024-04-13 10:15   ` Qu Wenruo
2024-04-12 15:03 ` fdmanana [this message]
2024-04-13 10:16   ` [PATCH 6/6] btrfs: open code csum_exist_in_range() Qu Wenruo
2024-04-12 16:50 ` [PATCH 0/6] btrfs: some speedup for NOCOW write path and cleanups David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43c7b46211cc26f0f47ccd8bca522d70e4e563b8.1712933006.git.fdmanana@suse.com \
    --to=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.