Skip to content

Commit 138203d

Browse files
committed
md/raid5: merge reshape_progress checking inside get_reshape_loc()
JIRA: https://issues.redhat.com/browse/RHEL-83988 commit 1320fe8 Author: Yu Kuai <[email protected]> Date: Thu Feb 27 20:04:52 2025 +0800 md/raid5: merge reshape_progress checking inside get_reshape_loc() During code review, it's found that other than raid5_bitmap_sector(), reshape_progress is always checked before get_reshape_loc(), while raid5_bitmap_sector() should check as well to prevent holding the lock 'conf->device_lock'. Hence merge that checking inside get_reshape_loc(). Link: https://lore.kernel.org/linux-raid/[email protected] Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Nigel Croxon <[email protected]>
1 parent bf2723f commit 138203d

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

drivers/md/raid5.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5858,6 +5858,9 @@ static enum reshape_loc get_reshape_loc(struct mddev *mddev,
58585858
struct r5conf *conf, sector_t logical_sector)
58595859
{
58605860
sector_t reshape_progress, reshape_safe;
5861+
5862+
if (likely(conf->reshape_progress == MaxSector))
5863+
return LOC_NO_RESHAPE;
58615864
/*
58625865
* Spinlock is needed as reshape_progress may be
58635866
* 64bit on a 32bit platform, and so it might be
@@ -5935,22 +5938,19 @@ static enum stripe_result make_stripe_request(struct mddev *mddev,
59355938
const int rw = bio_data_dir(bi);
59365939
enum stripe_result ret;
59375940
struct stripe_head *sh;
5941+
enum reshape_loc loc;
59385942
sector_t new_sector;
59395943
int previous = 0, flags = 0;
59405944
int seq, dd_idx;
59415945

59425946
seq = read_seqcount_begin(&conf->gen_lock);
5943-
5944-
if (unlikely(conf->reshape_progress != MaxSector)) {
5945-
enum reshape_loc loc = get_reshape_loc(mddev, conf,
5946-
logical_sector);
5947-
if (loc == LOC_INSIDE_RESHAPE) {
5948-
ret = STRIPE_SCHEDULE_AND_RETRY;
5949-
goto out;
5950-
}
5951-
if (loc == LOC_AHEAD_OF_RESHAPE)
5952-
previous = 1;
5947+
loc = get_reshape_loc(mddev, conf, logical_sector);
5948+
if (loc == LOC_INSIDE_RESHAPE) {
5949+
ret = STRIPE_SCHEDULE_AND_RETRY;
5950+
goto out;
59535951
}
5952+
if (loc == LOC_AHEAD_OF_RESHAPE)
5953+
previous = 1;
59545954

59555955
new_sector = raid5_compute_sector(conf, logical_sector, previous,
59565956
&dd_idx, NULL);
@@ -6127,7 +6127,6 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
61276127

61286128
/* Bail out if conflicts with reshape and REQ_NOWAIT is set */
61296129
if ((bi->bi_opf & REQ_NOWAIT) &&
6130-
(conf->reshape_progress != MaxSector) &&
61316130
get_reshape_loc(mddev, conf, logical_sector) == LOC_INSIDE_RESHAPE) {
61326131
bio_wouldblock_error(bi);
61336132
if (rw == WRITE)

0 commit comments

Comments
 (0)