Merge pull request #14609 from idryzhov/cfg-apply-remove-batches

mgmtd, lib: remove batch ids from cfg apply reply
This commit is contained in:
Christian Hopps 2023-10-25 13:43:44 -04:00 committed by GitHub
commit a709218b53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 64 deletions

View file

@ -112,9 +112,8 @@ message BeCfgDataApplyReq {
message BeCfgDataApplyReply { message BeCfgDataApplyReply {
required uint64 txn_id = 1; required uint64 txn_id = 1;
repeated uint64 batch_ids = 2; required bool success = 2;
required bool success = 3; optional string error_if_any = 3;
optional string error_if_any = 4;
} }
message BeOperDataGetReq { message BeOperDataGetReq {

View file

@ -610,8 +610,7 @@ failed:
} }
static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx, static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
uint64_t txn_id, uint64_t batch_ids[], uint64_t txn_id, bool success,
size_t num_batch_ids, bool success,
const char *error_if_any) const char *error_if_any)
{ {
Mgmtd__BeMessage be_msg; Mgmtd__BeMessage be_msg;
@ -620,8 +619,6 @@ static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
mgmtd__be_cfg_data_apply_reply__init(&apply_reply); mgmtd__be_cfg_data_apply_reply__init(&apply_reply);
apply_reply.success = success; apply_reply.success = success;
apply_reply.txn_id = txn_id; apply_reply.txn_id = txn_id;
apply_reply.batch_ids = (uint64_t *)batch_ids;
apply_reply.n_batch_ids = num_batch_ids;
if (error_if_any) if (error_if_any)
apply_reply.error_if_any = (char *)error_if_any; apply_reply.error_if_any = (char *)error_if_any;
@ -630,12 +627,7 @@ static int mgmt_be_send_apply_reply(struct mgmt_be_client *client_ctx,
be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY; be_msg.message_case = MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY;
be_msg.cfg_apply_reply = &apply_reply; be_msg.cfg_apply_reply = &apply_reply;
MGMTD_BE_CLIENT_DBG( MGMTD_BE_CLIENT_DBG("Sending CFG_APPLY_REPLY txn-id %" PRIu64, txn_id);
"Sending CFG_APPLY_REPLY txn-id %" PRIu64
" %zu batch ids %" PRIu64 " - %" PRIu64,
txn_id, num_batch_ids,
success && num_batch_ids ? batch_ids[0] : 0,
success && num_batch_ids ? batch_ids[num_batch_ids - 1] : 0);
return mgmt_be_client_send_msg(client_ctx, &be_msg); return mgmt_be_client_send_msg(client_ctx, &be_msg);
} }
@ -648,14 +640,11 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
unsigned long apply_nb_cfg_tm; unsigned long apply_nb_cfg_tm;
struct mgmt_be_batch_ctx *batch; struct mgmt_be_batch_ctx *batch;
char err_buf[BUFSIZ]; char err_buf[BUFSIZ];
size_t num_processed;
static uint64_t batch_ids[MGMTD_BE_MAX_BATCH_IDS_IN_REQ];
assert(txn && txn->client); assert(txn && txn->client);
client_ctx = txn->client; client_ctx = txn->client;
assert(txn->nb_txn); assert(txn->nb_txn);
num_processed = 0;
/* /*
* Now apply all the batches we have applied in one go. * Now apply all the batches we have applied in one go.
@ -673,9 +662,6 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
client_ctx->num_apply_nb_cfg++; client_ctx->num_apply_nb_cfg++;
txn->nb_txn = NULL; txn->nb_txn = NULL;
/*
* Send back CFG_APPLY_REPLY for all batches applied.
*/
FOREACH_BE_APPLY_BATCH_IN_LIST (txn, batch) { FOREACH_BE_APPLY_BATCH_IN_LIST (txn, batch) {
/* /*
* No need to delete the batch yet. Will be deleted during * No need to delete the batch yet. Will be deleted during
@ -684,19 +670,9 @@ static int mgmt_be_txn_proc_cfgapply(struct mgmt_be_txn_ctx *txn)
SET_FLAG(batch->flags, MGMTD_BE_TXN_FLAGS_CFG_APPLIED); SET_FLAG(batch->flags, MGMTD_BE_TXN_FLAGS_CFG_APPLIED);
mgmt_be_batches_del(&txn->apply_cfgs, batch); mgmt_be_batches_del(&txn->apply_cfgs, batch);
mgmt_be_batches_add_tail(&txn->cfg_batches, batch); mgmt_be_batches_add_tail(&txn->cfg_batches, batch);
batch_ids[num_processed] = batch->batch_id;
num_processed++;
if (num_processed == MGMTD_BE_MAX_BATCH_IDS_IN_REQ) {
mgmt_be_send_apply_reply(client_ctx, txn->txn_id,
batch_ids, num_processed,
true, NULL);
num_processed = 0;
}
} }
mgmt_be_send_apply_reply(client_ctx, txn->txn_id, batch_ids, mgmt_be_send_apply_reply(client_ctx, txn->txn_id, true, NULL);
num_processed, true, NULL);
MGMTD_BE_CLIENT_DBG("Nb-apply-duration %lu (avg: %lu) uSec", MGMTD_BE_CLIENT_DBG("Nb-apply-duration %lu (avg: %lu) uSec",
apply_nb_cfg_tm, client_ctx->avg_apply_nb_cfg_tm); apply_nb_cfg_tm, client_ctx->avg_apply_nb_cfg_tm);

View file

@ -469,14 +469,10 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY: case MGMTD__BE_MESSAGE__MESSAGE_CFG_APPLY_REPLY:
MGMTD_BE_ADAPTER_DBG( MGMTD_BE_ADAPTER_DBG(
"Got %s CFG_APPLY_REPLY from '%s' txn-id %" PRIx64 "Got %s CFG_APPLY_REPLY from '%s' txn-id %" PRIx64
" for %zu batches id %" PRIu64 "-%" PRIu64 " err:'%s'", " err:'%s'",
be_msg->cfg_apply_reply->success ? "successful" be_msg->cfg_apply_reply->success ? "successful"
: "failed", : "failed",
adapter->name, be_msg->cfg_apply_reply->txn_id, adapter->name, be_msg->cfg_apply_reply->txn_id,
be_msg->cfg_apply_reply->n_batch_ids,
be_msg->cfg_apply_reply->batch_ids[0],
be_msg->cfg_apply_reply->batch_ids
[be_msg->cfg_apply_reply->n_batch_ids - 1],
be_msg->cfg_apply_reply->error_if_any be_msg->cfg_apply_reply->error_if_any
? be_msg->cfg_apply_reply->error_if_any ? be_msg->cfg_apply_reply->error_if_any
: "None"); : "None");
@ -486,8 +482,6 @@ mgmt_be_adapter_handle_msg(struct mgmt_be_client_adapter *adapter,
mgmt_txn_notify_be_cfg_apply_reply( mgmt_txn_notify_be_cfg_apply_reply(
be_msg->cfg_apply_reply->txn_id, be_msg->cfg_apply_reply->txn_id,
be_msg->cfg_apply_reply->success, be_msg->cfg_apply_reply->success,
(uint64_t *)be_msg->cfg_apply_reply->batch_ids,
be_msg->cfg_apply_reply->n_batch_ids,
be_msg->cfg_apply_reply->error_if_any, adapter); be_msg->cfg_apply_reply->error_if_any, adapter);
break; break;
case MGMTD__BE_MESSAGE__MESSAGE_GET_REPLY: case MGMTD__BE_MESSAGE__MESSAGE_GET_REPLY:

View file

@ -2471,14 +2471,11 @@ int mgmt_txn_notify_be_cfgdata_reply(uint64_t txn_id, uint64_t batch_id,
} }
int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success, int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
uint64_t batch_ids[], char *error_if_any,
size_t num_batch_ids, char *error_if_any,
struct mgmt_be_client_adapter *adapter) struct mgmt_be_client_adapter *adapter)
{ {
struct mgmt_txn_ctx *txn; struct mgmt_txn_ctx *txn;
struct mgmt_txn_be_cfg_batch *batch;
struct mgmt_commit_cfg_req *cmtcfg_req = NULL; struct mgmt_commit_cfg_req *cmtcfg_req = NULL;
size_t indx;
txn = mgmt_txn_id2ctx(txn_id); txn = mgmt_txn_id2ctx(txn_id);
if (!txn || txn->type != MGMTD_TXN_TYPE_CONFIG || !txn->commit_cfg_req) if (!txn || txn->type != MGMTD_TXN_TYPE_CONFIG || !txn->commit_cfg_req)
@ -2488,9 +2485,8 @@ int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
if (!success) { if (!success) {
MGMTD_TXN_ERR("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64 MGMTD_TXN_ERR("CFGDATA_APPLY_REQ sent to '%s' failed txn-id: %" PRIu64
" batch ids %" PRIu64 " - %" PRIu64 " err: %s", " err: %s",
adapter->name, txn->txn_id, batch_ids[0], adapter->name, txn->txn_id,
batch_ids[num_batch_ids - 1],
error_if_any ? error_if_any : "None"); error_if_any ? error_if_any : "None");
mgmt_txn_send_commit_cfg_reply( mgmt_txn_send_commit_cfg_reply(
txn, MGMTD_INTERNAL_ERROR, txn, MGMTD_INTERNAL_ERROR,
@ -2500,25 +2496,17 @@ int mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
return 0; return 0;
} }
for (indx = 0; indx < num_batch_ids; indx++) { mgmt_move_txn_cfg_batches(txn, cmtcfg_req,
batch = mgmt_txn_cfgbatch_id2ctx(txn, batch_ids[indx]); &cmtcfg_req->curr_batches[adapter->id],
if (batch->txn != txn) &cmtcfg_req->next_batches[adapter->id],
return -1; true, MGMTD_COMMIT_PHASE_TXN_DELETE);
mgmt_move_txn_cfg_batch_to_next(
cmtcfg_req, batch,
&cmtcfg_req->curr_batches[adapter->id],
&cmtcfg_req->next_batches[adapter->id], true,
MGMTD_COMMIT_PHASE_TXN_DELETE);
}
if (!mgmt_txn_batches_count(&cmtcfg_req->curr_batches[adapter->id])) { /*
/* * All configuration for the specific backend has been applied.
* All configuration for the specific backend has been applied. * Send TXN-DELETE to wrap up the transaction for this backend.
* Send TXN-DELETE to wrap up the transaction for this backend. */
*/ SET_FLAG(adapter->flags, MGMTD_BE_ADAPTER_FLAGS_CFG_SYNCED);
SET_FLAG(adapter->flags, MGMTD_BE_ADAPTER_FLAGS_CFG_SYNCED); mgmt_txn_send_be_txn_delete(txn, adapter);
mgmt_txn_send_be_txn_delete(txn, adapter);
}
mgmt_try_move_commit_to_next_phase(txn, cmtcfg_req); mgmt_try_move_commit_to_next_phase(txn, cmtcfg_req);
if (mm->perf_stats_en) if (mm->perf_stats_en)

View file

@ -223,8 +223,7 @@ extern int mgmt_txn_notify_be_cfg_validate_reply(
*/ */
extern int extern int
mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success, mgmt_txn_notify_be_cfg_apply_reply(uint64_t txn_id, bool success,
uint64_t batch_ids[], char *error_if_any,
size_t num_batch_ids, char *error_if_any,
struct mgmt_be_client_adapter *adapter); struct mgmt_be_client_adapter *adapter);
/* /*