public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Christoph Hellwig <hch@infradead.org>,
	Jens Axboe <axboe@kernel.dk>, Chris Mason <clm@fb.com>,
	David Sterba <dsterba@suse.com>
Cc: Andreas Gruenbacher <agruenba@redhat.com>,
	linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org,
	linux-raid@vger.kernel.org, dm-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: [RFC 08/12] bio: use bio_set_status in some more places
Date: Mon,  8 Dec 2025 12:10:15 +0000	[thread overview]
Message-ID: <20251208121020.1780402-9-agruenba@redhat.com> (raw)
In-Reply-To: <20251208121020.1780402-1-agruenba@redhat.com>

In these places, the status is known not to be BLK_STS_OK (0), so the
'status != BLK_STS_OK' check in bio_set_status() will be optimized out
and we end up with identical code.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 block/blk-crypto-fallback.c  | 4 ++--
 block/blk-mq.c               | 2 +-
 block/t10-pi.c               | 2 +-
 drivers/md/dm-cache-target.c | 3 ++-
 drivers/md/dm-integrity.c    | 2 +-
 drivers/md/dm-zoned-target.c | 2 +-
 drivers/nvdimm/pmem.c        | 2 +-
 fs/btrfs/bio.c               | 4 ++--
 8 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
index 0e135ba26346..8a2631b1e7e1 100644
--- a/block/blk-crypto-fallback.c
+++ b/block/blk-crypto-fallback.c
@@ -292,7 +292,7 @@ static bool blk_crypto_fallback_encrypt_bio(struct bio **bio_ptr)
 	blk_st = blk_crypto_get_keyslot(blk_crypto_fallback_profile,
 					bc->bc_key, &slot);
 	if (blk_st != BLK_STS_OK) {
-		src_bio->bi_status = blk_st;
+		bio_set_status(src_bio, blk_st);
 		goto out_put_enc_bio;
 	}
 
@@ -395,7 +395,7 @@ static void blk_crypto_fallback_decrypt_bio(struct work_struct *work)
 	blk_st = blk_crypto_get_keyslot(blk_crypto_fallback_profile,
 					bc->bc_key, &slot);
 	if (blk_st != BLK_STS_OK) {
-		bio->bi_status = blk_st;
+		bio_set_status(bio, blk_st);
 		goto out_no_keyslot;
 	}
 
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 4e13d9f9ea96..503ca259429f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3205,7 +3205,7 @@ void blk_mq_submit_bio(struct bio *bio)
 
 	ret = blk_crypto_rq_get_keyslot(rq);
 	if (ret != BLK_STS_OK) {
-		bio->bi_status = ret;
+		bio_set_status(bio, ret);
 		bio_endio(bio);
 		blk_mq_free_request(rq);
 		return;
diff --git a/block/t10-pi.c b/block/t10-pi.c
index 0c4ed9702146..968cf1fe45f0 100644
--- a/block/t10-pi.c
+++ b/block/t10-pi.c
@@ -440,7 +440,7 @@ void blk_integrity_verify_iter(struct bio *bio, struct bvec_iter *saved_iter)
 		kunmap_local(kaddr);
 
 		if (ret) {
-			bio->bi_status = ret;
+			bio_set_status(bio, ret);
 			return;
 		}
 	}
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 82d748eeb9aa..d1dbd4ddaadb 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -1190,7 +1190,8 @@ static void mg_complete(struct dm_cache_migration *mg, bool success)
 			if (success)
 				force_set_dirty(cache, cblock);
 			else if (mg->k.input)
-				mg->overwrite_bio->bi_status = mg->k.input;
+				bio_set_status(mg->overwrite_bio,
+					       mg->k.input);
 			else
 				bio_set_status(mg->overwrite_bio,
 					       BLK_STS_IOERR);
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index d2288b9f2b0d..5220e15b6537 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -1617,7 +1617,7 @@ static void dec_in_flight(struct dm_integrity_io *dio)
 
 		bio = dm_bio_from_per_bio_data(dio, sizeof(struct dm_integrity_io));
 		if (unlikely(dio->bi_status) && !bio->bi_status)
