mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Vacek <neelx@suse.com>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: Qu Wenruo <wqu@suse.com>, Daniel Vacek <neelx@suse.com>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] btrfs: simplify async csum synchronization
Date: Thu, 13 Nov 2025 11:17:30 +0100	[thread overview]
Message-ID: <20251113101731.2624000-1-neelx@suse.com> (raw)

We don't need the redundant completion csum_done which marks the
csum work has been executed. We can simply flush_work() instead.

This way we can slim down the btrfs_bio structure by 32 bytes matching
it's size to what it used to be before introducing the async csums.
Hence not making any change with respect to the structure size.
---
This is a simple fixup for "btrfs: introduce btrfs_bio::async_csum" in
for-next and can be squashed into it.

v2: metadata is not checksummed here so use the endio_workers workqueue
    unconditionally. Thanks to Qu Wenruo.
---
 fs/btrfs/bio.c       | 2 +-
 fs/btrfs/bio.h       | 1 -
 fs/btrfs/file-item.c | 4 +---
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index a73652b8724a..fd6e4278a62f 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -106,7 +106,7 @@ void btrfs_bio_end_io(struct btrfs_bio *bbio, blk_status_t status)
 	ASSERT(in_task());
 
 	if (bbio->async_csum)
-		wait_for_completion(&bbio->csum_done);
+		flush_work(&bbio->csum_work);
 
 	bbio->bio.bi_status = status;
 	if (bbio->bio.bi_pool == &btrfs_clone_bioset) {
diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h
index deaeea3becf4..0b09d9122fa2 100644
--- a/fs/btrfs/bio.h
+++ b/fs/btrfs/bio.h
@@ -57,7 +57,6 @@ struct btrfs_bio {
 			struct btrfs_ordered_extent *ordered;
 			struct btrfs_ordered_sum *sums;
 			struct work_struct csum_work;
-			struct completion csum_done;
 			struct bvec_iter csum_saved_iter;
 			u64 orig_physical;
 		};
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index 72be3ede0edf..fb7d87da87ea 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -792,7 +792,6 @@ static void csum_one_bio_work(struct work_struct *work)
 	ASSERT(btrfs_op(&bbio->bio) == BTRFS_MAP_WRITE);
 	ASSERT(bbio->async_csum == true);
 	csum_one_bio(bbio, &bbio->csum_saved_iter);
-	complete(&bbio->csum_done);
 }
 
 /*
@@ -825,11 +824,10 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool async)
 		csum_one_bio(bbio, &bbio->bio.bi_iter);
 		return 0;
 	}
-	init_completion(&bbio->csum_done);
 	bbio->async_csum = true;
 	bbio->csum_saved_iter = bbio->bio.bi_iter;
 	INIT_WORK(&bbio->csum_work, csum_one_bio_work);
-	schedule_work(&bbio->csum_work);
+	queue_work(fs_info->endio_workers, &bbio->csum_work);
 	return 0;
 }
 
-- 
2.43.0


             reply	other threads:[~2025-11-13 10:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-13 10:17 Daniel Vacek [this message]
2025-11-18 12:07 ` David Sterba
2025-11-24 18:09   ` David Sterba
2026-01-07 17:00     ` Daniel Vacek
2026-01-08 14:35       ` David Sterba
2026-01-08 17:00         ` 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=20251113101731.2624000-1-neelx@suse.com \
    --to=neelx@suse.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.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®