mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] md/raid10: fix missing discard IO accounting
@ 2025-03-25  1:57 Yu Kuai
  2025-03-25  7:04 ` Coly Li
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yu Kuai @ 2025-03-25  1:57 UTC (permalink / raw)
  To: song, yukuai3, jgq516
  Cc: linux-raid, linux-kernel, yukuai1, yi.zhang, yangerkun

From: Yu Kuai <yukuai3@huawei.com>

md_account_bio() is not called from raid10_handle_discard(), now that we
handle bitmap inside md_account_bio(), also fix missing
bitmap_startwrite for discard.

Test whole disk discard for 20G raid10:

Before:
Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
md0    48.00     16.00     0.00   0.00    5.42   341.33

After:
Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
md0    68.00  20462.00     0.00   0.00    2.65 308133.65

Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/raid10.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9d8516acf2fd..6ef65b4d1093 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1735,6 +1735,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
 	 * The discard bio returns only first r10bio finishes
 	 */
 	if (first_copy) {
+		md_account_bio(mddev, &bio);
 		r10_bio->master_bio = bio;
 		set_bit(R10BIO_Discard, &r10_bio->state);
 		first_copy = false;
-- 
2.39.2


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

* Re: [PATCH] md/raid10: fix missing discard IO accounting
  2025-03-25  1:57 [PATCH] md/raid10: fix missing discard IO accounting Yu Kuai
@ 2025-03-25  7:04 ` Coly Li
  2025-03-25  7:27   ` Yu Kuai
  2025-03-25 11:47 ` Coly Li
  2025-03-25 13:35 ` Yu Kuai
  2 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2025-03-25  7:04 UTC (permalink / raw)
  To: Yu Kuai
  Cc: song, yukuai3, jgq516, linux-raid, linux-kernel, yi.zhang, yangerkun

On Tue, Mar 25, 2025 at 09:57:46AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> md_account_bio() is not called from raid10_handle_discard(), now that we
> handle bitmap inside md_account_bio(), also fix missing
> bitmap_startwrite for discard.
> 
> Test whole disk discard for 20G raid10:
> 
> Before:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    48.00     16.00     0.00   0.00    5.42   341.33
> 
> After:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    68.00  20462.00     0.00   0.00    2.65 308133.65
> 
> Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Should we treat discard request as real I/O?

Normally IMHO discard request should not be counted as real data transfer,
correct me if I am wrong.

Thanks.


> ---
>  drivers/md/raid10.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 9d8516acf2fd..6ef65b4d1093 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1735,6 +1735,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
>  	 * The discard bio returns only first r10bio finishes
>  	 */
>  	if (first_copy) {
> +		md_account_bio(mddev, &bio);
>  		r10_bio->master_bio = bio;
>  		set_bit(R10BIO_Discard, &r10_bio->state);
>  		first_copy = false;
> -- 
> 2.39.2
> 
> 

-- 
Coly Li

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

* Re: [PATCH] md/raid10: fix missing discard IO accounting
  2025-03-25  7:04 ` Coly Li
@ 2025-03-25  7:27   ` Yu Kuai
  2025-03-25 11:48     ` Coly Li
  0 siblings, 1 reply; 6+ messages in thread
From: Yu Kuai @ 2025-03-25  7:27 UTC (permalink / raw)
  To: Coly Li, Yu Kuai
  Cc: song, jgq516, linux-raid, linux-kernel, yi.zhang, yangerkun, yukuai (C)

Hi,

在 2025/03/25 15:04, Coly Li 写道:
> On Tue, Mar 25, 2025 at 09:57:46AM +0800, Yu Kuai wrote:
>> From: Yu Kuai <yukuai3@huawei.com>
>>
>> md_account_bio() is not called from raid10_handle_discard(), now that we
>> handle bitmap inside md_account_bio(), also fix missing
>> bitmap_startwrite for discard.
>>
>> Test whole disk discard for 20G raid10:
>>
>> Before:
>> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
>> md0    48.00     16.00     0.00   0.00    5.42   341.33
>>
>> After:
>> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
>> md0    68.00  20462.00     0.00   0.00    2.65 308133.65
>>
>> Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> 
> Should we treat discard request as real I/O?
> 
> Normally IMHO discard request should not be counted as real data transfer,
> correct me if I am wrong.

Normally it's not, that's why discard IOs are accounted separately in
the block layer.

Also notice that discard should be treated as write, because after
discard, reading will get zero data.

Thanks,
Kuai

