linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] md: fix bi_status reporting in md_end_clone_io
@ 2023-11-18  0:39 Song Liu
  2023-11-20  1:05 ` Yu Kuai
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Song Liu @ 2023-11-18  0:39 UTC (permalink / raw)
  To: linux-raid; +Cc: Song Liu, Bhanu Victor DiCara, Xiao Ni, Guoqing Jiang

md_end_clone_io() may overwrite error status in orig_bio->bi_status with
BLK_STS_OK. This could happen when orig_bio has BIO_CHAIN (split by
md_submit_bio => bio_split_to_limits, for example). As a result, upper
layer may miss error reported from md (or the device) and consider the
failed IO was successful.

Fix this by only update orig_bio->bi_status when current bio reports
error and orig_bio is BLK_STS_OK. This is the same behavior as
__bio_chain_endio().

Fixes: 10764815ff47 ("md: add io accounting for raid0 and raid5")
Reported-by: Bhanu Victor DiCara <00bvd0+linux@gmail.com>
Closes: https://lore.kernel.org/regressions/5727380.DvuYhMxLoT@bvd0/
Signed-off-by: Song Liu <song@kernel.org>
Tested-by: Xiao Ni <xni@redhat.com>
Cc: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4ee4593c874a..c94373d64f2c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8666,7 +8666,8 @@ static void md_end_clone_io(struct bio *bio)
 	struct bio *orig_bio = md_io_clone->orig_bio;
 	struct mddev *mddev = md_io_clone->mddev;
 
-	orig_bio->bi_status = bio->bi_status;
+	if (bio->bi_status && !orig_bio->bi_status)
+		orig_bio->bi_status = bio->bi_status;
 
 	if (md_io_clone->start_time)
 		bio_end_io_acct(orig_bio, md_io_clone->start_time);
-- 
2.34.1


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

* Re: [PATCH] md: fix bi_status reporting in md_end_clone_io
  2023-11-18  0:39 [PATCH] md: fix bi_status reporting in md_end_clone_io Song Liu
@ 2023-11-20  1:05 ` Yu Kuai
  2023-11-20  1:31 ` Guoqing Jiang
  2023-11-20  1:40 ` Guoqing Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Yu Kuai @ 2023-11-20  1:05 UTC (permalink / raw)
  To: Song Liu, linux-raid
  Cc: Bhanu Victor DiCara, Xiao Ni, Guoqing Jiang, yukuai (C)

在 2023/11/18 8:39, Song Liu 写道:
> md_end_clone_io() may overwrite error status in orig_bio->bi_status with
> BLK_STS_OK. This could happen when orig_bio has BIO_CHAIN (split by
> md_submit_bio => bio_split_to_limits, for example). As a result, upper
> layer may miss error reported from md (or the device) and consider the
> failed IO was successful.
> 
> Fix this by only update orig_bio->bi_status when current bio reports
> error and orig_bio is BLK_STS_OK. This is the same behavior as
> __bio_chain_endio().

LGTM
Reviewed-by: Yu Kuai <yukuai3@huawei.com>

> 
> Fixes: 10764815ff47 ("md: add io accounting for raid0 and raid5")
> Reported-by: Bhanu Victor DiCara <00bvd0+linux@gmail.com>
> Closes: https://lore.kernel.org/regressions/5727380.DvuYhMxLoT@bvd0/
> Signed-off-by: Song Liu <song@kernel.org>
> Tested-by: Xiao Ni <xni@redhat.com>
> Cc: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>   drivers/md/md.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 4ee4593c874a..c94373d64f2c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8666,7 +8666,8 @@ static void md_end_clone_io(struct bio *bio)
>   	struct bio *orig_bio = md_io_clone->orig_bio;
>   	struct mddev *mddev = md_io_clone->mddev;
>   
> -	orig_bio->bi_status = bio->bi_status;
> +	if (bio->bi_status && !orig_bio->bi_status)
> +		orig_bio->bi_status = bio->bi_status;
>   
>   	if (md_io_clone->start_time)
>   		bio_end_io_acct(orig_bio, md_io_clone->start_time);
> 


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

