Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <heinzm@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Heinz Mauelshagen and committed by
Mikulas Patocka
55dcfdf8 1cd83fb7

+7 -6
+7 -6
drivers/md/dm-raid.c
··· 3247 3247 rs_reset_inconclusive_reshape(rs); 3248 3248 3249 3249 /* Start raid set read-only and assumed clean to change in raid_resume() */ 3250 - rs->md.ro = 1; 3250 + rs->md.ro = MD_RDONLY; 3251 3251 rs->md.in_sync = 1; 3252 3252 3253 3253 /* Has to be held on running the array */ ··· 3385 3385 /* The MD sync thread can be done with io or be interrupted but still be running */ 3386 3386 if (!test_bit(MD_RECOVERY_DONE, &recovery) && 3387 3387 (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)))) { 3389 3389 if (test_bit(MD_RECOVERY_RESHAPE, &recovery)) 3390 3390 return st_reshape; 3391 3391 ··· 3775 3775 } else 3776 3776 return -EINVAL; 3777 3777 } 3778 - if (mddev->ro == 2) { 3778 + if (mddev->ro == MD_AUTO_READ) { 3779 3779 /* A write to sync_action is enough to justify 3780 3780 * canceling read-auto mode 3781 3781 */ 3782 - mddev->ro = 0; 3782 + mddev->ro = MD_RDWR; 3783 3783 if (!mddev->suspended) 3784 3784 md_wakeup_thread(mddev->sync_thread); 3785 3785 } ··· 3858 3858 */ 3859 3859 md_stop_writes(&rs->md); 3860 3860 mddev_suspend(&rs->md, false); 3861 + rs->md.ro = MD_RDONLY; 3861 3862 } 3862 3863 } 3863 3864 ··· 3969 3968 int ro = mddev->ro; 3970 3969 3971 3970 set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); 3972 - mddev->ro = 0; 3971 + mddev->ro = MD_RDWR; 3973 3972 md_update_sb(mddev, 1); 3974 3973 mddev->ro = ro; 3975 3974 } ··· 4126 4125 WARN_ON_ONCE(rcu_dereference_protected(mddev->sync_thread, 4127 4126 lockdep_is_held(&mddev->reconfig_mutex))); 4128 4127 clear_bit(RT_FLAG_RS_FROZEN, &rs->runtime_flags); 4129 - mddev->ro = 0; 4128 + mddev->ro = MD_RDWR; 4130 4129 mddev->in_sync = 0; 4131 4130 md_unfrozen_sync_thread(mddev); 4132 4131 mddev_unlock_and_resume(mddev);