Skip to content

Commit

Permalink
DAOS-13151 client: cache the attach info for the default system
Browse files Browse the repository at this point in the history
improve the daos_init() process to reuse the attach info instead of
doing agent drpc upcalls multiple times.

Required-githooks: true

Signed-off-by: Mohamad Chaarawi <[email protected]>
  • Loading branch information
mchaarawi committed Apr 16, 2024
1 parent c555ef0 commit 4de19db
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 72 deletions.
21 changes: 18 additions & 3 deletions src/client/api/init.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2016-2023 Intel Corporation.
* (C) Copyright 2016-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -147,6 +147,8 @@ daos_init(void)
struct d_fault_attr_t *d_fault_init;
struct d_fault_attr_t *d_fault_mem = NULL;
struct d_fault_attr_t d_fault_mem_saved;
struct dc_mgmt_sys_info *info;
Mgmt__GetAttachInfoResp *resp;
int rc;

D_MUTEX_LOCK(&module_lock);
Expand Down Expand Up @@ -195,19 +197,29 @@ daos_init(void)
if (rc != 0)
D_GOTO(out_agent, rc);

D_ALLOC_PTR(info);
if (info == NULL)
D_GOTO(out_job, rc);
rc = dc_get_attach_info(NULL, true, info, &resp);
if (rc != 0) {
D_FREE(info);
D_GOTO(out_job, rc);
}
dc_set_global_attach_info(info, resp);

/**
* get CaRT configuration (see mgmtModule.handleGetAttachInfo for the
* handling of NULL system names)
*/
rc = dc_mgmt_net_cfg(NULL);
if (rc != 0)
D_GOTO(out_job, rc);
D_GOTO(out_info, rc);

/** set up event queue */
rc = daos_eq_lib_init();
if (rc != 0) {
D_ERROR("failed to initialize eq_lib: "DF_RC"\n", DP_RC(rc));
D_GOTO(out_job, rc);
D_GOTO(out_info, rc);
}

/**
Expand Down Expand Up @@ -265,6 +277,9 @@ daos_init(void)
pl_fini();
out_eq:
daos_eq_lib_fini();
out_info:
dc_put_attach_info(info, resp);
D_FREE(info);
out_job:
dc_job_fini();
out_agent:
Expand Down
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, &sys);
rc = dc_mgmt_sys_attach(NULL, true, &sys);
if (rc != 0) {
D_ERROR("failed to attach to grp rc "DF_RC"\n", DP_RC(rc));
return rc;
Expand Down
16 changes: 9 additions & 7 deletions src/include/daos/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ struct dc_mgmt_sys {
struct dc_mgmt_sys_info sy_info;
};

int dc_mgmt_sys_attach(const char *name, struct dc_mgmt_sys **sysp);
int
dc_mgmt_sys_attach(const char *name, bool use_global_info, 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 @@ -72,11 +73,12 @@ int dc_mgmt_net_get_num_srv_ranks(void);
int dc_mgmt_get_sys_info(const char *sys, struct daos_sys_info **info);
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_get_attach_info(const char *name, bool all_ranks, struct dc_mgmt_sys_info *info,
Mgmt__GetAttachInfoResp **respp);
void
dc_set_global_attach_info(struct dc_mgmt_sys_info *info, Mgmt__GetAttachInfoResp *resp);
void
dc_put_attach_info(struct dc_mgmt_sys_info *info, Mgmt__GetAttachInfoResp *resp);

#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, &cp_arg.sys);
rc = dc_mgmt_sys_attach(args->grp, true, &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, &sys);
rc = dc_mgmt_sys_attach(NULL, true, &sys);
if (rc != 0) {
D_ERROR("failed to attach to grp rc "DF_RC"\n", DP_RC(rc));
return -DER_INVAL;
Expand Down
Loading

0 comments on commit 4de19db

Please sign in to comment.