mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vacek <neelx@suse.com>
To: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>
Cc: Daniel Vacek <neelx@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Qu Wenruo <wqu@suse.com>
Subject: [PATCH 1/2] btrfs: consume the given iter directly instead of copying in csum_one_bio()
Date: Wed,  2 Sep 2026 18:51:35 +0200	[thread overview]
Message-ID: <20260902165137.3781696-2-neelx@suse.com> (raw)
In-Reply-To: <20260902165137.3781696-1-neelx@suse.com>

This is just a small cleanup to avoid copying the iter twice in async case.
We already have a copy csum_one_bio() can consume directly. No need to copy
again the second time.
In the sync case we can copy in the caller (as we did before dd57c78aec39
("btrfs: introduce btrfs_bio::async_csum")).

Signed-off-by: Daniel Vacek <neelx@suse.com>
---
 fs/btrfs/file-item.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 581ca5653be9..5a5cffb18922 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -797,18 +797,16 @@ int btrfs_lookup_csums_bitmap(struct btrfs_root *root, struct btrfs_path *path,
 	return ret;
 }
 
-static void csum_one_bio(struct btrfs_bio *bbio, struct bvec_iter *src)
+static void csum_one_bio(struct btrfs_bio *bbio, struct bvec_iter *iter)
 {
 	struct btrfs_inode *inode = bbio->inode;
 	struct btrfs_fs_info *fs_info = inode->root->fs_info;
 	struct btrfs_ordered_sum *sums = bbio->sums;
-	struct bvec_iter iter;
 	const u32 blocksize = fs_info->sectorsize;
 	int index = 0;
 
-	for (iter = *src; iter.bi_size; bio_advance_iter(&bbio->bio, &iter, blocksize)) {
-		btrfs_csum_one_bio_block(fs_info, &bbio->bio, &iter,
-					 sums->sums + index);
+	for (; iter->bi_size; bio_advance_iter(&bbio->bio, iter, blocksize)) {
+		btrfs_csum_one_bio_block(fs_info, &bbio->bio, iter, sums->sums + index);
 
 		index += fs_info->csum_size;
 	}
@@ -851,12 +849,14 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async)
 	btrfs_add_ordered_sum(ordered, sums);
 
 	if (!async) {
-		csum_one_bio(bbio, &bbio->bio.bi_iter);
+		struct bvec_iter iter = bio->bi_iter;
+
+		csum_one_bio(bbio, &iter);
 		return 0;
 	}
 	init_completion(&bbio->csum_done);
 	bbio->async_csum = true;
-	bbio->csum_saved_iter = bbio->bio.bi_iter;
+	bbio->csum_saved_iter = bio->bi_iter;
 	INIT_WORK(&bbio->csum_work, csum_one_bio_work);
 	schedule_work(&bbio->csum_work);
 	return 0;
-- 
2.53.0


  reply	other threads:[~2026-09-02 16:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 16:51 [PATCH 0/2] btrfs: async checksumming cleanups Daniel Vacek
2026-09-02 16:51 ` Daniel Vacek [this message]
2026-09-02 21:51   ` [PATCH 1/2] btrfs: consume the given iter directly instead of copying in csum_one_bio() Qu Wenruo
2026-09-02 22:47     ` Qu Wenruo
2026-09-03  4:49   ` Daniel Vacek
2026-09-02 16:51 ` [PATCH 2/2] btrfs: use bio::remaining for async checksumming synchronization Daniel Vacek
2026-09-02 22:02   ` Qu Wenruo
2026-09-02 22:20     ` Qu Wenruo

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=20260902165137.3781696-2-neelx@suse.com \
    --to=neelx@suse.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mason@kernel.org \
    --cc=wqu@suse.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®