Message ID | 20240603125815.2199072-3-yukuai3@huawei.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | md: refacotor and some fixes related to sync_thread | expand |
Context | Check | Description |
---|---|---|
mdraidci/vmtest-md-6_11-VM_Test-8 | pending | Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17 and -O2 optimization |
mdraidci/vmtest-md-6_11-VM_Test-9 | pending | Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18 |
mdraidci/vmtest-md-6_11-VM_Test-10 | pending | Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18 and -O2 optimization |
mdraidci/vmtest-md-6_11-VM_Test-2 | success | Logs for Unittests |
mdraidci/vmtest-md-6_11-VM_Test-1 | success | Logs for ShellCheck |
mdraidci/vmtest-md-6_11-VM_Test-3 | success | Logs for Validate matrix.py |
mdraidci/vmtest-md-6_11-VM_Test-6 | success | Logs for x86_64-gcc / build-release |
mdraidci/vmtest-md-6_11-VM_Test-4 | success | Logs for set-matrix |
mdraidci/vmtest-md-6_11-VM_Test-5 | pending | Logs for x86_64-gcc / build / build for x86_64 with gcc |
mdraidci/vmtest-md-6_11-VM_Test-7 | pending | Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17 |
mdraidci/vmtest-md-6_11-PR | success | PR summary |
mdraidci/vmtest-md-6_11-VM_Test-0 | success | Logs for build-kernel |
On Mon, 3 Jun 2024 20:58:05 +0800 Yu Kuai <yukuai3@huawei.com> wrote: > 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 <yukuai3@huawei.com> > --- > drivers/md/md.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 56 insertions(+), 1 deletion(-) > > diff --git a/drivers/md/md.h b/drivers/md/md.h > index 170412a65b63..6b9d9246f260 100644 > --- a/drivers/md/md.h > +++ b/drivers/md/md.h > @@ -34,6 +34,61 @@ > */ > #define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT) > > +/* Status of sync thread. */ > +enum sync_action { > + /* > + * Represent by MD_RECOVERY_SYNC, start when: > + * 1) after assemble, sync data from first rdev to other copies, this > + * must be done first before other sync actions and will only execute > + * once; > + * 2) resize the array(notice that this is not reshape), sync data > for > + * the new range; > + */ > + ACTION_RESYNC, > + /* > + * Represent by MD_RECOVERY_RECOVER, start when: > + * 1) for new replacement, sync data based on the replace rdev or > + * available copies from other rdev; > + * 2) for new member disk while the array is degraded, sync data from > + * other rdev; > + * 3) reassemble after power failure or re-add a hot removed rdev, > sync > + * data from first rdev to other copies based on bitmap; > + */ > + ACTION_RECOVER, > + /* > + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED | > + * MD_RECOVERY_CHECK, start when user echo "check" to sysfs api > + * sync_action, used to check if data copies from differenct rdev are > + * the same. The number of mismatch sectors will be exported to user > + * by sysfs api mismatch_cnt; > + */ > + ACTION_CHECK, > + /* > + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when > + * user echo "repair" to sysfs api sync_action, usually paired with > + * ACTION_CHECK, used to force syncing data once user found that > there > + * are inconsistent data, > + */ > + ACTION_REPAIR, > + /* > + * Represent by MD_RECOVERY_RESHAPE, start when new member disk is > added > + * to the conf, notice that this is different from spares or > + * replacement; > + */ > + ACTION_RESHAPE, > + /* > + * Represent by MD_RECOVERY_FROZEN, can be set by sysfs api > sync_action > + * or internal usage like setting the array read-only, will forbid > above > + * actions. > + */ > + ACTION_FROZEN, > + /* > + * All above actions don't match. > + */ > + ACTION_IDLE, > + NR_SYNC_ACTIONS, > +}; I like if counter is keep in same style as rest enum values, like ACTION_COUNT. Anyway LGTM. Mariusz
Hi, 在 2024/06/11 16:31, Mariusz Tkaczyk 写道: > On Mon, 3 Jun 2024 20:58:05 +0800 > Yu Kuai <yukuai3@huawei.com> wrote: > >> 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 <yukuai3@huawei.com> >> --- >> drivers/md/md.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 56 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/md/md.h b/drivers/md/md.h >> index 170412a65b63..6b9d9246f260 100644 >> --- a/drivers/md/md.h >> +++ b/drivers/md/md.h >> @@ -34,6 +34,61 @@ >> */ >> #define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT) >> >> +/* Status of sync thread. */ >> +enum sync_action { >> + /* >> + * Represent by MD_RECOVERY_SYNC, start when: >> + * 1) after assemble, sync data from first rdev to other copies, this >> + * must be done first before other sync actions and will only execute >> + * once; >> + * 2) resize the array(notice that this is not reshape), sync data >> for >> + * the new range; >> + */ >> + ACTION_RESYNC, >> + /* >> + * Represent by MD_RECOVERY_RECOVER, start when: >> + * 1) for new replacement, sync data based on the replace rdev or >> + * available copies from other rdev; >> + * 2) for new member disk while the array is degraded, sync data from >> + * other rdev; >> + * 3) reassemble after power failure or re-add a hot removed rdev, >> sync >> + * data from first rdev to other copies based on bitmap; >> + */ >> + ACTION_RECOVER, >> + /* >> + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED | >> + * MD_RECOVERY_CHECK, start when user echo "check" to sysfs api >> + * sync_action, used to check if data copies from differenct rdev are >> + * the same. The number of mismatch sectors will be exported to user >> + * by sysfs api mismatch_cnt; >> + */ >> + ACTION_CHECK, >> + /* >> + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when >> + * user echo "repair" to sysfs api sync_action, usually paired with >> + * ACTION_CHECK, used to force syncing data once user found that >> there >> + * are inconsistent data, >> + */ >> + ACTION_REPAIR, >> + /* >> + * Represent by MD_RECOVERY_RESHAPE, start when new member disk is >> added >> + * to the conf, notice that this is different from spares or >> + * replacement; >> + */ >> + ACTION_RESHAPE, >> + /* >> + * Represent by MD_RECOVERY_FROZEN, can be set by sysfs api >> sync_action >> + * or internal usage like setting the array read-only, will forbid >> above >> + * actions. >> + */ >> + ACTION_FROZEN, >> + /* >> + * All above actions don't match. >> + */ >> + ACTION_IDLE, >> + NR_SYNC_ACTIONS, >> +}; > > I like if counter is keep in same style as rest enum values, like ACTION_COUNT. Thanks for the review, however, I didn't find this style "xxx_COUNT" in md code, AFAIK, "NR_xxx" style is used more, for example: enum stat_group { STAT_READ, STAT_WRITE, STAT_DISCARD, STAT_FLUSH, NR_STAT_GROUPS }; Just to let you know, I'll keep this style in the next version. :) Thanks, Kuai > > Anyway LGTM. > > Mariusz > . >
diff --git a/drivers/md/md.h b/drivers/md/md.h index 170412a65b63..6b9d9246f260 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -34,6 +34,61 @@ */ #define MD_FAILFAST (REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT) +/* Status of sync thread. */ +enum sync_action { + /* + * Represent by MD_RECOVERY_SYNC, start when: + * 1) after assemble, sync data from first rdev to other copies, this + * must be done first before other sync actions and will only execute + * once; + * 2) resize the array(notice that this is not reshape), sync data for + * the new range; + */ + ACTION_RESYNC, + /* + * Represent by MD_RECOVERY_RECOVER, start when: + * 1) for new replacement, sync data based on the replace rdev or + * available copies from other rdev; + * 2) for new member disk while the array is degraded, sync data from + * other rdev; + * 3) reassemble after power failure or re-add a hot removed rdev, sync + * data from first rdev to other copies based on bitmap; + */ + ACTION_RECOVER, + /* + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED | + * MD_RECOVERY_CHECK, start when user echo "check" to sysfs api + * sync_action, used to check if data copies from differenct rdev are + * the same. The number of mismatch sectors will be exported to user + * by sysfs api mismatch_cnt; + */ + ACTION_CHECK, + /* + * Represent by MD_RECOVERY_SYNC | MD_RECOVERY_REQUESTED, start when + * user echo "repair" to sysfs api sync_action, usually paired with + * ACTION_CHECK, used to force syncing data once user found that there + * are inconsistent data, + */ + ACTION_REPAIR, + /* + * Represent by MD_RECOVERY_RESHAPE, start when new member disk is added + * to the conf, notice that this is different from spares or + * replacement; + */ + ACTION_RESHAPE, + /* + * Represent by MD_RECOVERY_FROZEN, can be set by sysfs api sync_action + * or internal usage like setting the array read-only, will forbid above + * actions. + */ + ACTION_FROZEN, + /* + * All above actions don't match. + */ + ACTION_IDLE, + NR_SYNC_ACTIONS, +}; + /* * The struct embedded in rdev is used to serialize IO. */ @@ -571,7 +626,7 @@ enum recovery_flags { /* interrupted because io-error */ MD_RECOVERY_ERROR, - /* flags determines sync action */ + /* flags determines sync action, see details in enum sync_action */ /* if just this flag is set, action is resync. */ MD_RECOVERY_SYNC,
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 <yukuai3@huawei.com> --- drivers/md/md.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)