Skip to contentSkip to conversation

block: only update request sector if needed

PATCH Applied Johannes Thumshirn 5 participants 7 messages May 6, 2025 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: only update request sector if needed

From: Johannes Thumshirn <[email protected]>

In case of a ZONE APPEND write, regardless of native ZONE APPEND or the emulation layer in the zone write plugging code, the sector the data got written to by the device needs to be updated in the bio.

At the moment, this is done for every native ZONE APPEND write and every request that is flagged with 'BIO_ZONE_WRITE_PLUGGING'. But thus superfluously updates the sector for regular writes to a zoned block device.

Check if a bio is a native ZONE APPEND write or if the bio is flagged as 'BIO_EMULATES_ZONE_APPEND', meaning the block layer's zone write plugging code handles the ZONE APPEND and translates it into a regular write and back. Only if one of these two criterion is met, update the sector in the bio upon completion.

---
 block/blk.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk.h +2 -1
index 328075787814..594eeba7b949 100644
@@ -480,7 +480,8 @@ static inline void blk_zone_update_request_bio(struct request *rq,
 	 * the original BIO sector so that blk_zone_write_plug_bio_endio() can
 	 * lookup the zone write plug.
 	 */
-	if (req_op(rq) == REQ_OP_ZONE_APPEND || bio_zone_write_plugging(bio))
+	if (req_op(rq) == REQ_OP_ZONE_APPEND ||
+	    bio_flagged(bio, BIO_EMULATES_ZONE_APPEND))
 		bio->bi_iter.bi_sector = rq->__sector;
 }
 void blk_zone_write_plug_bio_endio(struct bio *bio);
Signature · 1 line
2.43.0
maintainer
#2 lore raw
Quoted 3 lines · Christoph Hellwig

Looks good:

Johannes, you need to update your mail setup, it's failing authentication verification and hence often / always gets marked as spam.

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 9 lines · Jens Axboe
Quoted 3 lines · Christoph Hellwig

Looks good:

Johannes, you need to update your mail setup, it's failing authentication verification and hence often / always gets marked as spam.

Yes in pure laziness I just used a gmail alias for the kernel.org address. I'll update to the proper mail.kernel.org setup.

maintainer Applied
#4 lore raw
In reply to Johannes Thumshirn
Quoted 10 lines · Johannes Thumshirn

In case of a ZONE APPEND write, regardless of native ZONE APPEND or the emulation layer in the zone write plugging code, the sector the data got written to by the device needs to be updated in the bio.

At the moment, this is done for every native ZONE APPEND write and every request that is flagged with 'BIO_ZONE_WRITE_PLUGGING'. But thus superfluously updates the sector for regular writes to a zoned block device.

[...]

Applied, thanks!

[1/1] block: only update request sector if needed

      commit: 3bb6e35632fed829a36c68385811217a9e8072a8

Best regards,

Signature · 1 line
Jens Axboe
#5 lore raw
In reply to Johannes Thumshirn
Quoted 27 lines · Johannes Thumshirn

From: Johannes Thumshirn <[email protected]>

In case of a ZONE APPEND write, regardless of native ZONE APPEND or the emulation layer in the zone write plugging code, the sector the data got written to by the device needs to be updated in the bio.

At the moment, this is done for every native ZONE APPEND write and every request that is flagged with 'BIO_ZONE_WRITE_PLUGGING'. But thus superfluously updates the sector for regular writes to a zoned block device.

Check if a bio is a native ZONE APPEND write or if the bio is flagged as 'BIO_EMULATES_ZONE_APPEND', meaning the block layer's zone write plugging code handles the ZONE APPEND and translates it into a regular write and back. Only if one of these two criterion is met, update the sector in the bio upon completion.

---
  block/blk.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
block/blk.h +0 -0
index 328075787814..594eeba7b949 100644

block/blk.h static inline void blk_zone_update_request_bio(struct request *rq, · line 487

Quoted 9 lines
block/blk.h +2 -1
@@ -480,7 +480,8 @@ static inline void blk_zone_update_request_bio(struct request *rq,
  	 * the original BIO sector so that blk_zone_write_plug_bio_endio() can
  	 * lookup the zone write plug.
  	 */
-	if (req_op(rq) == REQ_OP_ZONE_APPEND || bio_zone_write_plugging(bio))
+	if (req_op(rq) == REQ_OP_ZONE_APPEND ||
+	    bio_flagged(bio, BIO_EMULATES_ZONE_APPEND))
  		bio->bi_iter.bi_sector = rq->__sector;
  }
  void blk_zone_write_plug_bio_endio(struct bio *bio);

Does this patch need a "Fixes:" tag? Is the below correct?

Fixes dd291d77cc90 ("block: Introduce zone write plugging")

Thanks,

Bart.

#6 lore raw
Quoted 4 lines · Bart Van Assche

Does this patch need a "Fixes:" tag? Is the below correct?

Fixes dd291d77cc90 ("block: Introduce zone write plugging")

Why? It's just a superfluous assignment. I only noticed myself because I was adding a tracepoint in blk_zone_update_request_bio() and got unexpected results.