-			bio->bi_status = dio->bi_status;
+			bio_set_status(bio, dio->bi_status);
 		if (likely(!bio->bi_status) && unlikely(bio_sectors(bio) != dio->range.n_sectors)) {
 			dio->range.logical_sector += dio->range.n_sectors;
 			bio_advance(bio, dio->range.n_sectors << SECTOR_SHIFT);
diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 9da329078ea4..d0218a9f1c4f 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -78,7 +78,7 @@ static inline void dmz_bio_endio(struct bio *bio, blk_status_t status)
 		dm_per_bio_data(bio, sizeof(struct dmz_bioctx));
 
 	if (status != BLK_STS_OK && bio->bi_status == BLK_STS_OK)
-		bio->bi_status = status;
+		bio_set_status(bio, status);
 	if (bioctx->dev && bio->bi_status != BLK_STS_OK)
 		bioctx->dev->flags |= DMZ_CHECK_BDEV;
 
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c
index a2f8b5a85326..aa2a486522b5 100644
--- a/drivers/nvdimm/pmem.c
+++ b/drivers/nvdimm/pmem.c
@@ -222,7 +222,7 @@ static void pmem_submit_bio(struct bio *bio)
 			rc = pmem_do_read(pmem, bvec.bv_page, bvec.bv_offset,
 				iter.bi_sector, bvec.bv_len);
 		if (rc) {
-			bio->bi_status = rc;
+			bio_set_status(bio, rc);
 			break;
 		}
 	}
diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 00a7a13fab0c..a63d69509d05 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -174,7 +174,7 @@ static void btrfs_end_repair_bio(struct btrfs_bio *repair_bbio,
 		mirror = next_repair_mirror(fbio, mirror);
 		if (mirror == fbio->bbio->mirror_num) {
 			btrfs_debug(fs_info, "no mirror left");
-			fbio->bbio->bio.bi_status = BLK_STS_IOERR;
+			bio_set_status(&fbio->bbio->bio, BLK_STS_IOERR);
 			goto done;
 		}
 
@@ -225,7 +225,7 @@ static struct btrfs_failed_bio *repair_one_sector(struct btrfs_bio *failed_bbio,
 	num_copies = btrfs_num_copies(fs_info, logical, sectorsize);
 	if (num_copies == 1) {
 		btrfs_debug(fs_info, "no copy to repair from");
-		failed_bbio->bio.bi_status = BLK_STS_IOERR;
+		bio_set_status(&failed_bbio->bio, BLK_STS_IOERR);
 		return fbio;
 	}
 
-- 
2.51.0


  parent reply	other threads:[~2025-12-08 12:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 12:10 [RFC 00/12] bio cleanups Andreas Gruenbacher
2025-12-08 12:10 ` [RFC 01/12] bio: rename bio_chain arguments Andreas Gruenbacher
2025-12-16  7:57   ` Christoph Hellwig
2025-12-08 12:10 ` [RFC 02/12] bio: use bio_io_error more often Andreas Gruenbacher
2025-12-16  7:57   ` Christoph Hellwig
2025-12-08 12:10 ` [RFC 03/12] bio: add bio_set_errno Andreas Gruenbacher
2025-12-16  7:58   ` Christoph Hellwig
2025-12-08 12:10 ` [RFC 04/12] bio: use bio_set_errno in more places Andreas Gruenbacher
2025-12-08 12:10 ` [RFC 05/12] bio: add bio_set_status Andreas Gruenbacher
2025-12-16  7:59   ` Christoph Hellwig
2025-12-08 12:10 ` [RFC 06/12] bio: don't check target->bi_status on error Andreas Gruenbacher
2025-12-16  7:59   ` Christoph Hellwig
2025-12-16  8:41     ` Andreas Gruenbacher
2025-12-16 10:44       ` Christoph Hellwig
2025-12-16 11:20         ` Andreas Gruenbacher
2025-12-18  8:47           ` Christoph Hellwig
2025-12-19 20:14             ` Andreas Gruenbacher
2025-12-08 12:10 ` [RFC 07/12] bio: use bio_set_status for BLK_STS_* status codes Andreas Gruenbacher
2025-12-08 12:10 ` Andreas Gruenbacher [this message]
2025-12-08 12:10 ` [RFC 09/12] bio: switch to bio_set_status in submit_bio_noacct Andreas Gruenbacher
2025-12-08 12:10 ` [RFC 10/12] bio: never set bi_status to BLK_STS_OK during completion Andreas Gruenbacher
2025-12-08 12:10 ` [RFC 11/12] bio: add bio_endio_errno Andreas Gruenbacher
2025-12-16  8:00   ` Christoph Hellwig
2025-12-08 12:10 ` [RFC 12/12] bio: add bio_endio_status Andreas Gruenbacher
2025-12-16  8:01   ` Christoph Hellwig
2025-12-08 19:37 ` [RFC 00/12] bio cleanups David Sterba
2025-12-08 21:16   ` Andreas Gruenbacher

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=20251208121020.1780402-9-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=clm@fb.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=dsterba@suse.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox