|
34 | 34 | */
|
35 | 35 | #define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT)
|
36 | 36 |
|
| 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 | + |
37 | 92 | /*
|
38 | 93 | * The struct embedded in rdev is used to serialize IO.
|
39 | 94 | */
|
@@ -571,7 +626,7 @@ enum recovery_flags {
|
571 | 626 | /* interrupted because io-error */
|
572 | 627 | MD_RECOVERY_ERROR,
|
573 | 628 |
|
574 |
| - /* flags determines sync action */ |
| 629 | + /* flags determines sync action, see details in enum sync_action */ |
575 | 630 |
|
576 | 631 | /* if just this flag is set, action is resync. */
|
577 | 632 | MD_RECOVERY_SYNC,
|
|
0 commit comments