Skip to content
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

DAOS-13151 client: cache and reuse the attach info for the default system #14318

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/client/api/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ 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 d_fault_attr_t d_fault_mem_saved;
int rc;

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

/** get and cache attach info of default system */
rc = dc_mgmt_cache_attach_info(NULL);
if (rc != 0)
D_GOTO(out_job, rc);

/**
* 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_attach, 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_attach, rc);
}

/**
Expand Down Expand Up @@ -256,6 +261,8 @@ daos_init(void)
pl_fini();
out_eq:
daos_eq_lib_fini();
out_attach:
dc_mgmt_drop_attach_info();
out_job:
dc_job_fini();
out_agent:
Expand Down Expand Up @@ -313,6 +320,7 @@ daos_fini(void)
DF_RC"\n", DP_RC(rc));

dc_tm_fini();
dc_mgmt_drop_attach_info();
dc_agent_fini();
dc_job_fini();

Expand Down
10 changes: 4 additions & 6 deletions src/control/cmd/daos/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"

"github.com/daos-stack/daos/src/control/build"
"github.com/daos-stack/daos/src/control/cmd/dmg/pretty"
"github.com/daos-stack/daos/src/control/common"
"github.com/daos-stack/daos/src/control/common/proto/convert"
Expand Down Expand Up @@ -94,12 +93,11 @@ func (cmd *poolBaseCmd) PoolID() ui.LabelOrUUIDFlag {

func (cmd *poolBaseCmd) connectPool(flags C.uint) error {
sysName := cmd.SysName
if sysName == "" {
sysName = build.DefaultSystemName
var cSysName *C.char
if sysName != "" {
cSysName := C.CString(sysName)
defer freeString(cSysName)
}
cSysName := C.CString(sysName)
defer freeString(cSysName)

var rc C.int
switch {
case cmd.PoolID().HasLabel():
Expand Down
5 changes: 1 addition & 4 deletions src/control/cmd/daos/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"

"github.com/daos-stack/daos/src/control/build"
"github.com/daos-stack/daos/src/control/common/cmdutil"
"github.com/daos-stack/daos/src/control/lib/daos"
"github.com/daos-stack/daos/src/control/logging"
Expand All @@ -42,6 +41,7 @@ init_op_vals(struct cmd_args_s *ap)
ap->o_op = -1;
ap->fs_op = -1;
ap->sh_op = -1;
ap->sysname = NULL;
}

void
Expand Down Expand Up @@ -184,8 +184,6 @@ func freeCmdArgs(ap *C.struct_cmd_args_s) {
return
}

freeString(ap.sysname)

C.free(unsafe.Pointer(ap.dfs_path))
C.free(unsafe.Pointer(ap.dfs_prefix))

Expand Down Expand Up @@ -213,7 +211,6 @@ func allocCmdArgs(log logging.Logger) (ap *C.struct_cmd_args_s, cleanFn func(),
// allocate the struct using C memory to avoid any issues with Go GC
ap = (*C.struct_cmd_args_s)(C.calloc(1, C.sizeof_struct_cmd_args_s))
C.init_op_vals(ap)
ap.sysname = C.CString(build.DefaultSystemName)

ctx, cancel := context.WithCancel(context.Background())
outStream, outCleanup, err := createWriteStream(ctx, log.Info)
Expand Down
12 changes: 6 additions & 6 deletions src/engine/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static char modules[MAX_MODULE_OPTIONS + 1];
static unsigned int nr_threads;

/** DAOS system name (corresponds to crt group ID) */
static char *daos_sysname = DAOS_DEFAULT_SYS_NAME;
char *daos_sysname = DAOS_DEFAULT_SYS_NAME;

/** Storage node hostname */
char dss_hostname[DSS_HOSTNAME_MAX_LEN];
Expand Down Expand Up @@ -1030,16 +1030,16 @@ parse(int argc, char **argv)
case 'f':
rc = arg_strtoul(optarg, &dss_core_offset, "\"-f\"");
break;
case 'g':
if (strnlen(optarg, DAOS_SYS_NAME_MAX + 1) >
DAOS_SYS_NAME_MAX) {
printf("DAOS system name must be at most "
"%d bytes\n", DAOS_SYS_NAME_MAX);
case 'g': {
if (strnlen(optarg, DAOS_SYS_NAME_MAX + 1) > DAOS_SYS_NAME_MAX) {
printf("DAOS system name must be at most %d bytes\n",
DAOS_SYS_NAME_MAX);
rc = -DER_INVAL;
break;
}
daos_sysname = optarg;
break;
}
case 's':
dss_storage_path = optarg;
break;
Expand Down
27 changes: 14 additions & 13 deletions src/include/daos/mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,20 @@ int dc_mgmt_pool_find(struct dc_mgmt_sys *sys, const char *label,
int dc_mgmt_notify_pool_connect(struct dc_pool *pool);
int dc_mgmt_notify_pool_disconnect(struct dc_pool *pool);
int dc_mgmt_notify_exit(void);
int dc_mgmt_net_get_num_srv_ranks(void);

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);

void
dc_mgmt_put_sys_info(struct daos_sys_info *info);
int
dc_mgmt_tm_register(const char *sys, const char *jobid, key_t shm_key, uid_t *owner_uid);

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);

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_tm_register(const char *sys, const char *jobid, key_t shm_key, uid_t *owner_uid);
#endif
3 changes: 3 additions & 0 deletions src/include/daos_srv/daos_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
/* Standard max length of addresses e.g. URI, PCI */
#define ADDR_STR_MAX_LEN 128

/** DAOS system name (corresponds to crt group ID) */
extern char *daos_sysname;

/** number of target (XS set) per engine */
extern unsigned int dss_tgt_nr;

Expand Down
2 changes: 1 addition & 1 deletion src/mgmt/cli_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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, &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
Loading
Loading