-
Notifications
You must be signed in to change notification settings - Fork 340
DAOS-18425 rebuild: NAK certain rebuild stop commands #17421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a0a28a
c802f2b
783ac97
d4b5aae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -884,14 +884,62 @@ enum { | |
| }; | ||
|
|
||
| static bool | ||
| rebuild_is_stoppable(struct rebuild_global_pool_tracker *rgt, bool force) | ||
| rebuild_is_stoppable(struct rebuild_global_pool_tracker *rgt, bool force, int *rcp) | ||
| { | ||
| if ((rgt->rgt_opc == RB_OP_REBUILD) || (rgt->rgt_opc == RB_OP_UPGRADE)) | ||
| /* NAK if nothing is rebuilding */ | ||
| if (rgt == NULL) { | ||
| *rcp = -DER_NONEXIST; | ||
| return false; | ||
| } | ||
|
|
||
| /* NAK if another rebuild is queued for the same pool (it would run after this one stopped) | ||
| */ | ||
| if (!d_list_empty(&rebuild_gst.rg_queue_list)) { | ||
| struct rebuild_task *task; | ||
|
|
||
| d_list_for_each_entry(task, &rebuild_gst.rg_queue_list, dst_list) { | ||
| if (uuid_compare(task->dst_pool_uuid, rgt->rgt_pool_uuid) == 0) { | ||
| *rcp = -DER_NO_PERM; | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if ((rgt->rgt_opc == RB_OP_REBUILD) || (rgt->rgt_opc == RB_OP_UPGRADE)) { | ||
| *rcp = 0; | ||
| return true; | ||
| } | ||
|
|
||
| if ((rgt->rgt_opc == RB_OP_FAIL_RECLAIM) && force && (rgt->rgt_num_op_freclaim_fail > 0)) | ||
| /* Defer stop for many Fail_reclaim cases (until after it finishes). Do not return errors. | ||
| * Only allow force-stop of repeating failures in Fail_reclaim | ||
| */ | ||
| if (rgt->rgt_opc == RB_OP_FAIL_RECLAIM && force) { | ||
| if (rgt->rgt_num_op_freclaim_fail == 0) { | ||
| D_INFO(DF_RB | ||
| ": cannot force-stop op:Fail_reclaim with 0 failures - defer stop " | ||
| "until after it finishes\n", | ||
| DP_RB_RGT(rgt)); | ||
| *rcp = 0; | ||
| return false; | ||
| } | ||
| D_INFO(DF_RB ": force-stop in op:Fail_reclaim after %u failures\n", DP_RB_RGT(rgt), | ||
| rgt->rgt_num_op_freclaim_fail); | ||
| *rcp = 0; | ||
| return true; | ||
| } else if (rgt->rgt_opc == RB_OP_FAIL_RECLAIM) { | ||
| D_INFO(DF_RB ": defer stop until after op:Fail_reclaim finishes\n", DP_RB_RGT(rgt)); | ||
| *rcp = 0; | ||
| return false; | ||
| } | ||
|
|
||
| /* NAK if this rebuild is Reclaim (i.e., it's effectively done) */ | ||
| if (rgt->rgt_opc == RB_OP_RECLAIM) { | ||
| *rcp = -DER_BUSY; | ||
| return false; | ||
| } | ||
|
|
||
| /* Not expected */ | ||
| *rcp = -DER_MISC; | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -900,34 +948,35 @@ int | |
| ds_rebuild_admin_stop(struct ds_pool *pool, uint32_t force) | ||
| { | ||
| struct rebuild_global_pool_tracker *rgt; | ||
| int rc = 0; | ||
|
|
||
| /* look up the running rebuild and mark it as aborted (and by the administrator) */ | ||
| rgt = rebuild_global_pool_tracker_lookup(pool->sp_uuid, -1 /* ver */, -1 /* gen */); | ||
| if (rgt == NULL) { | ||
| /* nothing running, make it a no-op */ | ||
| D_INFO(DF_UUID ": received request to stop rebuild - but nothing found to stop\n", | ||
| DP_UUID(pool->sp_uuid)); | ||
| return 0; | ||
| } | ||
|
|
||
| /* admin stop command does not terminate reclaim/fail_reclaim jobs (unless forced) */ | ||
| if (rebuild_is_stoppable(rgt, force)) { | ||
| /* admin stop command only for specific cases (and force option for failing op:Fail_reclaim) | ||
| */ | ||
| if (rebuild_is_stoppable(rgt, force, &rc)) { | ||
| D_INFO(DF_RB ": stopping rebuild force=%u opc %u(%s)\n", DP_RB_RGT(rgt), force, | ||
| rgt->rgt_opc, RB_OP_STR(rgt->rgt_opc)); | ||
| rgt->rgt_abort = 1; | ||
| rgt->rgt_status.rs_errno = -DER_OP_CANCELED; | ||
| } else { | ||
| D_INFO(DF_RB ": NOT stopping rebuild during opc %u(%s)\n", DP_RB_RGT(rgt), | ||
| rgt->rgt_opc, RB_OP_STR(rgt->rgt_opc)); | ||
| if (rgt) { | ||
| D_INFO(DF_RB ": NOT stopping rebuild force=%u opc %u(%s), rc=%d\n", | ||
| DP_RB_RGT(rgt), force, rgt->rgt_opc, RB_OP_STR(rgt->rgt_opc), rc); | ||
| } else { | ||
| DL_INFO(rc, DF_UUID ": nothing found to stop", DP_UUID(pool->sp_uuid)); | ||
| return rc; | ||
| } | ||
| } | ||
|
|
||
| /* admin stop command does not terminate op:Fail_reclaim, but it is remembered to avoid | ||
| * retrying the original op:Rebuild. | ||
| /* admin stop command does not usually terminate op:Fail_reclaim, but it is always | ||
| * remembered to avoid retrying the original op:Rebuild. | ||
| */ | ||
| if (rgt->rgt_abort || (rgt->rgt_opc == RB_OP_FAIL_RECLAIM)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto, rgt possible is NULL?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
| rgt->rgt_stop_admin = 1; | ||
| rgt_put(rgt); | ||
| return 0; | ||
| return rc; | ||
| } | ||
|
|
||
| /* | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some case rgt possible be NULL? won't it trigger segfault then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if
rgt==NULL, thenrebuild_is_stoppable()will return false. So in this branch it will be non-NULL.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Not requesting changes] I had the same questions when reading here and below.
ds_rebuild_admin_stopseems to suffer a bit too much for collecting all rebuild-stoppable logic intorebuild_is_stoppable. Handlingrgt == NULLoutside ofrebuild_is_stopping(e.g., before callingrebuild_is_stopping) might be an alternative worth considering, if the PR needed to be revised for other reasons. Just my naive impression. :)