> 
> Thanks.
> 
> 
>> ---
>>   drivers/md/raid10.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
>> index 9d8516acf2fd..6ef65b4d1093 100644
>> --- a/drivers/md/raid10.c
>> +++ b/drivers/md/raid10.c
>> @@ -1735,6 +1735,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
>>   	 * The discard bio returns only first r10bio finishes
>>   	 */
>>   	if (first_copy) {
>> +		md_account_bio(mddev, &bio);
>>   		r10_bio->master_bio = bio;
>>   		set_bit(R10BIO_Discard, &r10_bio->state);
>>   		first_copy = false;
>> -- 
>> 2.39.2
>>
>>
> 


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

* Re: [PATCH] md/raid10: fix missing discard IO accounting
  2025-03-25  1:57 [PATCH] md/raid10: fix missing discard IO accounting Yu Kuai
  2025-03-25  7:04 ` Coly Li
@ 2025-03-25 11:47 ` Coly Li
  2025-03-25 13:35 ` Yu Kuai
  2 siblings, 0 replies; 6+ messages in thread
From: Coly Li @ 2025-03-25 11:47 UTC (permalink / raw)
  To: Yu Kuai
  Cc: song, yukuai3, jgq516, linux-raid, linux-kernel, yi.zhang, yangerkun

On Tue, Mar 25, 2025 at 09:57:46AM +0800, Yu Kuai wrote:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> md_account_bio() is not called from raid10_handle_discard(), now that we
> handle bitmap inside md_account_bio(), also fix missing
> bitmap_startwrite for discard.
> 
> Test whole disk discard for 20G raid10:
> 
> Before:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    48.00     16.00     0.00   0.00    5.42   341.33
> 
> After:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    68.00  20462.00     0.00   0.00    2.65 308133.65
> 
> Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>


Acked-by: Coly Li <colyli@kernel.org>

Thanks.

> ---
>  drivers/md/raid10.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 9d8516acf2fd..6ef65b4d1093 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1735,6 +1735,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
>  	 * The discard bio returns only first r10bio finishes
>  	 */
>  	if (first_copy) {
> +		md_account_bio(mddev, &bio);
>  		r10_bio->master_bio = bio;
>  		set_bit(R10BIO_Discard, &r10_bio->state);
>  		first_copy = false;
> -- 
> 2.39.2
> 
> 

-- 
Coly Li

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

* Re: [PATCH] md/raid10: fix missing discard IO accounting
  2025-03-25  7:27   ` Yu Kuai
@ 2025-03-25 11:48     ` Coly Li
  0 siblings, 0 replies; 6+ messages in thread
From: Coly Li @ 2025-03-25 11:48 UTC (permalink / raw)
  To: Yu Kuai
  Cc: Coly Li, song, jgq516, linux-raid, linux-kernel, yi.zhang,
	yangerkun, yukuai (C)



> 2025年3月25日 15:27,Yu Kuai <yukuai1@huaweicloud.com> 写道:
> 
> Hi,
> 
> 在 2025/03/25 15:04, Coly Li 写道:
>> On Tue, Mar 25, 2025 at 09:57:46AM +0800, Yu Kuai wrote:
>>> From: Yu Kuai <yukuai3@huawei.com>
>>> 
>>> md_account_bio() is not called from raid10_handle_discard(), now that we
>>> handle bitmap inside md_account_bio(), also fix missing
>>> bitmap_startwrite for discard.
>>> 
>>> Test whole disk discard for 20G raid10:
>>> 
>>> Before:
>>> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
>>> md0    48.00     16.00     0.00   0.00    5.42   341.33
>>> 
>>> After:
>>> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
>>> md0    68.00  20462.00     0.00   0.00    2.65 308133.65
>>> 
>>> Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
>>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
>> Should we treat discard request as real I/O?
>> Normally IMHO discard request should not be counted as real data transfer,
>> correct me if I am wrong.
> 
> Normally it's not, that's why discard IOs are accounted separately in
> the block layer.
> 
> Also notice that discard should be treated as write, because after
> discard, reading will get zero data.

I see, it is for the separated discard counting.  Sure, I reply my Acked-by on the original patch.

Thank you for the explanation.

Coly Li

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

* Re: [PATCH] md/raid10: fix missing discard IO accounting
  2025-03-25  1:57 [PATCH] md/raid10: fix missing discard IO accounting Yu Kuai
  2025-03-25  7:04 ` Coly Li
  2025-03-25 11:47 ` Coly Li
@ 2025-03-25 13:35 ` Yu Kuai
  2 siblings, 0 replies; 6+ messages in thread
From: Yu Kuai @ 2025-03-25 13:35 UTC (permalink / raw)
  To: Yu Kuai, song, jgq516
  Cc: linux-raid, linux-kernel, yi.zhang, yangerkun, yukuai (C)

在 2025/03/25 9:57, Yu Kuai 写道:
> From: Yu Kuai <yukuai3@huawei.com>
> 
> md_account_bio() is not called from raid10_handle_discard(), now that we
> handle bitmap inside md_account_bio(), also fix missing
> bitmap_startwrite for discard.
> 
> Test whole disk discard for 20G raid10:
> 
> Before:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    48.00     16.00     0.00   0.00    5.42   341.33
> 
> After:
> Device   d/s     dMB/s   drqm/s  %drqm d_await dareq-sz
> md0    68.00  20462.00     0.00   0.00    2.65 308133.65
> 
> Fixes: 528bc2cf2fcc ("md/raid10: enable io accounting")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   drivers/md/raid10.c | 1 +
>   1 file changed, 1 insertion(+)
> 
Applied to md-6.15
Thanks

> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 9d8516acf2fd..6ef65b4d1093 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1735,6 +1735,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio)
>   	 * The discard bio returns only first r10bio finishes
>   	 */
>   	if (first_copy) {
> +		md_account_bio(mddev, &bio);
>   		r10_bio->master_bio = bio;
>   		set_bit(R10BIO_Discard, &r10_bio->state);
>   		first_copy = false;
> 


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

end of thread, other threads:[~2025-03-25 13:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25  1:57 [PATCH] md/raid10: fix missing discard IO accounting Yu Kuai
2025-03-25  7:04 ` Coly Li
2025-03-25  7:27   ` Yu Kuai
2025-03-25 11:48     ` Coly Li
2025-03-25 11:47 ` Coly Li
2025-03-25 13:35 ` Yu Kuai

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

all inboxes | Powered by JetHome®