Skip to content

Commit

Permalink
md: fix bi_status reporting in md_end_clone_io
Browse files Browse the repository at this point in the history
commit 45b4789 upstream.

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: 1076481 ("md: add io accounting for raid0 and raid5")
Cc: stable@vger.kernel.org # v5.14+
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>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
liu-song-6 authored and gregkh committed Dec 3, 2023
1 parent 415f644 commit fa9bacc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -8648,7 +8648,8 @@ static void md_end_io_acct(struct bio *bio)
struct md_io_acct *md_io_acct = bio->bi_private;
struct bio *orig_bio = md_io_acct->orig_bio;

orig_bio->bi_status = bio->bi_status;
if (bio->bi_status && !orig_bio->bi_status)
orig_bio->bi_status = bio->bi_status;

bio_end_io_acct(orig_bio, md_io_acct->start_time);
bio_put(bio);
Expand Down

0 comments on commit fa9bacc

Please sign in to comment.