* Re: [PATCH] md: fix bi_status reporting in md_end_clone_io
  2023-11-18  0:39 [PATCH] md: fix bi_status reporting in md_end_clone_io Song Liu
  2023-11-20  1:05 ` Yu Kuai
@ 2023-11-20  1:31 ` Guoqing Jiang
  2023-11-20  1:40 ` Guoqing Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Guoqing Jiang @ 2023-11-20  1:31 UTC (permalink / raw)
  To: Song Liu, linux-raid; +Cc: Bhanu Victor DiCara, Xiao Ni



On 11/18/23 08:39, Song Liu wrote:
> md_end_clone_io() may overwrite error status in orig_bio->bi_status with
> BLK_STS_OK. This could happen when orig_bio has BIO_CHAIN (split by
> md_submit_bio => bio_split_to_limits, for example). As a result, upper
> layer may miss error reported from md (or the device) and consider the
> failed IO was successful.
>
> Fix this by only update orig_bio->bi_status when current bio reports
> error and orig_bio is BLK_STS_OK. This is the same behavior as
> __bio_chain_endio().

DRBD has the similar change.

> Fixes: 10764815ff47 ("md: add io accounting for raid0 and raid5")
> Reported-by: Bhanu Victor DiCara <00bvd0+linux@gmail.com>
> Closes: https://lore.kernel.org/regressions/5727380.DvuYhMxLoT@bvd0/
> Signed-off-by: Song Liu <song@kernel.org>
> Tested-by: Xiao Ni <xni@redhat.com>
> Cc: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>   drivers/md/md.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 4ee4593c874a..c94373d64f2c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8666,7 +8666,8 @@ static void md_end_clone_io(struct bio *bio)
>   	struct bio *orig_bio = md_io_clone->orig_bio;
>   	struct mddev *mddev = md_io_clone->mddev;
>   
> -	orig_bio->bi_status = bio->bi_status;
> +	if (bio->bi_status && !orig_bio->bi_status)
> +		orig_bio->bi_status = bio->bi_status;

Thanks for the fix!

Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Guoqing

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

* Re: [PATCH] md: fix bi_status reporting in md_end_clone_io
  2023-11-18  0:39 [PATCH] md: fix bi_status reporting in md_end_clone_io Song Liu
  2023-11-20  1:05 ` Yu Kuai
  2023-11-20  1:31 ` Guoqing Jiang
@ 2023-11-20  1:40 ` Guoqing Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Guoqing Jiang @ 2023-11-20  1:40 UTC (permalink / raw)
  To: Song Liu, linux-raid; +Cc: Bhanu Victor DiCara, Xiao Ni, guoqing.jiang



On 11/18/23 08:39, Song Liu wrote:
> md_end_clone_io() may overwrite error status in orig_bio->bi_status with
> BLK_STS_OK. This could happen when orig_bio has BIO_CHAIN (split by
> md_submit_bio => bio_split_to_limits, for example). As a result, upper
> layer may miss error reported from md (or the device) and consider the
> failed IO was successful.
>
> Fix this by only update orig_bio->bi_status when current bio reports
> error and orig_bio is BLK_STS_OK. This is the same behavior as
> __bio_chain_endio().

DRBD has the similar change.

> Fixes: 10764815ff47 ("md: add io accounting for raid0 and raid5")
> Reported-by: Bhanu Victor DiCara <00bvd0+linux@gmail.com>
> Closes: https://lore.kernel.org/regressions/5727380.DvuYhMxLoT@bvd0/
> Signed-off-by: Song Liu <song@kernel.org>
> Tested-by: Xiao Ni <xni@redhat.com>
> Cc: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>   drivers/md/md.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 4ee4593c874a..c94373d64f2c 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8666,7 +8666,8 @@ static void md_end_clone_io(struct bio *bio)
>   	struct bio *orig_bio = md_io_clone->orig_bio;
>   	struct mddev *mddev = md_io_clone->mddev;
>   
> -	orig_bio->bi_status = bio->bi_status;
> +	if (bio->bi_status && !orig_bio->bi_status)
> +		orig_bio->bi_status = bio->bi_status;

Thanks for the fix!

Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>

Guoqing

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

end of thread, other threads:[~2023-11-20  1:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-18  0:39 [PATCH] md: fix bi_status reporting in md_end_clone_io Song Liu
2023-11-20  1:05 ` Yu Kuai
2023-11-20  1:31 ` Guoqing Jiang
2023-11-20  1:40 ` Guoqing Jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).