public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: only update request sector if needed
@ 2025-05-06 11:27 Johannes Thumshirn
  2025-05-06 11:59 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2025-05-06 11:27 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Christoph Hellwig, Damien Le Moal, linux-block,
	Johannes Thumshirn

From: Johannes Thumshirn <johannes.thumshirn@wdc.com>

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.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 block/blk.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk.h b/block/blk.h
index 328075787814..594eeba7b949 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 11:27 [PATCH] block: only update request sector if needed Johannes Thumshirn
@ 2025-05-06 11:59 ` Christoph Hellwig
  2025-05-06 13:45   ` Jens Axboe
  2025-05-06 13:48 ` Jens Axboe
  2025-05-06 16:02 ` Bart Van Assche
  2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2025-05-06 11:59 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Jens Axboe, Christoph Hellwig, Damien Le Moal, linux-block,
	Johannes Thumshirn

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 11:59 ` Christoph Hellwig
@ 2025-05-06 13:45   ` Jens Axboe
  2025-05-06 16:28     ` Johannes Thumshirn
  0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2025-05-06 13:45 UTC (permalink / raw)
  To: Christoph Hellwig, Johannes Thumshirn
  Cc: Damien Le Moal, linux-block, Johannes Thumshirn

On 5/6/25 5:59 AM, Christoph Hellwig wrote:
> Looks good:
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>

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

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 11:27 [PATCH] block: only update request sector if needed Johannes Thumshirn
  2025-05-06 11:59 ` Christoph Hellwig
@ 2025-05-06 13:48 ` Jens Axboe
  2025-05-06 16:02 ` Bart Van Assche
  2 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2025-05-06 13:48 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Damien Le Moal, linux-block,
	Johannes Thumshirn


On Tue, 06 May 2025 13:27:30 +0200, Johannes Thumshirn wrote:
> 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,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 11:27 [PATCH] block: only update request sector if needed Johannes Thumshirn
  2025-05-06 11:59 ` Christoph Hellwig
  2025-05-06 13:48 ` Jens Axboe
@ 2025-05-06 16:02 ` Bart Van Assche
  2025-05-06 16:27   ` Johannes Thumshirn
  2 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2025-05-06 16:02 UTC (permalink / raw)
  To: Johannes Thumshirn, Jens Axboe
  Cc: Christoph Hellwig, Damien Le Moal, linux-block,
	Johannes Thumshirn

On 5/6/25 4:27 AM, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> 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.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>   block/blk.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/blk.h b/block/blk.h
> index 328075787814..594eeba7b949 100644
> --- a/block/blk.h
> +++ b/block/blk.h
> @@ -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.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 16:02 ` Bart Van Assche
@ 2025-05-06 16:27   ` Johannes Thumshirn
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2025-05-06 16:27 UTC (permalink / raw)
  To: Bart Van Assche, Johannes Thumshirn, Jens Axboe
  Cc: hch, Damien Le Moal, linux-block@vger.kernel.org

On 06.05.25 18:03, Bart Van Assche wrote:
> 
> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] block: only update request sector if needed
  2025-05-06 13:45   ` Jens Axboe
@ 2025-05-06 16:28     ` Johannes Thumshirn
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Thumshirn @ 2025-05-06 16:28 UTC (permalink / raw)
  To: Jens Axboe, hch, Johannes Thumshirn
  Cc: Damien Le Moal, linux-block@vger.kernel.org

On 06.05.25 15:45, Jens Axboe wrote:
> On 5/6/25 5:59 AM, Christoph Hellwig wrote:
>> Looks good:
>>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
> 
> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-05-06 16:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-06 11:27 [PATCH] block: only update request sector if needed Johannes Thumshirn
2025-05-06 11:59 ` Christoph Hellwig
2025-05-06 13:45   ` Jens Axboe
2025-05-06 16:28     ` Johannes Thumshirn
2025-05-06 13:48 ` Jens Axboe
2025-05-06 16:02 ` Bart Van Assche
2025-05-06 16:27   ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox