Skip to content

Commit 55dcfdf

Browse files
mauelshaMikulas Patocka
authored andcommitted
dm raid: use proper md_ro_state enumerators
The dm-raid code was using hardcoded integer values to represent the read-only/read-write state of RAID arrays instead of the proper enumeration constants defined in the md_ro_state enumerator type. Changes: - Replace hardcoded integers with the appropriate md_ro_state enumerator values - Add the missing MD_RDONLY setting in the post_suspend function (no failures have been attributed to this inconsistency, the fix ensures correct state transitions for completeness) This improves code clarity and maintainability by using the defined enumeration constants rather than magic numbers, ensuring the code properly conforms to the established API interface. Signed-off-by: Heinz Mauelshagen <[email protected]> Signed-off-by: Mikulas Patocka <[email protected]>
1 parent 1cd83fb commit 55dcfdf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/md/dm-raid.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3247,7 +3247,7 @@ static int raid_ctr(struct dm_target *ti, unsigned int argc, char **argv)
32473247
rs_reset_inconclusive_reshape(rs);
32483248

32493249
/* Start raid set read-only and assumed clean to change in raid_resume() */
3250-
rs->md.ro = 1;
3250+
rs->md.ro = MD_RDONLY;
32513251
rs->md.in_sync = 1;
32523252

32533253
/* Has to be held on running the array */
@@ -3385,7 +3385,7 @@ static enum sync_state decipher_sync_action(struct mddev *mddev, unsigned long r
33853385
/* The MD sync thread can be done with io or be interrupted but still be running */
33863386
if (!test_bit(MD_RECOVERY_DONE, &recovery) &&
33873387
(test_bit(MD_RECOVERY_RUNNING, &recovery) ||
3388-
(!mddev->ro && test_bit(MD_RECOVERY_NEEDED, &recovery)))) {
3388+
(md_is_rdwr(mddev) && test_bit(MD_RECOVERY_NEEDED, &recovery)))) {
33893389
if (test_bit(MD_RECOVERY_RESHAPE, &recovery))
33903390
return st_reshape;
33913391

@@ -3775,11 +3775,11 @@ static int raid_message(struct dm_target *ti, unsigned int argc, char **argv,
37753775
} else
37763776
return -EINVAL;
37773777
}
3778-
if (mddev->ro == 2) {
3778+
if (mddev->ro == MD_AUTO_READ) {
37793779
/* A write to sync_action is enough to justify
37803780
* canceling read-auto mode
37813781
*/
3782-
mddev->ro = 0;
3782+
mddev->ro = MD_RDWR;
37833783
if (!mddev->suspended)
37843784
md_wakeup_thread(mddev->sync_thread);
37853785
}
@@ -3858,6 +3858,7 @@ static void raid_postsuspend(struct dm_target *ti)
38583858
*/
38593859
md_stop_writes(&rs->md);
38603860
mddev_suspend(&rs->md, false);
3861+
rs->md.ro = MD_RDONLY;
38613862
}
38623863
}
38633864

@@ -3968,7 +3969,7 @@ static void rs_update_sbs(struct raid_set *rs)
39683969
int ro = mddev->ro;
39693970

39703971
set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
3971-
mddev->ro = 0;
3972+
mddev->ro = MD_RDWR;
39723973
md_update_sb(mddev, 1);
39733974
mddev->ro = ro;
39743975
}
@@ -4125,7 +4126,7 @@ static void raid_resume(struct dm_target *ti)
41254126
WARN_ON_ONCE(rcu_dereference_protected(mddev->sync_thread,
41264127
lockdep_is_held(&mddev->reconfig_mutex)));
41274128
clear_bit(RT_FLAG_RS_FROZEN, &rs->runtime_flags);
4128-
mddev->ro = 0;
4129+
mddev->ro = MD_RDWR;
41294130
mddev->in_sync = 0;
41304131
md_unfrozen_sync_thread(mddev);
41314132
mddev_unlock_and_resume(mddev);

0 commit comments

Comments
 (0)