2023-07-10 07:24:16

by Chengming Zhou

[permalink] [raw]
Subject: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

From: Chengming Zhou <[email protected]>

If the policy == (REQ_FSEQ_DATA | REQ_FSEQ_POSTFLUSH), it means that the
data sequence and post-flush sequence need to be done for this request.

The rq->flush.seq should record what sequences have been done (or don't
need to be done). So in this case, pre-flush doesn't need to be done,
we should init rq->flush.seq to REQ_FSEQ_PREFLUSH not REQ_FSEQ_POSTFLUSH.

Of course, this doesn't cause any problem in fact, since pre-flush and
post-flush sequence do the same thing for now.

But we'd better fix this value, and the next patch will depend on this
value to be correct.

Signed-off-by: Chengming Zhou <[email protected]>
---
block/blk-flush.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 4826d2d61a23..094a6adb2718 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -448,7 +448,7 @@ bool blk_insert_flush(struct request *rq)
* the post flush, and then just pass the command on.
*/
blk_rq_init_flush(rq);
- rq->flush.seq |= REQ_FSEQ_POSTFLUSH;
+ rq->flush.seq |= REQ_FSEQ_PREFLUSH;
spin_lock_irq(&fq->mq_flush_lock);
fq->flush_data_in_flight++;
spin_unlock_irq(&fq->mq_flush_lock);
--
2.41.0



2023-07-10 13:47:13

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On Mon, Jul 10, 2023 at 02:47:04PM +0800, [email protected] wrote:
> From: Chengming Zhou <[email protected]>
>
> If the policy == (REQ_FSEQ_DATA | REQ_FSEQ_POSTFLUSH), it means that the
> data sequence and post-flush sequence need to be done for this request.
>
> The rq->flush.seq should record what sequences have been done (or don't
> need to be done). So in this case, pre-flush doesn't need to be done,
> we should init rq->flush.seq to REQ_FSEQ_PREFLUSH not REQ_FSEQ_POSTFLUSH.
>
> Of course, this doesn't cause any problem in fact, since pre-flush and
> post-flush sequence do the same thing for now.

I wonder if it really doesn't cause any problems, but the change for
sure looks good:

Reviewed-by: Christoph Hellwig <[email protected]>

It should probably go before your other flush optimizations and maybe
grow a fixes tag.

2023-07-11 11:29:13

by Chengming Zhou

[permalink] [raw]
Subject: Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On 2023/7/10 21:30, Christoph Hellwig wrote:
> On Mon, Jul 10, 2023 at 02:47:04PM +0800, [email protected] wrote:
>> From: Chengming Zhou <[email protected]>
>>
>> If the policy == (REQ_FSEQ_DATA | REQ_FSEQ_POSTFLUSH), it means that the
>> data sequence and post-flush sequence need to be done for this request.
>>
>> The rq->flush.seq should record what sequences have been done (or don't
>> need to be done). So in this case, pre-flush doesn't need to be done,
>> we should init rq->flush.seq to REQ_FSEQ_PREFLUSH not REQ_FSEQ_POSTFLUSH.
>>
>> Of course, this doesn't cause any problem in fact, since pre-flush and
>> post-flush sequence do the same thing for now.
>
> I wonder if it really doesn't cause any problems, but the change for
> sure looks good:
>
> Reviewed-by: Christoph Hellwig <[email protected]>
>
> It should probably go before your other flush optimizations and maybe
> grow a fixes tag.

Ok, will add a Fixes tag and send it as a separate patch since it's a bug fix.

Thanks.


2023-07-11 11:33:19

by Chengming Zhou

[permalink] [raw]
Subject: Re: [External] Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On 2023/7/11 19:06, Chengming Zhou wrote:
> On 2023/7/10 21:30, Christoph Hellwig wrote:
>> On Mon, Jul 10, 2023 at 02:47:04PM +0800, [email protected] wrote:
>>> From: Chengming Zhou <[email protected]>
>>>
>>> If the policy == (REQ_FSEQ_DATA | REQ_FSEQ_POSTFLUSH), it means that the
>>> data sequence and post-flush sequence need to be done for this request.
>>>
>>> The rq->flush.seq should record what sequences have been done (or don't
>>> need to be done). So in this case, pre-flush doesn't need to be done,
>>> we should init rq->flush.seq to REQ_FSEQ_PREFLUSH not REQ_FSEQ_POSTFLUSH.
>>>
>>> Of course, this doesn't cause any problem in fact, since pre-flush and
>>> post-flush sequence do the same thing for now.
>>
>> I wonder if it really doesn't cause any problems, but the change for
>> sure looks good:
>>
>> Reviewed-by: Christoph Hellwig <[email protected]>
>>
>> It should probably go before your other flush optimizations and maybe
>> grow a fixes tag.
>
> Ok, will add a Fixes tag and send it as a separate patch since it's a bug fix.
>

Well, I should put it in that series before other flush optimizations instead.


2023-07-11 11:43:17

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On Tue, Jul 11, 2023 at 07:06:20PM +0800, Chengming Zhou wrote:
> Ok, will add a Fixes tag and send it as a separate patch since it's a bug fix.

Btw, it's probably not worth resending patch 2 until we've figured out
and dealt with the SATA flush regression that Chuck reported.

2023-07-11 12:19:22

by Chengming Zhou

[permalink] [raw]
Subject: Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On 2023/7/11 19:31, Christoph Hellwig wrote:
> On Tue, Jul 11, 2023 at 07:06:20PM +0800, Chengming Zhou wrote:
>> Ok, will add a Fixes tag and send it as a separate patch since it's a bug fix.
>
> Btw, it's probably not worth resending patch 2 until we've figured out
> and dealt with the SATA flush regression that Chuck reported.

Ok, I will not resend patch 2. As for the patch 1, should I resend it as a separate patch
or just put it in that series [1] before other flush optimizations ?

I search on the block mail list, find the issue [2] you mentioned, will look into it too.

[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://lore.kernel.org/linux-block/[email protected]/

2023-07-11 12:19:33

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 1/2] blk-flush: fix rq->flush.seq for post-flush requests

On Tue, Jul 11, 2023 at 07:52:11PM +0800, Chengming Zhou wrote:
> On 2023/7/11 19:31, Christoph Hellwig wrote:
> > On Tue, Jul 11, 2023 at 07:06:20PM +0800, Chengming Zhou wrote:
> >> Ok, will add a Fixes tag and send it as a separate patch since it's a bug fix.
> >
> > Btw, it's probably not worth resending patch 2 until we've figured out
> > and dealt with the SATA flush regression that Chuck reported.
>
> Ok, I will not resend patch 2. As for the patch 1, should I resend it as a separate patch
> or just put it in that series [1] before other flush optimizations ?

I'd wait a bit for debugging the regression. For the worst case we'll have
to revert the patch, which currently can be done cleanly, but can't be
with that patch.