Commit a6502b42 authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Zheng Zengkai
Browse files

md/raid1: rename print_msg with r1bio_existed

mainline inclusion
from mainline-v5.14-rc1
commit 9b8ae7b9
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I587H6
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=9b8ae7b938235229ccb112c4e887ff1bcc232836



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

The caller of raid1_read_request could pass NULL or a valid pointer for
"struct r1bio *r1_bio", so it actually means whether r1_bio is existed
or not.

Signed-off-by: default avatarGuoqing Jiang <jiangguoqing@kylinos.cn>
Signed-off-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarZhang Wensheng <zhangwensheng5@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent f54d03a3
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1210,7 +1210,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
	const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
	const unsigned long do_sync = (bio->bi_opf & REQ_SYNC);
	int max_sectors;
	int max_sectors;
	int rdisk;
	int rdisk;
	bool print_msg = !!r1_bio;
	bool r1bio_existed = !!r1_bio;
	char b[BDEVNAME_SIZE];
	char b[BDEVNAME_SIZE];


	/*
	/*
@@ -1220,7 +1220,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
	 */
	 */
	gfp_t gfp = r1_bio ? (GFP_NOIO | __GFP_HIGH) : GFP_NOIO;
	gfp_t gfp = r1_bio ? (GFP_NOIO | __GFP_HIGH) : GFP_NOIO;


	if (print_msg) {
	if (r1bio_existed) {
		/* Need to get the block device name carefully */
		/* Need to get the block device name carefully */
		struct md_rdev *rdev;
		struct md_rdev *rdev;
		rcu_read_lock();
		rcu_read_lock();
@@ -1252,7 +1252,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,


	if (rdisk < 0) {
	if (rdisk < 0) {
		/* couldn't find anywhere to read from */
		/* couldn't find anywhere to read from */
		if (print_msg) {
		if (r1bio_existed) {
			pr_crit_ratelimited("md/raid1:%s: %s: unrecoverable I/O read error for block %llu\n",
			pr_crit_ratelimited("md/raid1:%s: %s: unrecoverable I/O read error for block %llu\n",
					    mdname(mddev),
					    mdname(mddev),
					    b,
					    b,
@@ -1263,7 +1263,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
	}
	}
	mirror = conf->mirrors + rdisk;
	mirror = conf->mirrors + rdisk;


	if (print_msg)
	if (r1bio_existed)
		pr_info_ratelimited("md/raid1:%s: redirecting sector %llu to other mirror: %s\n",
		pr_info_ratelimited("md/raid1:%s: redirecting sector %llu to other mirror: %s\n",
				    mdname(mddev),
				    mdname(mddev),
				    (unsigned long long)r1_bio->sector,
				    (unsigned long long)r1_bio->sector,