Skip to content

Commit a85aa09

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: add a new enum type sync_action
In order to make code related to sync_thread cleaner in following patches, also add detail comment about each sync action. And also prepare to remove the related recovery_flags in the fulture. Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0476d09 commit a85aa09

File tree

1 file changed

+56
-1
lines changed

1 file changed

+56
-1
lines changed

drivers/md/md.h

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,61 @@
3434
*/
3535
#define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT)
3636

37+
/* Status of sync thread. */
38+
enum sync_action {
39+
/*
40+
* Represent by MD_RECOVERY_SYNC, start when:
41+
* 1) after assemble, sync data from first rdev to other copies, this
42+
* must be done first before other sync actions and will only execute
43+
* once;
44+
* 2) resize the array(notice that this is not reshape), sync data for
45+
* the new range;
46+
*/
47+
ACTION_RESYNC,
48+
/*
49+
* Represent by MD_RECOVERY_RECOVER, start when:
50+
* 1) for new replacement, sync data based on the replace rdev or
51+
* available copies from other rdev;
52+
* 2) for new member disk while the array is degraded, sync data from
53+
* other rdev;
54+
* 3) reassemble after power failure or re-add a hot removed rdev, sync
55+
* data from first rdev to other copies based on bitmap;
56+
*/
57+
ACTION_RECOVER,
58+
/*
59+
* Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED |
60+
* MD_RECOVERY_CHECK, start when user echo "check" to sysfs api
61+
* sync_action, used to check if data copies from differenct rdev are
62+
* the same. The number of mismatch sectors will be exported to user
63+
* by sysfs api mismatch_cnt;
64+
*/
65+
ACTION_CHECK,
66+
/*
67+
* Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when
68+
* user echo "repair" to sysfs api sync_action, usually paired with
69+
* ACTION_CHECK, used to force syncing data once user found that there
70+
* are inconsistent data,
71+
*/
72+
ACTION_REPAIR,
73+
/*
74+
* Represent by MD_RECOVERY_RESHAPE, start when new member disk is added
75+
* to the conf, notice that this is different from spares or
76+
* replacement;
77+
*/
78+
ACTION_RESHAPE,
79+
/*
80+
* Represent by MD_RECOVERY_FROZEN, can be set by sysfs api sync_action
81+
* or internal usage like setting the array read-only, will forbid above
82+
* actions.
83+
*/
84+
ACTION_FROZEN,
85+
/*
86+
* All above actions don't match.
87+
*/
88+
ACTION_IDLE,
89+
NR_SYNC_ACTIONS,
90+
};
91+
3792
/*
3893
* The struct embedded in rdev is used to serialize IO.
3994
*/
@@ -571,7 +626,7 @@ enum recovery_flags {
571626
/* interrupted because io-error */
572627
MD_RECOVERY_ERROR,
573628

574-
/* flags determines sync action */
629+
/* flags determines sync action, see details in enum sync_action */
575630

576631
/* if just this flag is set, action is resync. */
577632
MD_RECOVERY_SYNC,

0 commit comments

Comments
 (0)