Commit bbcee09f authored by Yu Kuai's avatar Yu Kuai Committed by Jialin Zhang
Browse files

raid10: fix leak of io accounting

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6JN04


CVE: NA

--------------------------------

handle_read_error() will resumit r10_bio by raid10_read_request(), which
will call bio_start_io_acct() again, while bio_end_io_acct() will only
be called once.

Fix the problem by don't account io again from handle_read_error().

Fixes: 528bc2cf ("md/raid10: enable io accounting")
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarHou Tao <houtao1@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parent 4441c142
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1117,7 +1117,7 @@ static void regular_request_wait(struct mddev *mddev, struct r10conf *conf,
}

static void raid10_read_request(struct mddev *mddev, struct bio *bio,
				struct r10bio *r10_bio)
				struct r10bio *r10_bio, bool handle_error)
{
	struct r10conf *conf = mddev->private;
	struct bio *read_bio;
@@ -1187,7 +1187,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio,
	}
	slot = r10_bio->read_slot;

	if (blk_queue_io_stat(bio->bi_disk->queue))
	if (!handle_error && blk_queue_io_stat(bio->bi_disk->queue))
		r10_bio->start_time = bio_start_io_acct(bio);
	read_bio = bio_clone_fast(bio, gfp, &mddev->bio_set);

@@ -1503,7 +1503,7 @@ static void __make_request(struct mddev *mddev, struct bio *bio, int sectors)
	memset(r10_bio->devs, 0, sizeof(r10_bio->devs[0]) * conf->copies);

	if (bio_data_dir(bio) == READ)
		raid10_read_request(mddev, bio, r10_bio);
		raid10_read_request(mddev, bio, r10_bio, false);
	else
		raid10_write_request(mddev, bio, r10_bio);
}
@@ -2597,7 +2597,7 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
	rdev_dec_pending(rdev, mddev);
	allow_barrier(conf);
	r10_bio->state = 0;
	raid10_read_request(mddev, r10_bio->master_bio, r10_bio);
	raid10_read_request(mddev, r10_bio->master_bio, r10_bio, true);
}

static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)