diff mbox series

[01/26] block: Restore sector of flush requests

Message ID 20240202073104.2418230-2-dlemoal@kernel.org (mailing list archive)
State Not Applicable
Headers show
Series Zone write plugging | expand

Commit Message

Damien Le Moal Feb. 2, 2024, 7:30 a.m. UTC
On completion of a flush sequence, blk_flush_restore_request() restores
the bio of a request to the original submitted BIO. However, the last
use of the request in the flush sequence may have been for a POSTFLUSH
which does not have a sector. So make sure to restore the request sector
using the iter sector of the original BIO. This BIO has not changed yet
since the completions of the flush sequence intermediate steps use
requeueing of the request until all steps are completed.

Restoring the request sector ensures that blk_mq_end_request() will see
a valid sector as originally set when the flush BIO was submitted.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
 block/blk-flush.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Hannes Reinecke Feb. 4, 2024, 11:55 a.m. UTC | #1
On 2/2/24 15:30, Damien Le Moal wrote:
> On completion of a flush sequence, blk_flush_restore_request() restores
> the bio of a request to the original submitted BIO. However, the last
> use of the request in the flush sequence may have been for a POSTFLUSH
> which does not have a sector. So make sure to restore the request sector
> using the iter sector of the original BIO. This BIO has not changed yet
> since the completions of the flush sequence intermediate steps use
> requeueing of the request until all steps are completed.
> 
> Restoring the request sector ensures that blk_mq_end_request() will see
> a valid sector as originally set when the flush BIO was submitted.
> 
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   block/blk-flush.c | 1 +
>   1 file changed, 1 insertion(+)
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Bart Van Assche Feb. 5, 2024, 5:22 p.m. UTC | #2
On 2/1/24 23:30, Damien Le Moal wrote:
> diff --git a/block/blk-flush.c b/block/blk-flush.c
> index b0f314f4bc14..2f58ae018464 100644
> --- a/block/blk-flush.c
> +++ b/block/blk-flush.c
> @@ -130,6 +130,7 @@ static void blk_flush_restore_request(struct request *rq)
>   	 * original @rq->bio.  Restore it.
>   	 */
>   	rq->bio = rq->biotail;
> +	rq->__sector = rq->bio->bi_iter.bi_sector;

Hmm ... is it guaranteed that rq->bio != NULL in this context?

Thanks,

Bart.
Damien Le Moal Feb. 5, 2024, 11:42 p.m. UTC | #3
On 2/6/24 02:22, Bart Van Assche wrote:
> On 2/1/24 23:30, Damien Le Moal wrote:
>> diff --git a/block/blk-flush.c b/block/blk-flush.c
>> index b0f314f4bc14..2f58ae018464 100644
>> --- a/block/blk-flush.c
>> +++ b/block/blk-flush.c
>> @@ -130,6 +130,7 @@ static void blk_flush_restore_request(struct request *rq)
>>   	 * original @rq->bio.  Restore it.
>>   	 */
>>   	rq->bio = rq->biotail;
>> +	rq->__sector = rq->bio->bi_iter.bi_sector;
> 
> Hmm ... is it guaranteed that rq->bio != NULL in this context?

Yes.

> 
> Thanks,
> 
> Bart.
>
diff mbox series

Patch

diff --git a/block/blk-flush.c b/block/blk-flush.c
index b0f314f4bc14..2f58ae018464 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -130,6 +130,7 @@  static void blk_flush_restore_request(struct request *rq)
 	 * original @rq->bio.  Restore it.
 	 */
 	rq->bio = rq->biotail;
+	rq->__sector = rq->bio->bi_iter.bi_sector;
 
 	/* make @rq a normal request */
 	rq->rq_flags &= ~RQF_FLUSH_SEQ;