Skip to content

Commit 2d389a7

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid1: Clean up local variable 'b' from raid1_read_request()
The local variable will only be used onced, in the error path that read_balance() failed to find a valid rdev to read. Since now the rdev is ensured can't be removed from conf while IO is still pending, remove the local variable and dereference rdev directly. Since we're here, also remove an extra empty line, and unnecessary type conversion from sector_t(u64) to unsigned long long. Signed-off-by: Yu Kuai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Song Liu <[email protected]>
1 parent 86ad4cd commit 2d389a7

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

drivers/md/raid1.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,6 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
13171317
int max_sectors;
13181318
int rdisk;
13191319
bool r1bio_existed = !!r1_bio;
1320-
char b[BDEVNAME_SIZE];
13211320

13221321
/*
13231322
* If r1_bio is set, we are blocking the raid1d thread
@@ -1326,16 +1325,6 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
13261325
*/
13271326
gfp_t gfp = r1_bio ? (GFP_NOIO | __GFP_HIGH) : GFP_NOIO;
13281327

1329-
if (r1bio_existed) {
1330-
/* Need to get the block device name carefully */
1331-
struct md_rdev *rdev = conf->mirrors[r1_bio->read_disk].rdev;
1332-
1333-
if (rdev)
1334-
snprintf(b, sizeof(b), "%pg", rdev->bdev);
1335-
else
1336-
strcpy(b, "???");
1337-
}
1338-
13391328
/*
13401329
* Still need barrier for READ in case that whole
13411330
* array is frozen.
@@ -1357,15 +1346,13 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
13571346
* used and no empty request is available.
13581347
*/
13591348
rdisk = read_balance(conf, r1_bio, &max_sectors);
1360-
13611349
if (rdisk < 0) {
13621350
/* couldn't find anywhere to read from */
1363-
if (r1bio_existed) {
1364-
pr_crit_ratelimited("md/raid1:%s: %s: unrecoverable I/O read error for block %llu\n",
1351+
if (r1bio_existed)
1352+
pr_crit_ratelimited("md/raid1:%s: %pg: unrecoverable I/O read error for block %llu\n",
13651353
mdname(mddev),
1366-
b,
1367-
(unsigned long long)r1_bio->sector);
1368-
}
1354+
conf->mirrors[r1_bio->read_disk].rdev->bdev,
1355+
r1_bio->sector);
13691356
raid_end_bio_io(r1_bio);
13701357
return;
13711358
}

0 commit comments

Comments
 (0)