Skip to content

Commit

Permalink
remove the flag for using cached info from management attach
Browse files Browse the repository at this point in the history
Signed-off-by: Mohamad Chaarawi <[email protected]>
  • Loading branch information
mchaarawi committed Apr 23, 2024
1 parent 1fc1291 commit e5fa214
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/client/api/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ daos_rpc_proto_query(crt_opcode_t base_opc, uint32_t *ver_array, int count, int
int rc;
int i;

rc = dc_mgmt_sys_attach(NULL, true, &sys);
rc = dc_mgmt_sys_attach(NULL, &sys);
if (rc != 0) {
D_ERROR("failed to attach to grp rc "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down
8 changes: 3 additions & 5 deletions src/include/daos/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct dc_mgmt_sys {
struct dc_mgmt_sys_info sy_info;
};

int dc_mgmt_sys_attach(const char *name, bool use_global_info, struct dc_mgmt_sys **sysp);
int dc_mgmt_sys_attach(const char *name, struct dc_mgmt_sys **sysp);
void dc_mgmt_sys_detach(struct dc_mgmt_sys *sys);
ssize_t dc_mgmt_sys_encode(struct dc_mgmt_sys *sys, void *buf, size_t cap);
ssize_t dc_mgmt_sys_decode(void *buf, size_t len, struct dc_mgmt_sys **sysp);
Expand All @@ -74,9 +74,7 @@ void dc_mgmt_put_sys_info(struct daos_sys_info *info);
int dc_get_attach_info(const char *name, bool all_ranks, struct dc_mgmt_sys_info *info,
Mgmt__GetAttachInfoResp **respp);
void dc_put_attach_info(struct dc_mgmt_sys_info *info, Mgmt__GetAttachInfoResp *resp);
int
dc_mgmt_cache_attach_info(const char *name);
void
dc_mgmt_drop_attach_info(void);
int dc_mgmt_cache_attach_info(const char *name);
void dc_mgmt_drop_attach_info(void);
int dc_mgmt_tm_register(const char *sys, const char *jobid, key_t shm_key, uid_t *owner_uid);
#endif
4 changes: 2 additions & 2 deletions src/mgmt/cli_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dc_debug_set_params(tse_task_t *task)
int rc;

args = dc_task_get_args(task);
rc = dc_mgmt_sys_attach(args->grp, true, &cp_arg.sys);
rc = dc_mgmt_sys_attach(args->grp, &cp_arg.sys);
if (rc != 0) {
D_ERROR("failed to attach to grp %s, rc "DF_RC"\n", args->grp,
DP_RC(rc));
Expand Down Expand Up @@ -97,7 +97,7 @@ dc_debug_add_mark(const char *mark)
crt_opcode_t opc;
int rc;

rc = dc_mgmt_sys_attach(NULL, true, &sys);
rc = dc_mgmt_sys_attach(NULL, &sys);
if (rc != 0) {
D_ERROR("failed to attach to grp rc "DF_RC"\n", DP_RC(rc));
return -DER_INVAL;
Expand Down
30 changes: 13 additions & 17 deletions src/mgmt/cli_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ dc_mgmt_profile(char *path, int avg, bool start)
crt_opcode_t opc;
int rc;

rc = dc_mgmt_sys_attach(NULL, false, &sys);
rc = dc_mgmt_sys_attach(NULL, &sys);
if (rc != 0) {
D_ERROR("failed to attach to grp rc "DF_RC"\n", DP_RC(rc));
return -DER_INVAL;
Expand Down Expand Up @@ -839,11 +839,12 @@ detach_group(bool server, crt_group_t *group)
}

static int
attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
attach(const char *name, struct dc_mgmt_sys **sysp)
{
struct dc_mgmt_sys *sys;
crt_group_t *group;
Mgmt__GetAttachInfoResp *resp;
bool need_free_resp = false;
int rc;

D_DEBUG(DB_MGMT, "attaching to system '%s'\n", name);
Expand Down Expand Up @@ -871,7 +872,8 @@ attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
goto out;
}

if (!use_global_resp) {
if (!resp_g) {
need_free_resp = true;
rc = get_attach_info(name, true /* all_ranks */, &sys->sy_info, &resp);
if (rc != 0)
goto err_sys;
Expand All @@ -886,15 +888,15 @@ attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
if (rc != 0)
goto err_info;

if (!use_global_resp)
if (need_free_resp)
free_get_attach_info_resp(resp);
out:
*sysp = sys;
return 0;

err_info:
d_rank_list_free(sys->sy_info.ms_ranks);
if (!use_global_resp)
if (need_free_resp)
free_get_attach_info_resp(resp);
err_sys:
D_FREE(sys);
Expand Down Expand Up @@ -930,7 +932,7 @@ lookup_sys(const char *name)
}

static int
sys_attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
sys_attach(const char *name, struct dc_mgmt_sys **sysp)
{
struct dc_mgmt_sys *sys;
int rc = 0;
Expand All @@ -941,7 +943,7 @@ sys_attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
if (sys != NULL)
goto ok;

rc = attach(name, use_global_resp, &sys);
rc = attach(name, &sys);
if (rc != 0)
goto out_lock;

Expand All @@ -962,17 +964,11 @@ sys_attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
* \param[in,out] sys system handle
*/
int
dc_mgmt_sys_attach(const char *name, bool use_global_resp, struct dc_mgmt_sys **sysp)
dc_mgmt_sys_attach(const char *name, struct dc_mgmt_sys **sysp)
{
if (name == NULL) {
if (name == NULL)
name = agent_sys_name;
} else {
/** use the global attach response if default system */
if (strcmp(name, agent_sys_name) != 0)
use_global_resp = false;
}

return sys_attach(name, use_global_resp, sysp);
return sys_attach(name, sysp);
}

/**
Expand Down Expand Up @@ -1030,7 +1026,7 @@ dc_mgmt_sys_decode(void *buf, size_t len, struct dc_mgmt_sys **sysp)
}
sysb = buf;

return sys_attach(sysb->syb_name, false, sysp);
return sys_attach(sysb->syb_name, sysp);
}

/* For a given pool label or UUID, contact mgmt. service to look up its
Expand Down
2 changes: 1 addition & 1 deletion src/mgmt/cli_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ dc_mgmt_get_bs_state(tse_task_t *task)

args = dc_task_get_args(task);

rc = dc_mgmt_sys_attach(args->grp, true, &cb_args.sys);
rc = dc_mgmt_sys_attach(args->grp, &cb_args.sys);
if (rc != 0) {
D_ERROR("cannot attach to DAOS system: %s\n", args->grp);
D_GOTO(out, rc);
Expand Down
4 changes: 2 additions & 2 deletions src/pool/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ init_pool(const char *label, uuid_t uuid, uint64_t capas, const char *grp,
pool->dp_capas = capas;

/** attach to the server group and initialize rsvc_client */
rc = dc_mgmt_sys_attach(grp, true, &pool->dp_sys);
rc = dc_mgmt_sys_attach(grp, &pool->dp_sys);
if (rc != 0)
D_GOTO(err_pool, rc);

Expand Down Expand Up @@ -1531,7 +1531,7 @@ dc_pool_update_internal(tse_task_t *task, daos_pool_update_t *args, int opc)
D_GOTO(out_tpriv, rc = -DER_NOMEM);
}

rc = dc_mgmt_sys_attach(args->grp, true, &tpriv->state->sys);
rc = dc_mgmt_sys_attach(args->grp, &tpriv->state->sys);
if (rc != 0) {
D_ERROR(DF_UUID": failed to sys attach, rc %d.\n",
DP_UUID(args->uuid), rc);
Expand Down
2 changes: 1 addition & 1 deletion src/pool/srv_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dsc_pool_open(uuid_t pool_uuid, uuid_t poh_uuid, unsigned int flags,
pool->dp_capas = flags;

/** attach to the server group and initialize rsvc_client */
rc = dc_mgmt_sys_attach(daos_sysname, false, &pool->dp_sys);
rc = dc_mgmt_sys_attach(daos_sysname, &pool->dp_sys);
if (rc != 0)
D_GOTO(out, rc);

Expand Down
8 changes: 4 additions & 4 deletions src/rdb/tests/rdbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ multi_tests_common_parse(int argc, char *argv[])

D_ASSERT(g_nreps < g_nranks);

return dc_mgmt_sys_attach(group_id, false, &sys);
return dc_mgmt_sys_attach(group_id, &sys);
}

static void
Expand Down Expand Up @@ -589,7 +589,7 @@ init_hdlr(int argc, char *argv[])
}
}

rc = dc_mgmt_sys_attach(group_id, false, &sys);
rc = dc_mgmt_sys_attach(group_id, &sys);
if (rc != 0)
return rc;

Expand Down Expand Up @@ -720,7 +720,7 @@ test_hdlr(int argc, char *argv[])
}
}

rc = dc_mgmt_sys_attach(group_id, false, &sys);
rc = dc_mgmt_sys_attach(group_id, &sys);
if (rc != 0)
return rc;

Expand Down Expand Up @@ -1483,7 +1483,7 @@ fini_hdlr(int argc, char *argv[])
}
}

rc = dc_mgmt_sys_attach(group_id, false, &sys);
rc = dc_mgmt_sys_attach(group_id, &sys);
if (rc != 0)
return rc;

Expand Down

0 comments on commit e5fa214

Please sign in to comment.