diff --git a/src/bio/smd.pb-c.c b/src/bio/smd.pb-c.c index c89dbef31e5..359a535fe6d 100644 --- a/src/bio/smd.pb-c.c +++ b/src/bio/smd.pb-c.c @@ -1784,7 +1784,7 @@ static const ProtobufCFieldDescriptor ctl__smd_device__field_descriptors[14] = offsetof(Ctl__SmdDevice, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2079,7 +2079,7 @@ static const ProtobufCFieldDescriptor ctl__smd_pool_resp__pool__field_descriptor offsetof(Ctl__SmdPoolResp__Pool, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2091,7 +2091,7 @@ static const ProtobufCFieldDescriptor ctl__smd_pool_resp__pool__field_descriptor offsetof(Ctl__SmdPoolResp__Pool, blobs), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -2284,7 +2284,7 @@ static const ProtobufCFieldDescriptor ctl__smd_query_resp__pool__field_descripto offsetof(Ctl__SmdQueryResp__Pool, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2296,7 +2296,7 @@ static const ProtobufCFieldDescriptor ctl__smd_query_resp__pool__field_descripto offsetof(Ctl__SmdQueryResp__Pool, blobs), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; diff --git a/src/bio/smd.pb-c.h b/src/bio/smd.pb-c.h index 23c2823b6cc..89a7c51aa98 100644 --- a/src/bio/smd.pb-c.h +++ b/src/bio/smd.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1003003 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/src/cart/crt_group.c b/src/cart/crt_group.c index 52e0c6d47cc..513ddee9806 100644 --- a/src/cart/crt_group.c +++ b/src/cart/crt_group.c @@ -1871,8 +1871,6 @@ crt_group_config_path_set(const char *path) int crt_nr_secondary_remote_tags_set(int idx, int num_tags) { - struct crt_prov_gdata *prov_data; - D_DEBUG(DB_ALL, "secondary_idx=%d num_tags=%d\n", idx, num_tags); if (idx != 0) { @@ -1880,19 +1878,12 @@ crt_nr_secondary_remote_tags_set(int idx, int num_tags) return -DER_NONEXIST; } - if ((crt_gdata.cg_prov_gdata_secondary == NULL) || - (idx >= crt_gdata.cg_num_secondary_provs)) { - D_ERROR("Secondary providers not initialized\n"); - return -DER_NONEXIST; - } - if (num_tags <= 0) { D_ERROR("Invalid number of tags: %d\n", num_tags); return -DER_INVAL; } - prov_data = &crt_gdata.cg_prov_gdata_secondary[idx]; - prov_data->cpg_num_remote_tags = num_tags; + crt_gdata.cg_num_remote_tags = num_tags; return DER_SUCCESS; } diff --git a/src/cart/crt_hg_proc.c b/src/cart/crt_hg_proc.c index 839fd45d49d..a66d2314884 100644 --- a/src/cart/crt_hg_proc.c +++ b/src/cart/crt_hg_proc.c @@ -711,6 +711,7 @@ crt_proc_in_common(crt_proc_t proc, crt_rpc_input_t *data) rpc_priv->crp_grp_priv, rpc_priv->crp_pub.cr_ep.ep_rank); hdr->cch_dst_tag = rpc_priv->crp_pub.cr_ep.ep_tag; + hdr->cch_src_is_primary = rpc_priv->crp_src_is_primary; if (rpc_priv->crp_flags & CRT_RPC_FLAG_DEADLINES_USED) { hdr->cch_src_deadline_sec = rpc_priv->crp_deadline_sec; } else { diff --git a/src/cart/crt_init.c b/src/cart/crt_init.c index 1b926465ac3..d3750942b24 100644 --- a/src/cart/crt_init.c +++ b/src/cart/crt_init.c @@ -64,6 +64,10 @@ crt_lib_init(void) crt_gdata.cg_inited = 0; crt_gdata.cg_primary_prov = CRT_PROV_OFI_TCP_RXM; + /* By default set number of secondary remote tags to 1 */ + crt_gdata.cg_num_remote_tags = 1; + crt_gdata.cg_last_remote_tag = 0; + rc = d_gettime(&now); D_ASSERTF(rc == 0, "d_gettime: " DF_RC "\n", DP_RC(rc)); d_srand(now.tv_sec * 1000 * 1000 * 1000 + now.tv_nsec + getpid()); diff --git a/src/cart/crt_internal_types.h b/src/cart/crt_internal_types.h index 02fbe3eea0c..bec3aa94e15 100644 --- a/src/cart/crt_internal_types.h +++ b/src/cart/crt_internal_types.h @@ -160,6 +160,12 @@ struct crt_gdata { ATOMIC uint64_t cg_rpcid; /* rpc id */ + /** Last remote tag sent */ + uint32_t cg_last_remote_tag; + + /** Number of remote tags */ + uint32_t cg_num_remote_tags; + /* protects crt_gdata (see the lock order comment on crp_mutex) */ pthread_rwlock_t cg_rwlock; diff --git a/src/cart/crt_rpc.c b/src/cart/crt_rpc.c index b858964cdbd..49ce3066c2c 100644 --- a/src/cart/crt_rpc.c +++ b/src/cart/crt_rpc.c @@ -1199,7 +1199,6 @@ crt_req_ep_lc_lookup(struct crt_rpc_priv *rpc_priv, bool *uri_exists) char *uri = NULL; int rc = 0; char *base_addr = NULL; - struct crt_prov_gdata *prov_data; int dst_tag; req = &rpc_priv->crp_pub; @@ -1214,13 +1213,12 @@ crt_req_ep_lc_lookup(struct crt_rpc_priv *rpc_priv, bool *uri_exists) /* For a secondary provider round-robin between all available remote contexts */ if (!crt_gdata.cg_provider_is_primary) { - prov_data = &crt_gdata.cg_prov_gdata_secondary[0]; + D_RWLOCK_WRLOCK(&crt_gdata.cg_rwlock); + crt_gdata.cg_last_remote_tag++; + crt_gdata.cg_last_remote_tag %= crt_gdata.cg_num_remote_tags; - D_MUTEX_LOCK(&prov_data->cpg_mutex); - prov_data->cpg_last_remote_tag++; - prov_data->cpg_last_remote_tag %= prov_data->cpg_num_remote_tags; - dst_tag = prov_data->cpg_last_remote_tag; - D_MUTEX_UNLOCK(&prov_data->cpg_mutex); + dst_tag = crt_gdata.cg_last_remote_tag; + D_RWLOCK_UNLOCK(&crt_gdata.cg_rwlock); } crt_grp_lc_lookup(grp_priv, ctx->cc_idx, @@ -1789,6 +1787,10 @@ crt_rpc_common_hdlr(struct crt_rpc_priv *rpc_priv) goto skip_check; } + /* Skip check for secondary provider clients */ + if (!rpc_priv->crp_req_hdr.cch_src_is_primary) + goto skip_check; + if ((self_rank != CRT_NO_RANK && self_rank != rpc_priv->crp_req_hdr.cch_dst_rank) || crt_ctx->cc_idx != rpc_priv->crp_req_hdr.cch_dst_tag) { D_ERROR("Mismatch rpc: %p opc: %x rank:%d tag:%d " @@ -1904,6 +1906,28 @@ crt_req_src_rank_get(crt_rpc_t *rpc, d_rank_t *rank) return rc; } +int +crt_req_src_provider_is_primary(crt_rpc_t *req, bool *result) +{ + struct crt_rpc_priv *rpc_priv = NULL; + int rc = 0; + + if (req == NULL) { + D_ERROR("req is NULL\n"); + D_GOTO(out, rc = -DER_INVAL); + } + + if (result == NULL) { + D_ERROR("result is NULL\n"); + D_GOTO(out, rc = -DER_INVAL); + } + + rpc_priv = container_of(req, struct crt_rpc_priv, crp_pub); + *result = rpc_priv->crp_req_hdr.cch_src_is_primary; +out: + return rc; +} + int crt_req_dst_rank_get(crt_rpc_t *rpc, d_rank_t *rank) { diff --git a/src/cart/crt_rpc.h b/src/cart/crt_rpc.h index 64fffdcc9e4..fe9f6e2db3c 100644 --- a/src/cart/crt_rpc.h +++ b/src/cart/crt_rpc.h @@ -72,8 +72,9 @@ struct crt_common_hdr { /* originator rank in default primary group */ d_rank_t cch_src_rank; /* destination tag */ - uint32_t cch_dst_tag; - + uint16_t cch_dst_tag; + /* indicates whether rpc originator intended to send on a primary ctx */ + uint32_t cch_src_is_primary : 1; /* used in crp_reply_hdr to propagate rpc failure back to sender */ /* TODO: workaround for DAOS-13973 */ diff --git a/src/container/srv_cli.c b/src/container/srv_cli.c index 351c22417cf..95cc90330df 100644 --- a/src/container/srv_cli.c +++ b/src/container/srv_cli.c @@ -1,5 +1,5 @@ /** - * (C) Copyright 2017-2021 Intel Corporation. + * (C) Copyright 2017-2022 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ diff --git a/src/container/srv_container.c b/src/container/srv_container.c index 3efa3211f89..0de2903204b 100644 --- a/src/container/srv_container.c +++ b/src/container/srv_container.c @@ -1516,12 +1516,10 @@ find_hdls_by_cont_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) } static int cont_close_hdls(struct cont_svc *svc, - struct cont_tgt_close_rec *recs, int nrecs, - crt_context_t ctx); + struct cont_tgt_close_rec *recs, int nrecs); static int -evict_hdls(struct rdb_tx *tx, struct cont *cont, bool force, struct ds_pool_hdl *pool_hdl, - crt_context_t ctx) +evict_hdls(struct rdb_tx *tx, struct cont *cont, bool force, struct ds_pool_hdl *pool_hdl) { struct find_hdls_by_cont_arg arg; int rc; @@ -1547,7 +1545,7 @@ evict_hdls(struct rdb_tx *tx, struct cont *cont, bool force, struct ds_pool_hdl goto out; } - rc = cont_close_hdls(cont->c_svc, arg.fha_buf.rb_recs, arg.fha_buf.rb_nrecs, ctx); + rc = cont_close_hdls(cont->c_svc, arg.fha_buf.rb_recs, arg.fha_buf.rb_nrecs); out: recs_buf_fini(&arg.fha_buf); @@ -1605,11 +1603,11 @@ cont_destroy(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont *cont, D_GOTO(out_prop, rc = -DER_NO_PERM); } - rc = evict_hdls(tx, cont, force, NULL /* pool_hdl */, rpc->cr_ctx); + rc = evict_hdls(tx, cont, force, NULL /* pool_hdl */); if (rc != 0) goto out_prop; - rc = cont_destroy_bcast(rpc->cr_ctx, cont->c_svc, cont->c_uuid); + rc = cont_destroy_bcast(dss_get_module_info()->dmi_ctx, cont->c_svc, cont->c_uuid); if (rc != 0) goto out_prop; @@ -2639,7 +2637,7 @@ cont_open(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont *cont, cr if (flags & (DAOS_COO_EVICT | DAOS_COO_EVICT_ALL)) { rc = evict_hdls(tx, cont, true /* force */, - (flags & DAOS_COO_EVICT_ALL) ? NULL : pool_hdl, rpc->cr_ctx); + (flags & DAOS_COO_EVICT_ALL) ? NULL : pool_hdl); if (rc != 0) { daos_prop_free(prop); goto out; @@ -2811,8 +2809,7 @@ cont_open(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont *cont, cr } static int -cont_close_recs(crt_context_t ctx, struct cont_svc *svc, - struct cont_tgt_close_rec recs[], int nrecs) +cont_close_recs(struct cont_svc *svc, struct cont_tgt_close_rec recs[], int nrecs) { int i; int rc = 0; @@ -2852,7 +2849,7 @@ cont_close_recs(crt_context_t ctx, struct cont_svc *svc, static int cont_close_one_hdl(struct rdb_tx *tx, struct d_hash_table *nhc, struct cont_svc *svc, - crt_context_t ctx, const uuid_t uuid) + const uuid_t uuid) { d_iov_t key; d_iov_t value; @@ -2889,8 +2886,7 @@ cont_close_one_hdl(struct rdb_tx *tx, struct d_hash_table *nhc, struct cont_svc /* Close an array of handles, possibly belonging to different containers. */ static int -cont_close_hdls(struct cont_svc *svc, struct cont_tgt_close_rec *recs, - int nrecs, crt_context_t ctx) +cont_close_hdls(struct cont_svc *svc, struct cont_tgt_close_rec *recs, int nrecs) { struct rdb_tx tx; struct d_hash_table txs_nhc; /* TX per-container number of handles cache (HT). */ @@ -2904,7 +2900,7 @@ cont_close_hdls(struct cont_svc *svc, struct cont_tgt_close_rec *recs, " recs[0].hce="DF_U64"\n", DP_CONT(svc->cs_pool_uuid, NULL), nrecs, DP_UUID(recs[0].tcr_hdl), recs[0].tcr_hce); - rc = cont_close_recs(ctx, svc, recs, nrecs); + rc = cont_close_recs(svc, recs, nrecs); if (rc != 0) { D_ERROR(DF_CONT": failed to close %d recs: "DF_RC"\n", DP_CONT(svc->cs_pool_uuid, NULL), nrecs, DP_RC(rc)); @@ -2926,7 +2922,7 @@ cont_close_hdls(struct cont_svc *svc, struct cont_tgt_close_rec *recs, DP_CONT(svc->cs_pool_uuid, NULL), num_tx); for (i = 0; i < nrecs; i++) { - rc = cont_close_one_hdl(&tx, &txs_nhc, svc, ctx, recs[i].tcr_hdl); + rc = cont_close_one_hdl(&tx, &txs_nhc, svc, recs[i].tcr_hdl); if (rc != 0) { D_ERROR(DF_CONT": failed to close handle: "DF_UUID", "DF_RC"\n", DP_CONT(svc->cs_pool_uuid, NULL), DP_UUID(recs[i].tcr_hdl), @@ -3029,11 +3025,11 @@ cont_close(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont *cont, DP_CONT(cont->c_svc->cs_pool_uuid, in->cci_op.ci_uuid), DP_UUID(rec.tcr_hdl), rec.tcr_hce); - rc = cont_close_recs(rpc->cr_ctx, cont->c_svc, &rec, 1 /* nrecs */); + rc = cont_close_recs(cont->c_svc, &rec, 1 /* nrecs */); if (rc != 0) D_GOTO(out, rc); - rc = cont_close_one_hdl(tx, NULL /* nhc */, cont->c_svc, rpc->cr_ctx, rec.tcr_hdl); + rc = cont_close_one_hdl(tx, NULL /* nhc */, cont->c_svc, rec.tcr_hdl); /* On success update modify time (except if open specified read-only metadata stats) */ if (rc == 0 && !(chdl.ch_flags & DAOS_COO_RO_MDSTATS)) @@ -3690,7 +3686,7 @@ cont_query(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont *cont, if (qbits & DAOS_CO_QUERY_TGT) { /* need RF if user query cont_info */ qbits |= (DAOS_CO_QUERY_PROP_REDUN_FAC | DAOS_CO_QUERY_PROP_REDUN_LVL); - rc = cont_query_bcast(rpc->cr_ctx, cont, in->cqi_op.ci_pool_hdl, + rc = cont_query_bcast(dss_get_module_info()->dmi_ctx, cont, in->cqi_op.ci_pool_hdl, in->cqi_op.ci_hdl, out); if (rc) return rc; @@ -4381,8 +4377,7 @@ close_iter_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) * and managed by local container services. */ int -ds_cont_close_by_pool_hdls(uuid_t pool_uuid, uuid_t *pool_hdls, int n_pool_hdls, - crt_context_t ctx) +ds_cont_close_by_pool_hdls(uuid_t pool_uuid, uuid_t *pool_hdls, int n_pool_hdls) { struct cont_svc *svc; struct rdb_tx tx; @@ -4420,7 +4415,7 @@ ds_cont_close_by_pool_hdls(uuid_t pool_uuid, uuid_t *pool_hdls, int n_pool_hdls, if (arg.cia_buf.rb_nrecs > 0) rc = cont_close_hdls(svc, arg.cia_buf.rb_recs, - arg.cia_buf.rb_nrecs, ctx); + arg.cia_buf.rb_nrecs); out_buf: recs_buf_fini(&arg.cia_buf); diff --git a/src/container/srv_epoch.c b/src/container/srv_epoch.c index 5d5e01e4469..5b5442e033c 100644 --- a/src/container/srv_epoch.c +++ b/src/container/srv_epoch.c @@ -310,7 +310,8 @@ ds_cont_snap_create(struct rdb_tx *tx, struct ds_pool_hdl *pool_hdl, struct cont cont_epoch_op_in_get_data(rpc, CONT_SNAP_CREATE, cont_proto_ver, &snap_eph, &opts); - rc = snap_create_bcast(tx, cont, in->cei_op.ci_hdl, opts, rpc->cr_ctx, &snap_eph); + rc = snap_create_bcast(tx, cont, in->cei_op.ci_hdl, opts, dss_get_module_info()->dmi_ctx, + &snap_eph); if (rc == 0) { out->ceo_epoch = snap_eph; *(daos_epoch_t *)op_val->ov_resvd = snap_eph; diff --git a/src/control/cmd/daos_agent/attachinfo.go b/src/control/cmd/daos_agent/attachinfo.go index decd9469df4..71c5ad34e6c 100644 --- a/src/control/cmd/daos_agent/attachinfo.go +++ b/src/control/cmd/daos_agent/attachinfo.go @@ -37,7 +37,7 @@ func (cmd *attachInfoCmd) getAttachInfo(ctx context.Context) (*control.GetAttach type dumpAttachInfoCmd struct { attachInfoCmd Output string `short:"o" long:"output" default:"stdout" description:"Dump output to this location"` - ProviderIdx *uint // TODO SRS-31: Enable with multiprovider functionality: `short:"n" long:"provider_idx" description:"Index of provider to fetch (if multiple)"` + ProviderIdx *uint `short:"n" long:"provider_idx" description:"Index of provider to fetch (if multiple)"` } func (cmd *dumpAttachInfoCmd) Execute(_ []string) error { diff --git a/src/control/cmd/daos_agent/config.go b/src/control/cmd/daos_agent/config.go index 418ffadfefe..3c974d0f344 100644 --- a/src/control/cmd/daos_agent/config.go +++ b/src/control/cmd/daos_agent/config.go @@ -135,7 +135,7 @@ type Config struct { ExcludeFabricIfaces common.StringSet `yaml:"exclude_fabric_ifaces,omitempty"` IncludeFabricIfaces common.StringSet `yaml:"include_fabric_ifaces,omitempty"` FabricInterfaces []*NUMAFabricConfig `yaml:"fabric_ifaces,omitempty"` - ProviderIdx uint // TODO SRS-31: Enable with multiprovider functionality + ProviderIdx uint `yaml:"provider_idx"` Telemetry TelemetryConfig `yaml:",inline"` } diff --git a/src/control/cmd/daos_agent/config_test.go b/src/control/cmd/daos_agent/config_test.go index 69f50152605..b7b6bde173f 100644 --- a/src/control/cmd/daos_agent/config_test.go +++ b/src/control/cmd/daos_agent/config_test.go @@ -78,6 +78,7 @@ fabric_ifaces: - iface: ib3 domain: mlx5_3 +provider_idx: 1 `) badLogMaskCfg := test.CreateTestFile(t, dir, ` @@ -202,6 +203,7 @@ exclude_fabric_ifaces: ["ib3"] }, }, }, + ProviderIdx: 1, }, }, } { diff --git a/src/control/cmd/dmg/auto_test.go b/src/control/cmd/dmg/auto_test.go index bec414701d2..5cdd1c38613 100644 --- a/src/control/cmd/dmg/auto_test.go +++ b/src/control/cmd/dmg/auto_test.go @@ -569,7 +569,7 @@ engines: - "0000:03:00.0" provider: ofi+verbs fabric_iface: ib0 - fabric_iface_port: 31416 + fabric_iface_port: "31416" pinned_numa_node: 0 - targets: 6 nr_xs_helpers: 0 @@ -586,7 +586,7 @@ engines: - "0000:06:00.0" provider: ofi+verbs fabric_iface: ib1 - fabric_iface_port: 32416 + fabric_iface_port: "32416" pinned_numa_node: 1 disable_vfio: false disable_vmd: false diff --git a/src/control/cmd/dmg/pretty/system.go b/src/control/cmd/dmg/pretty/system.go index e859f817ad4..d3d5d654ed1 100644 --- a/src/control/cmd/dmg/pretty/system.go +++ b/src/control/cmd/dmg/pretty/system.go @@ -140,6 +140,7 @@ func PrintSystemQueryResponse(out, outErr io.Writer, resp *control.SystemQueryRe return err } printAbsentHosts(outErr, &resp.AbsentHosts) + printSystemProviders(out, resp.Providers) printSysSelfHealUnsetFlags(out, resp.SysSelfHealPolicy) return nil @@ -149,6 +150,8 @@ func PrintSystemQueryResponse(out, outErr io.Writer, resp *control.SystemQueryRe printAbsentRanks(outErr, &resp.AbsentRanks) printSysSelfHealUnsetFlags(out, resp.SysSelfHealPolicy) + printSystemProviders(out, resp.Providers) + return nil } @@ -186,6 +189,26 @@ func printSystemResults(out, outErr io.Writer, results system.MemberResults, abs return nil } +func printSystemProviders(out io.Writer, providers []string) { + if len(providers) == 0 { + return + } + + idxKey := "Idx" + provKey := "Provider" + formatter := txtfmt.NewTableFormatter(idxKey, provKey) + + var table []txtfmt.TableRow + for i, prov := range providers { + table = append(table, txtfmt.TableRow{ + idxKey: fmt.Sprintf("%d", i), + provKey: prov, + }) + } + + fmt.Fprint(out, formatter.Format(table)) +} + // PrintSystemStartResponse generates a human-readable representation of the // supplied SystemStartResp struct and writes it to the supplied io.Writer. func PrintSystemStartResponse(out, outErr io.Writer, resp *control.SystemStartResp) error { diff --git a/src/control/cmd/dmg/pretty/system_test.go b/src/control/cmd/dmg/pretty/system_test.go index a0cc95853db..ecb17316d2f 100644 --- a/src/control/cmd/dmg/pretty/system_test.go +++ b/src/control/cmd/dmg/pretty/system_test.go @@ -424,6 +424,28 @@ Rank UUID Control Address Fault Domain State Unknown 3 hosts: foo[7-9] Unknown 3 ranks: 7-9 +`, + }, + "providers": { + resp: &control.SystemQueryResp{ + Members: Members{ + MockMember(t, 0, MemberStateJoined), + MockMember(t, 1, MemberStateJoined), + MockMember(t, 2, MemberStateStopped), + }, + Providers: []string{"ofi+verbs", "ofi+tcp", "ofi+tcp"}, + }, + expPrintStr: ` +Rank State +---- ----- +[0-1] Joined +2 Stopped + +Idx Provider +--- -------- +0 ofi+verbs +1 ofi+tcp +2 ofi+tcp `, }, } { diff --git a/src/control/cmd/drpc_test/hello/drpc_test.pb.go b/src/control/cmd/drpc_test/hello/drpc_test.pb.go new file mode 100644 index 00000000000..c993b462f23 --- /dev/null +++ b/src/control/cmd/drpc_test/hello/drpc_test.pb.go @@ -0,0 +1,306 @@ +// +// (C) Copyright 2018-2022 Intel Corporation. +// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.5.0 +// source: drpc_test.proto + +package hello + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Module int32 + +const ( + Module_HELLO Module = 0 +) + +// Enum value maps for Module. +var ( + Module_name = map[int32]string{ + 0: "HELLO", + } + Module_value = map[string]int32{ + "HELLO": 0, + } +) + +func (x Module) Enum() *Module { + p := new(Module) + *p = x + return p +} + +func (x Module) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Module) Descriptor() protoreflect.EnumDescriptor { + return file_drpc_test_proto_enumTypes[0].Descriptor() +} + +func (Module) Type() protoreflect.EnumType { + return &file_drpc_test_proto_enumTypes[0] +} + +func (x Module) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Module.Descriptor instead. +func (Module) EnumDescriptor() ([]byte, []int) { + return file_drpc_test_proto_rawDescGZIP(), []int{0} +} + +type Function int32 + +const ( + Function_GREETING Function = 0 +) + +// Enum value maps for Function. +var ( + Function_name = map[int32]string{ + 0: "GREETING", + } + Function_value = map[string]int32{ + "GREETING": 0, + } +) + +func (x Function) Enum() *Function { + p := new(Function) + *p = x + return p +} + +func (x Function) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Function) Descriptor() protoreflect.EnumDescriptor { + return file_drpc_test_proto_enumTypes[1].Descriptor() +} + +func (Function) Type() protoreflect.EnumType { + return &file_drpc_test_proto_enumTypes[1] +} + +func (x Function) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Function.Descriptor instead. +func (Function) EnumDescriptor() ([]byte, []int) { + return file_drpc_test_proto_rawDescGZIP(), []int{1} +} + +type Hello struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *Hello) Reset() { + *x = Hello{} + if protoimpl.UnsafeEnabled { + mi := &file_drpc_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Hello) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Hello) ProtoMessage() {} + +func (x *Hello) ProtoReflect() protoreflect.Message { + mi := &file_drpc_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Hello.ProtoReflect.Descriptor instead. +func (*Hello) Descriptor() ([]byte, []int) { + return file_drpc_test_proto_rawDescGZIP(), []int{0} +} + +func (x *Hello) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type HelloResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` +} + +func (x *HelloResponse) Reset() { + *x = HelloResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_drpc_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloResponse) ProtoMessage() {} + +func (x *HelloResponse) ProtoReflect() protoreflect.Message { + mi := &file_drpc_test_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloResponse.ProtoReflect.Descriptor instead. +func (*HelloResponse) Descriptor() ([]byte, []int) { + return file_drpc_test_proto_rawDescGZIP(), []int{1} +} + +func (x *HelloResponse) GetGreeting() string { + if x != nil { + return x.Greeting + } + return "" +} + +var File_drpc_test_proto protoreflect.FileDescriptor + +var file_drpc_test_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x64, 0x72, 0x70, 0x63, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x1b, 0x0a, 0x05, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, + 0x6e, 0x67, 0x2a, 0x13, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x09, 0x0a, 0x05, + 0x48, 0x45, 0x4c, 0x4c, 0x4f, 0x10, 0x00, 0x2a, 0x18, 0x0a, 0x08, 0x46, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x12, 0x0c, 0x0a, 0x08, 0x47, 0x52, 0x45, 0x45, 0x54, 0x49, 0x4e, 0x47, 0x10, + 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x64, 0x61, 0x6f, 0x73, 0x2d, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2f, 0x64, 0x61, 0x6f, 0x73, 0x2f, + 0x73, 0x72, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2f, 0x63, 0x6d, 0x64, 0x2f, + 0x64, 0x72, 0x70, 0x63, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_drpc_test_proto_rawDescOnce sync.Once + file_drpc_test_proto_rawDescData = file_drpc_test_proto_rawDesc +) + +func file_drpc_test_proto_rawDescGZIP() []byte { + file_drpc_test_proto_rawDescOnce.Do(func() { + file_drpc_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_drpc_test_proto_rawDescData) + }) + return file_drpc_test_proto_rawDescData +} + +var file_drpc_test_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_drpc_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_drpc_test_proto_goTypes = []interface{}{ + (Module)(0), // 0: hello.Module + (Function)(0), // 1: hello.Function + (*Hello)(nil), // 2: hello.Hello + (*HelloResponse)(nil), // 3: hello.HelloResponse +} +var file_drpc_test_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_drpc_test_proto_init() } +func file_drpc_test_proto_init() { + if File_drpc_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_drpc_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Hello); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_drpc_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_drpc_test_proto_rawDesc, + NumEnums: 2, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_drpc_test_proto_goTypes, + DependencyIndexes: file_drpc_test_proto_depIdxs, + EnumInfos: file_drpc_test_proto_enumTypes, + MessageInfos: file_drpc_test_proto_msgTypes, + }.Build() + File_drpc_test_proto = out.File + file_drpc_test_proto_rawDesc = nil + file_drpc_test_proto_goTypes = nil + file_drpc_test_proto_depIdxs = nil +} diff --git a/src/control/cmd/hello_drpc/hello/drpc_test.pb.go b/src/control/cmd/hello_drpc/hello/drpc_test.pb.go index cc09f17de86..2357b5905ba 100644 --- a/src/control/cmd/hello_drpc/hello/drpc_test.pb.go +++ b/src/control/cmd/hello_drpc/hello/drpc_test.pb.go @@ -1,13 +1,13 @@ // -// (C) Copyright 2018-2021 Intel Corporation. +// (C) Copyright 2018-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.26.0 -// protoc v3.5.0 +// protoc-gen-go v1.34.1 +// protoc v3.14.0 // source: drpc_test.proto package hello diff --git a/src/control/common/proto/convert/types.go b/src/control/common/proto/convert/types.go index 07208c9493b..8ad641d566d 100644 --- a/src/control/common/proto/convert/types.go +++ b/src/control/common/proto/convert/types.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/common/proto/ctl/ctl.pb.go b/src/control/common/proto/ctl/ctl.pb.go index 86533efcfff..0f8e5e10719 100644 --- a/src/control/common/proto/ctl/ctl.pb.go +++ b/src/control/common/proto/ctl/ctl.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: ctl/ctl.proto package ctl diff --git a/src/control/common/proto/ctl/ctl_grpc.pb.go b/src/control/common/proto/ctl/ctl_grpc.pb.go index 7badc2e46af..43ae21be257 100644 --- a/src/control/common/proto/ctl/ctl_grpc.pb.go +++ b/src/control/common/proto/ctl/ctl_grpc.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v3.5.0 +// - protoc v3.14.0 // source: ctl/ctl.proto package ctl diff --git a/src/control/common/proto/ctl/firmware.pb.go b/src/control/common/proto/ctl/firmware.pb.go index 8cc8c8d49de..26b3e4b8f11 100644 --- a/src/control/common/proto/ctl/firmware.pb.go +++ b/src/control/common/proto/ctl/firmware.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: ctl/firmware.proto package ctl diff --git a/src/control/common/proto/ctl/smd.pb.go b/src/control/common/proto/ctl/smd.pb.go index 3e5b00bd894..cc0c4ae26ca 100644 --- a/src/control/common/proto/ctl/smd.pb.go +++ b/src/control/common/proto/ctl/smd.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: ctl/smd.proto package ctl diff --git a/src/control/common/proto/ctl/storage.pb.go b/src/control/common/proto/ctl/storage.pb.go index 2c03d995439..8bf34c9eee0 100644 --- a/src/control/common/proto/ctl/storage.pb.go +++ b/src/control/common/proto/ctl/storage.pb.go @@ -7,8 +7,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v3.5.0 +// protoc-gen-go v1.34.1 +// protoc v3.14.0 // source: ctl/storage.proto package ctl diff --git a/src/control/common/proto/ctl/storage_nvme.pb.go b/src/control/common/proto/ctl/storage_nvme.pb.go index 5c1ba3e9080..429a2dea710 100644 --- a/src/control/common/proto/ctl/storage_nvme.pb.go +++ b/src/control/common/proto/ctl/storage_nvme.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: ctl/storage_nvme.proto package ctl diff --git a/src/control/common/proto/ctl/support.pb.go b/src/control/common/proto/ctl/support.pb.go index 98fcab681bc..ef1bb5c2866 100644 --- a/src/control/common/proto/ctl/support.pb.go +++ b/src/control/common/proto/ctl/support.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: ctl/support.proto package ctl diff --git a/src/control/drpc/drpc.pb.go b/src/control/drpc/drpc.pb.go index ed5ace4fbee..dc8ee3db340 100644 --- a/src/control/drpc/drpc.pb.go +++ b/src/control/drpc/drpc.pb.go @@ -7,7 +7,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.1 -// protoc v3.5.0 +// protoc v3.14.0 // source: drpc.proto package drpc diff --git a/src/control/lib/control/auto.go b/src/control/lib/control/auto.go index d07a0a3e9c7..5c19f3e64eb 100644 --- a/src/control/lib/control/auto.go +++ b/src/control/lib/control/auto.go @@ -1098,7 +1098,7 @@ func genEngineConfigs(req ConfGenerateReq, newEngineCfg newEngineCfgFn, nodeSet cfg.Fabric = engine.FabricConfig{ Provider: iface.Provider, Interface: iface.Device, - InterfacePort: ifPort, + InterfacePort: fmt.Sprintf("%d", ifPort), } if err := cfg.SetNUMAAffinity(pnn); err != nil { return nil, errors.Wrapf(err, "setting numa %d affinity on engine config", diff --git a/src/control/lib/hostlist/api_test.go b/src/control/lib/hostlist/api_test.go index cd741f473fe..941d32782e0 100644 --- a/src/control/lib/hostlist/api_test.go +++ b/src/control/lib/hostlist/api_test.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/lib/hostlist/hostgroup.go b/src/control/lib/hostlist/hostgroup.go index d01d7f173df..529d60293c0 100644 --- a/src/control/lib/hostlist/hostgroup.go +++ b/src/control/lib/hostlist/hostgroup.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/lib/hostlist/hostrange.go b/src/control/lib/hostlist/hostrange.go index 2f8b2e3a57b..80c9272a526 100644 --- a/src/control/lib/hostlist/hostrange.go +++ b/src/control/lib/hostlist/hostrange.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/logging/error.go b/src/control/logging/error.go index 7bda8c4cd00..e0f249184a3 100644 --- a/src/control/logging/error.go +++ b/src/control/logging/error.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/logging/formatting.go b/src/control/logging/formatting.go index b9328c26239..013325e0426 100644 --- a/src/control/logging/formatting.go +++ b/src/control/logging/formatting.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/logging/info.go b/src/control/logging/info.go index 9d820f44877..f724cf5c2da 100644 --- a/src/control/logging/info.go +++ b/src/control/logging/info.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/pbin/faults.go b/src/control/pbin/faults.go index 0a0738fdf7f..2f9fbfcbf52 100644 --- a/src/control/pbin/faults.go +++ b/src/control/pbin/faults.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2020-2021 Intel Corporation. +// (C) Copyright 2020-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/pbin/forwarding.go b/src/control/pbin/forwarding.go index 11e296d069a..98483288dcf 100644 --- a/src/control/pbin/forwarding.go +++ b/src/control/pbin/forwarding.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/pbin/stdio.go b/src/control/pbin/stdio.go index 9b1a0d38b4a..e95bd8e4377 100644 --- a/src/control/pbin/stdio.go +++ b/src/control/pbin/stdio.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/pbin/stdio_test.go b/src/control/pbin/stdio_test.go index 48b48f113da..88e535ad690 100644 --- a/src/control/pbin/stdio_test.go +++ b/src/control/pbin/stdio_test.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/security/signature.go b/src/control/security/signature.go index 790ef81cc5b..1c61743cbc7 100644 --- a/src/control/security/signature.go +++ b/src/control/security/signature.go @@ -1,5 +1,5 @@ // -// (C) Copyright 2019-2021 Intel Corporation. +// (C) Copyright 2019-2022 Intel Corporation. // // SPDX-License-Identifier: BSD-2-Clause-Patent // diff --git a/src/control/server/config/server_test.go b/src/control/server/config/server_test.go index 08b53010c10..e45e9813a92 100644 --- a/src/control/server/config/server_test.go +++ b/src/control/server/config/server_test.go @@ -258,6 +258,7 @@ func TestServerConfig_Constructed(t *testing.T) { WithSocketDir("./.daos/daos_server"). WithFabricProvider("ofi+verbs;ofi_rxm"). WithCrtTimeout(30). + WithNumSecondaryEndpoints([]int{2}). WithMgmtSvcReplicas("hostname1", "hostname2", "hostname3"). WithFaultCb("./.daos/fd_callback"). WithFaultPath("/vcdu0/rack1/hostname"). @@ -292,6 +293,7 @@ func TestServerConfig_Constructed(t *testing.T) { WithFabricProvider("ofi+verbs;ofi_rxm"). WithFabricAuthKey("foo:bar"). WithCrtTimeout(30). + WithNumSecondaryEndpoints([]int{2}). WithPinnedNumaNode(0). WithBypassHealthChk(&bypass). WithEnvVars("CRT_TIMEOUT=30"). @@ -322,6 +324,7 @@ func TestServerConfig_Constructed(t *testing.T) { WithFabricProvider("ofi+verbs;ofi_rxm"). WithFabricAuthKey("foo:bar"). WithCrtTimeout(30). + WithNumSecondaryEndpoints([]int{2}). WithBypassHealthChk(&bypass). WithEnvVars("CRT_TIMEOUT=100"). WithLogFile("/var/log/daos/daos_engine.1.log"). @@ -363,7 +366,7 @@ func TestServerConfig_updateServerConfig(t *testing.T) { Fabric: engine.FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 1111, + InterfacePort: "1111", NumSecondaryEndpoints: []int{2, 3, 4}, }, }, @@ -377,7 +380,7 @@ func TestServerConfig_updateServerConfig(t *testing.T) { Fabric: engine.FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 1111, + InterfacePort: "1111", NumSecondaryEndpoints: []int{2, 3, 4}, }, }, diff --git a/src/control/server/engine/config.go b/src/control/server/engine/config.go index e8c16ee15fb..b743ab9827c 100644 --- a/src/control/server/engine/config.go +++ b/src/control/server/engine/config.go @@ -39,7 +39,7 @@ const ( type FabricConfig struct { Provider string `yaml:"provider,omitempty" cmdEnv:"D_PROVIDER"` Interface string `yaml:"fabric_iface,omitempty" cmdEnv:"D_INTERFACE"` - InterfacePort int `yaml:"fabric_iface_port,omitempty" cmdEnv:"D_PORT,nonzero"` + InterfacePort string `yaml:"fabric_iface_port,omitempty" cmdEnv:"D_PORT"` NumaNodeIndex uint `yaml:"-"` BypassHealthChk *bool `yaml:"bypass_health_chk,omitempty" cmdLongFlag:"--bypass_health_chk" cmdShortFlag:"-b"` CrtTimeout uint32 `yaml:"crt_timeout,omitempty" cmdEnv:"CRT_TIMEOUT"` @@ -125,11 +125,20 @@ func (fc *FabricConfig) GetInterfacePorts() ([]int, error) { return nil, errors.New("FabricConfig is nil") } - if fc.InterfacePort == 0 { + portStrs := splitMultiProviderStr(fc.InterfacePort) + if len(portStrs) == 0 { return nil, errors.New("fabric_iface_port not set") } - return []int{fc.InterfacePort}, nil + ports := make([]int, 0) + for _, str := range portStrs { + intPort, err := strconv.Atoi(str) + if err != nil { + return nil, err + } + ports = append(ports, intPort) + } + return ports, nil } // Update fills in any missing fields from the provided FabricConfig. @@ -144,7 +153,7 @@ func (fc *FabricConfig) Update(other FabricConfig) { if fc.Interface == "" { fc.Interface = other.Interface } - if fc.InterfacePort == 0 { + if fc.InterfacePort == "" { fc.InterfacePort = other.InterfacePort } if fc.CrtTimeout == 0 { @@ -195,7 +204,7 @@ func (fc *FabricConfig) Validate() error { } } - if len(interfaces) != numProv { // TODO SRS-31: check num ports when multiprovider fully enabled: || len(ports) != numProv { + if len(interfaces) != numProv || len(ports) != numProv { return errors.Errorf("provider, fabric_iface and fabric_iface_port must include the same number of items delimited by %q", MultiProviderSeparator) } @@ -663,7 +672,7 @@ func (c *Config) WithFabricInterface(iface string) *Config { // WithFabricInterfacePort sets the numeric interface port to be used by this instance. func (c *Config) WithFabricInterfacePort(ifacePort int) *Config { - c.Fabric.InterfacePort = ifacePort + c.Fabric.InterfacePort = fmt.Sprintf("%d", ifacePort) return c } diff --git a/src/control/server/engine/config_test.go b/src/control/server/engine/config_test.go index 48c29a7b794..003c0681e1c 100644 --- a/src/control/server/engine/config_test.go +++ b/src/control/server/engine/config_test.go @@ -560,14 +560,14 @@ func TestConfig_FabricValidation(t *testing.T) { "missing provider": { cfg: FabricConfig{ Interface: "bar", - InterfacePort: 42, + InterfacePort: "42", }, expErr: errors.New("provider"), }, "missing interface": { cfg: FabricConfig{ Provider: "foo", - InterfacePort: 42, + InterfacePort: "42", }, expErr: errors.New("fabric_iface"), }, @@ -582,7 +582,7 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: "foo", Interface: "bar", - InterfacePort: -42, + InterfacePort: "-42", }, expErr: errors.New("fabric_iface_port"), }, @@ -590,21 +590,21 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: "foo", Interface: "bar", - InterfacePort: 42, + InterfacePort: "42", }, }, "multi provider/interface/port ok": { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar"), Interface: multiProviderString("baz", "net"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128"), }, }, "mismatched num providers": { cfg: FabricConfig{ Provider: "foo", Interface: multiProviderString("baz", "net"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128"), }, expErr: errors.New("same number"), }, @@ -612,7 +612,15 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar"), Interface: "baz", - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128"), + }, + expErr: errors.New("same number"), + }, + "mismatched num ports": { + cfg: FabricConfig{ + Provider: multiProviderString("foo", "bar"), + Interface: multiProviderString("baz", "net"), + InterfacePort: "42", }, expErr: errors.New("same number"), }, @@ -620,7 +628,7 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar"), Interface: multiProviderString("baz", "net"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128"), NumSecondaryEndpoints: []int{0}, }, expErr: errors.New("must be > 0"), @@ -629,7 +637,7 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar", "baz"), Interface: multiProviderString("net0", "net1", "net2"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128", "256"), NumSecondaryEndpoints: []int{1, 2}, }, }, @@ -637,7 +645,7 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar", "baz"), Interface: multiProviderString("net0", "net1", "net2"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128", "256"), NumSecondaryEndpoints: []int{1, 2, 3}, }, expErr: errors.New("must have one value for each"), @@ -646,7 +654,7 @@ func TestConfig_FabricValidation(t *testing.T) { cfg: FabricConfig{ Provider: multiProviderString("foo", "bar", "baz"), Interface: multiProviderString("net0", "net1", "net2"), - InterfacePort: 42, + InterfacePort: multiProviderString("42", "128", "256"), NumSecondaryEndpoints: []int{1}, }, expErr: errors.New("must have one value for each"), @@ -949,10 +957,28 @@ func TestFabricConfig_GetInterfacePorts(t *testing.T) { }, "single": { cfg: &FabricConfig{ - InterfacePort: 1234, + InterfacePort: "1234", }, expPorts: []int{1234}, }, + "multi": { + cfg: &FabricConfig{ + InterfacePort: multiProviderString("1234", "5678", "9012"), + }, + expPorts: []int{1234, 5678, 9012}, + }, + "excessive whitespace": { + cfg: &FabricConfig{ + InterfacePort: multiProviderString("1234 ", " 5678 ", "", " 9012"), + }, + expPorts: []int{1234, 5678, 9012}, + }, + "non-integer port": { + cfg: &FabricConfig{ + InterfacePort: multiProviderString("1234", "a123"), + }, + expErr: errors.New("strconv.Atoi"), + }, } { t.Run(name, func(t *testing.T) { ports, err := tc.cfg.GetInterfacePorts() @@ -1024,7 +1050,7 @@ func TestFabricConfig_Update(t *testing.T) { new: FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 60, DisableSRX: true, NumSecondaryEndpoints: []int{1}, @@ -1032,7 +1058,7 @@ func TestFabricConfig_Update(t *testing.T) { expResult: &FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 60, DisableSRX: true, NumSecondaryEndpoints: []int{1}, @@ -1042,7 +1068,7 @@ func TestFabricConfig_Update(t *testing.T) { fc: &FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 60, DisableSRX: true, NumSecondaryEndpoints: []int{1}, @@ -1051,7 +1077,7 @@ func TestFabricConfig_Update(t *testing.T) { expResult: &FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 60, DisableSRX: true, NumSecondaryEndpoints: []int{1}, @@ -1064,14 +1090,14 @@ func TestFabricConfig_Update(t *testing.T) { new: FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 120, DisableSRX: true, }, expResult: &FabricConfig{ Provider: "provider", Interface: "iface", - InterfacePort: 9999, + InterfacePort: "9999", CrtTimeout: 60, DisableSRX: true, }, diff --git a/src/engine/drpc_client.c b/src/engine/drpc_client.c index 9c013e9d2cf..41500011d08 100644 --- a/src/engine/drpc_client.c +++ b/src/engine/drpc_client.c @@ -164,7 +164,10 @@ drpc_notify_ready(bool check_mode) size_t reqb_size; Drpc__Response *dresp; uint64_t incarnation; + size_t nr_sec_uris; + char **sec_uris = NULL; int rc; + int i; rc = crt_self_uri_get(0 /* tag */, &req.uri); if (rc != 0) @@ -173,8 +176,38 @@ drpc_notify_ready(bool check_mode) if (rc != 0) goto out_uri; + nr_sec_uris = crt_get_nr_secondary_providers(); + if (nr_sec_uris > 0) { + D_ALLOC_ARRAY(sec_uris, nr_sec_uris); + if (sec_uris == NULL) + D_GOTO(out_uri, rc = -DER_NOMEM); + for (i = 0; i < nr_sec_uris; i++) { + rc = crt_self_uri_get_secondary(i, &sec_uris[i]); + if (rc != 0) { + D_ERROR("failed to get secondary provider URI, idx=%d, rc=%d\n", + i, rc); + nr_sec_uris = i; + goto out_sec_uri; + } + D_DEBUG(DB_MGMT, "secondary provider URI: %s\n", sec_uris[i]); + } + + D_DEBUG(DB_MGMT, "setting secondary provider URIs\n"); + req.secondaryuris = sec_uris; + req.n_secondaryuris = nr_sec_uris; + + D_DEBUG(DB_MGMT, "setting secondary provider number cart ctxs\n"); + req.n_secondarynctxs = nr_sec_uris; + D_ALLOC_ARRAY(req.secondarynctxs, nr_sec_uris); + if (req.secondarynctxs == NULL) + D_GOTO(out_sec_uri, rc = -DER_NOMEM); + for (i = 0; i < nr_sec_uris; i++) + req.secondarynctxs[i] = dss_sec_xs_nr; + } + req.incarnation = incarnation; req.nctxs = DSS_CTX_NR_TOTAL; + /* Do not free, this string is managed by the dRPC listener */ req.drpclistenersock = drpc_listener_socket_path; req.instanceidx = dss_instance_idx; @@ -184,7 +217,7 @@ drpc_notify_ready(bool check_mode) reqb_size = srv__notify_ready_req__get_packed_size(&req); D_ALLOC(reqb, reqb_size); if (reqb == NULL) - D_GOTO(out_uri, rc = -DER_NOMEM); + D_GOTO(out_sec_nctxs, rc = -DER_NOMEM); srv__notify_ready_req__pack(&req, reqb); D_INFO("notifying server ready\n"); @@ -201,6 +234,12 @@ drpc_notify_ready(bool check_mode) drpc_response_free(dresp); out_reqb: D_FREE(reqb); +out_sec_nctxs: + D_FREE(req.secondarynctxs); +out_sec_uri: + for (i = 0; i < nr_sec_uris; i++) + D_FREE(sec_uris[i]); + D_FREE(sec_uris); out_uri: D_FREE(req.uri); out: diff --git a/src/engine/init.c b/src/engine/init.c index 0072b87be33..2b4516e0033 100644 --- a/src/engine/init.c +++ b/src/engine/init.c @@ -1004,6 +1004,7 @@ parse(int argc, char **argv) { "instance_idx", required_argument, NULL, 'I' }, { "bypass_health_chk", no_argument, NULL, 'b' }, { "storage_tiers", required_argument, NULL, 'T' }, + { "nr_sec_ctx", required_argument, NULL, 'S' }, { "check", no_argument, NULL, 'C' }, { NULL, 0, NULL, 0} }; @@ -1015,7 +1016,7 @@ parse(int argc, char **argv) /* load all of modules by default */ sprintf(modules, "%s", MODULE_LIST); - while ((c = getopt_long(argc, argv, "c:d:f:g:hi:m:n:p:r:H:t:s:x:I:bT:C", + while ((c = getopt_long(argc, argv, "c:d:f:g:hi:m:n:p:r:H:t:s:x:I:bT:S:C:", opts, NULL)) != -1) { switch (c) { case 'm': @@ -1087,6 +1088,9 @@ parse(int argc, char **argv) rc = -DER_INVAL; } break; + case 'S': + rc = arg_strtoul(optarg, &dss_sec_xs_nr, "\"-S\""); + break; case 'C': dss_check_mode = true; if (spec_mod) { diff --git a/src/engine/srv.c b/src/engine/srv.c index 697b94a2304..62e888e34a3 100644 --- a/src/engine/srv.c +++ b/src/engine/srv.c @@ -14,7 +14,7 @@ * - bind execution streams to core/NUMA node */ -#define D_LOGFAC DD_FAC(server) +#define D_LOGFAC DD_FAC(server) #include #include @@ -72,16 +72,18 @@ * daos_rpc_tag() to query the target tag (context ID) of specific RPC request. */ +/** Number of secondary cart context XS */ +unsigned int dss_sec_xs_nr; /** Number of offload XS */ -unsigned int dss_tgt_offload_xs_nr; +unsigned int dss_tgt_offload_xs_nr; /** Number of offload per socket */ -unsigned int dss_offload_per_numa_nr; +unsigned int dss_offload_per_numa_nr; /** Number of target per socket */ -unsigned int dss_tgt_per_numa_nr; +unsigned int dss_tgt_per_numa_nr; /** Number of target (XS set) per engine */ -unsigned int dss_tgt_nr; +unsigned int dss_tgt_nr; /** Number of system XS */ -unsigned int dss_sys_xs_nr = DSS_SYS_XS_NR_DEFAULT; +unsigned int dss_sys_xs_nr = DSS_SYS_XS_NR_DEFAULT; /** * Flag of helper XS as a pool. * false - the helper XS is near its main IO service XS. When there is one or @@ -93,12 +95,12 @@ unsigned int dss_sys_xs_nr = DSS_SYS_XS_NR_DEFAULT; * create all VOS targets' IO service XS, and then all helper XS that * are shared used by all VOS targets. */ -bool dss_helper_pool; +bool dss_helper_pool; /** Bypass for the nvme health check */ -bool dss_nvme_bypass_health_check; +bool dss_nvme_bypass_health_check; -static daos_epoch_t dss_start_epoch; +static daos_epoch_t dss_start_epoch; unsigned int dss_ctx_nr_get(void) @@ -106,17 +108,23 @@ dss_ctx_nr_get(void) return DSS_CTX_NR_TOTAL; } +#define DSS_SYS_XS_NAME_FMT "daos_sys_%d" +#define DSS_IO_XS_NAME_FMT "daos_io_%d" +#define DSS_IOFW_XS_NAME_FMT "daos_iofw_%d" +#define DSS_OFFLOAD_XS_NAME_FMT "daos_off_%d" +#define DSS_SEC_XS_NAME_FMT "daos_sec_%d" + struct dss_xstream_data { /** Initializing step, it is for cleanup of global states */ - int xd_init_step; - int xd_ult_init_rc; - bool xd_ult_signal; + int xd_init_step; + int xd_ult_init_rc; + bool xd_ult_signal; /** total number of XS including system XS, main XS and offload XS */ - int xd_xs_nr; + int xd_xs_nr; /** created XS pointer array */ - struct dss_xstream **xd_xs_ptrs; + struct dss_xstream **xd_xs_ptrs; /** serialize initialization of ULTs */ - ABT_cond xd_ult_init; + ABT_cond xd_ult_init; /** barrier for all ULTs to enter handling loop */ ABT_cond xd_ult_barrier; ABT_mutex xd_mutex; @@ -124,7 +132,7 @@ struct dss_xstream_data { bool xd_monitor_runnable; }; -static struct dss_xstream_data xstream_data; +static struct dss_xstream_data xstream_data; bool dss_sched_monitor_enter(void) @@ -172,8 +180,7 @@ dss_xstream_set_affinity(struct dss_xstream *dxs) * Set memory affinity, but fail silently if it does not work since some * systems return ENOSYS. */ - rc = hwloc_set_membind(dss_topo, dxs->dx_cpuset, HWLOC_MEMBIND_BIND, - HWLOC_MEMBIND_THREAD); + rc = hwloc_set_membind(dss_topo, dxs->dx_cpuset, HWLOC_MEMBIND_BIND, HWLOC_MEMBIND_THREAD); if (rc) D_DEBUG(DB_TRACE, "failed to set memory affinity: %d\n", errno); @@ -184,7 +191,7 @@ bool dss_xstream_exiting(struct dss_xstream *dxs) { ABT_bool state; - int rc; + int rc; rc = ABT_future_test(dxs->dx_shutdown, &state); D_ASSERTF(rc == ABT_SUCCESS, "%d\n", rc); @@ -204,8 +211,8 @@ dss_get_xstream(int stream_id) return dss_current_xstream(); D_ASSERTF(stream_id >= 0 && stream_id < xstream_data.xd_xs_nr, - "invalid stream id %d (xstream_data.xd_xs_nr %d).\n", - stream_id, xstream_data.xd_xs_nr); + "invalid stream id %d (xstream_data.xd_xs_nr %d).\n", stream_id, + xstream_data.xd_xs_nr); return xstream_data.xd_xs_ptrs[stream_id]; } @@ -218,9 +225,9 @@ dss_get_xstream(int stream_id) int dss_sleep(uint64_t msec) { - struct sched_req_attr attr = { 0 }; - struct sched_request *req; - uuid_t anonym_uuid; + struct sched_req_attr attr = {0}; + struct sched_request *req; + uuid_t anonym_uuid; uuid_clear(anonym_uuid); sched_req_attr_init(&attr, SCHED_REQ_ANONYM, &anonym_uuid); @@ -236,7 +243,7 @@ dss_sleep(uint64_t msec) struct dss_rpc_cntr * dss_rpc_cntr_get(enum dss_rpc_cntr_id id) { - struct dss_xstream *dx = dss_current_xstream(); + struct dss_xstream *dx = dss_current_xstream(); D_ASSERT(id < DSS_RC_MAX); return &dx->dx_rpc_cntrs[id]; @@ -273,30 +280,27 @@ dss_rpc_cntr_exit(enum dss_rpc_cntr_id id, bool error) } static int -dss_iv_resp_hdlr(crt_context_t *ctx, void *hdlr_arg, - void (*real_rpc_hdlr)(void *), void *arg) +dss_iv_resp_hdlr(crt_context_t *ctx, void *hdlr_arg, void (*real_rpc_hdlr)(void *), void *arg) { - struct dss_xstream *dx = (struct dss_xstream *)arg; + struct dss_xstream *dx = (struct dss_xstream *)arg; /* * Current EC aggregation periodically update IV, use * PERIODIC flag to avoid interfering CPU relaxing. */ - return sched_create_thread(dx, real_rpc_hdlr, hdlr_arg, - ABT_THREAD_ATTR_NULL, NULL, + return sched_create_thread(dx, real_rpc_hdlr, hdlr_arg, ABT_THREAD_ATTR_NULL, NULL, DSS_ULT_FL_PERIODIC); } static int -dss_rpc_hdlr(crt_context_t *ctx, void *hdlr_arg, - void (*real_rpc_hdlr)(void *), void *arg) +dss_rpc_hdlr(crt_context_t *ctx, void *hdlr_arg, void (*real_rpc_hdlr)(void *), void *arg) { - struct dss_xstream *dx = (struct dss_xstream *)arg; - crt_rpc_t *rpc = (crt_rpc_t *)hdlr_arg; - unsigned int mod_id = opc_get_mod_id(rpc->cr_opc); - struct dss_module *module = dss_module_get(mod_id); - struct sched_req_attr attr = { 0 }; - int rc; + struct dss_xstream *dx = (struct dss_xstream *)arg; + crt_rpc_t *rpc = (crt_rpc_t *)hdlr_arg; + unsigned int mod_id = opc_get_mod_id(rpc->cr_opc); + struct dss_module *module = dss_module_get(mod_id); + struct sched_req_attr attr = {0}; + int rc; if (DAOS_FAIL_CHECK(DAOS_FAIL_LOST_REQ)) return 0; @@ -334,11 +338,50 @@ dss_rpc_hdlr(crt_context_t *ctx, void *hdlr_arg, return -DER_TIMEDOUT; } +static int +secondary_rpc_hdlr(crt_context_t *ctx, void *hdlr_arg, void (*real_rpc_hdlr)(void *), void *arg) +{ + struct dss_xstream *primary_dx; + crt_rpc_t *rpc = (crt_rpc_t *)hdlr_arg; + uint32_t tag; + int xs_id, rc; + + D_DEBUG(DB_TRACE, "Received secondary RPC, opc: %#x\n", rpc->cr_opc); + + rc = crt_req_dst_tag_get(rpc, &tag); + if (rc) { + D_ERROR("Failed to get tag from RPC, " DF_RC "\n", DP_RC(rc)); + return rc; + } + + /* The RPC dest tag must be SYS0 or a VOS target */ + if (tag == 0) { + xs_id = 0; + } else if (tag >= DAOS_TGT0_OFFSET && tag < DAOS_IO_CTX_ID(dss_tgt_nr)) { + xs_id = DSS_MAIN_XS_ID(tag - DAOS_TGT0_OFFSET); + } else { + D_ERROR("Invalid tag:%u from secondary RPC\n", tag); + return -DER_INVAL; + } + + primary_dx = dss_get_xstream(xs_id); + if (primary_dx == NULL) { + D_ERROR("Failed to get primary xstream:%u\n", xs_id); + return -DER_INVAL; + } + + /* + * Given that the secondary RPC isn't common use case, ignore the CPU apportioning + * policy and kickoff the RPC processing on primary xstream immediately. + */ + return sched_create_thread(primary_dx, real_rpc_hdlr, rpc, ABT_THREAD_ATTR_NULL, NULL, 0); +} + static void dss_nvme_poll_ult(void *args) { - struct dss_module_info *dmi = dss_get_module_info(); - struct dss_xstream *dx = dss_current_xstream(); + struct dss_module_info *dmi = dss_get_module_info(); + struct dss_xstream *dx = dss_current_xstream(); D_ASSERT(dss_xstream_has_nvme(dx)); while (!dss_xstream_exiting(dx)) { @@ -355,20 +398,19 @@ dss_nvme_poll_ult(void *args) static void wait_all_exited(struct dss_xstream *dx, struct dss_module_info *dmi) { - int rc; + int rc; D_DEBUG(DB_TRACE, "XS(%d) draining ULTs.\n", dx->dx_xs_id); sched_stop(dx); while (1) { - size_t total_size = 0; - int i; + size_t total_size = 0; + int i; for (i = 0; i < DSS_POOL_CNT; i++) { - size_t pool_size; - rc = ABT_pool_get_total_size(dx->dx_pools[i], - &pool_size); + size_t pool_size; + rc = ABT_pool_get_total_size(dx->dx_pools[i], &pool_size); D_ASSERTF(rc == ABT_SUCCESS, "%d\n", rc); total_size += pool_size; } @@ -386,8 +428,7 @@ wait_all_exited(struct dss_xstream *dx, struct dss_module_info *dmi) if (dx->dx_comm) { rc = crt_progress(dmi->dmi_ctx, 0); if (rc != 0 && rc != -DER_TIMEDOUT) - D_ERROR("failed to progress CART context: %d\n", - rc); + D_ERROR("failed to progress CART context: %d\n", rc); } ABT_thread_yield(); @@ -395,6 +436,71 @@ wait_all_exited(struct dss_xstream *dx, struct dss_module_info *dmi) D_DEBUG(DB_TRACE, "XS(%d) drained ULTs.\n", dx->dx_xs_id); } +/* Get xstream type from xstream ID */ +static unsigned int +xs_id2type(unsigned int xs_id) +{ + unsigned int helper_per_tgt, xs_offset; + + D_ASSERTF(xs_id < DSS_XS_NR_TOTAL, + "invalid xs_id %d, dss_tgt_nr %d, dss_tgt_offload_xs_nr %d, dss_sec_xs_nr %d\n", + xs_id, dss_tgt_nr, dss_tgt_offload_xs_nr, dss_sec_xs_nr); + + if (xs_id == 0) + return DSS_XS_SYS; + else if (xs_id == 1) + return DSS_XS_SWIM; + else if (xs_id < dss_sys_xs_nr) + return DSS_XS_DRPC; + else if (xs_id >= dss_sys_xs_nr + dss_tgt_nr + dss_tgt_offload_xs_nr) + return DSS_XS_SEC; + + if (dss_helper_pool) { + if (xs_id < (dss_sys_xs_nr + dss_tgt_nr)) + return DSS_XS_VOS; + else if (xs_id < (dss_sys_xs_nr + 2 * dss_tgt_nr)) + return DSS_XS_IOFW; + else + return DSS_XS_OFFLOAD; + } + + helper_per_tgt = dss_tgt_offload_xs_nr / dss_tgt_nr; + D_ASSERT(helper_per_tgt == 0 || helper_per_tgt == 1 || helper_per_tgt == 2); + + xs_offset = (xs_id - dss_sys_xs_nr) % (helper_per_tgt + 1); + if (xs_offset == 0) + return DSS_XS_VOS; + else if (xs_offset == 1) + return DSS_XS_IOFW; + else + return DSS_XS_OFFLOAD; +} + +/* Get target ID from xstream ID */ +static inline int +xs_id2tgt(int xs_id) +{ + unsigned int helper_per_tgt; + unsigned int xs_type = xs_id2type(xs_id); + + if (xs_type != DSS_XS_VOS && xs_type != DSS_XS_IOFW) + return -1; + + if (dss_helper_pool) + return xs_id - dss_sys_xs_nr; + + helper_per_tgt = dss_tgt_offload_xs_nr / dss_tgt_nr; + D_ASSERT(helper_per_tgt == 0 || helper_per_tgt == 1 || helper_per_tgt == 2); + + return (xs_id - dss_sys_xs_nr) / (helper_per_tgt + 1); +} + +static inline bool +has_crt_context(struct dss_xstream *dx) +{ + return dx->dx_comm || (xs_id2type(dx->dx_xs_id) == DSS_XS_SEC); +} + #define D_MEMORY_TRACK_ENV "D_MEMORY_TRACK" /* * The server handler ULT first sets CPU affinity, initialize the per-xstream @@ -408,10 +514,11 @@ dss_srv_handler(void *arg) struct dss_xstream *dx = (struct dss_xstream *)arg; struct daos_thread_local_storage *dtc; struct dss_module_info *dmi; - int rc; - bool track_mem = false; - bool signal_caller = true; - bool with_chore_queue = dx->dx_iofw && !dx->dx_main_xs; + int rc; + bool track_mem = false; + bool signal_caller = true; + unsigned int xs_type; + bool with_chore_queue; rc = dss_xstream_set_affinity(dx); if (rc) @@ -431,36 +538,54 @@ dss_srv_handler(void *arg) dmi = dss_get_module_info(); D_ASSERT(dmi != NULL); - dmi->dmi_xs_id = dx->dx_xs_id; - dmi->dmi_tgt_id = dx->dx_tgt_id; + dmi->dmi_xs_id = dx->dx_xs_id; + dmi->dmi_tgt_id = dx->dx_tgt_id; dmi->dmi_ctx_id = -1; D_INIT_LIST_HEAD(&dmi->dmi_dtx_batched_cont_open_list); D_INIT_LIST_HEAD(&dmi->dmi_dtx_batched_pool_list); (void)pthread_setname_np(pthread_self(), dx->dx_name); - if (dx->dx_comm) { + xs_type = xs_id2type(dx->dx_xs_id); + with_chore_queue = (xs_type == DSS_XS_IOFW || xs_type == DSS_XS_OFFLOAD); + if (xs_type == DSS_XS_SEC) { + rc = crt_context_create_secondary(&dmi->dmi_ctx, 0); + if (rc != 0) { + D_ERROR("Failed to create secondary crt ctxt: " DF_RC "\n", DP_RC(rc)); + goto tls_fini; + } + + rc = crt_context_register_rpc_task(dmi->dmi_ctx, secondary_rpc_hdlr, NULL, dx); + if (rc != 0) { + D_ERROR("Failed to register secondary process cb " DF_RC "\n", DP_RC(rc)); + goto crt_destroy; + } + + rc = crt_context_idx(dmi->dmi_ctx, &dmi->dmi_ctx_id); + if (rc != 0) { + D_ERROR("Failed to get secondary context ID: rc " DF_RC "\n", DP_RC(rc)); + goto crt_destroy; + } + dx->dx_ctx_id = dmi->dmi_ctx_id; + } else if (dx->dx_comm) { /* create private transport context */ rc = crt_context_create(&dmi->dmi_ctx); if (rc != 0) { - D_ERROR("failed to create crt ctxt: "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to create crt ctxt: " DF_RC "\n", DP_RC(rc)); goto tls_fini; } - rc = crt_context_register_rpc_task(dmi->dmi_ctx, dss_rpc_hdlr, - dss_iv_resp_hdlr, dx); + rc = + crt_context_register_rpc_task(dmi->dmi_ctx, dss_rpc_hdlr, dss_iv_resp_hdlr, dx); if (rc != 0) { - D_ERROR("failed to register process cb "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to register process cb " DF_RC "\n", DP_RC(rc)); goto crt_destroy; } /** Get context index from cart */ rc = crt_context_idx(dmi->dmi_ctx, &dmi->dmi_ctx_id); if (rc != 0) { - D_ERROR("failed to get xtream index: rc "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to get xtream index: rc " DF_RC "\n", DP_RC(rc)); goto crt_destroy; } dx->dx_ctx_id = dmi->dmi_ctx_id; @@ -469,15 +594,14 @@ dss_srv_handler(void *arg) /* * xs_id: 0 => SYS XS: ctx_id: 0 * xs_id: 1 => SWIM XS: ctx_id: 1 - * xs_id: 2 => DRPC XS: no ctx_id */ D_ASSERTF(dx->dx_ctx_id == dx->dx_xs_id, - "incorrect ctx_id %d for xs_id %d\n", - dx->dx_ctx_id, dx->dx_xs_id); + "incorrect ctx_id %d for xs_id %d\n", dx->dx_ctx_id, + dx->dx_xs_id); } else { if (dx->dx_main_xs) { D_ASSERTF(dx->dx_ctx_id == - (dx->dx_tgt_id + dss_sys_xs_nr - DRPC_XS_NR), + (dx->dx_tgt_id + dss_sys_xs_nr - DRPC_XS_NR), "incorrect ctx_id %d for xs_id %d tgt_id %d\n", dx->dx_ctx_id, dx->dx_xs_id, dx->dx_tgt_id); } else { @@ -486,13 +610,12 @@ dss_srv_handler(void *arg) "incorrect ctx_id %d for xs_id %d tgt_id %d\n", dx->dx_ctx_id, dx->dx_xs_id, dx->dx_tgt_id); else - D_ASSERTF(dx->dx_ctx_id == - (dx->dx_tgt_id + dss_sys_xs_nr - DRPC_XS_NR + - dss_tgt_nr), + D_ASSERTF(dx->dx_ctx_id == (dx->dx_tgt_id + dss_sys_xs_nr - + DRPC_XS_NR + dss_tgt_nr), "incorrect ctx_id %d for xs_id %d " "tgt_id %d tgt_nr %d\n", - dx->dx_ctx_id, dx->dx_xs_id, - dx->dx_tgt_id, dss_tgt_nr); + dx->dx_ctx_id, dx->dx_xs_id, dx->dx_tgt_id, + dss_tgt_nr); } } } @@ -508,12 +631,13 @@ dss_srv_handler(void *arg) ABT_thread_attr attr; /* Initialize NVMe context for main XS which accesses NVME */ - rc = bio_xsctxt_alloc(&dmi->dmi_nvme_ctxt, - dmi->dmi_tgt_id < 0 ? BIO_SYS_TGT_ID : dmi->dmi_tgt_id, - false); + rc = + bio_xsctxt_alloc(&dmi->dmi_nvme_ctxt, + dmi->dmi_tgt_id < 0 ? BIO_SYS_TGT_ID : dmi->dmi_tgt_id, false); if (rc != 0) { D_ERROR("failed to init spdk context for xstream(%d) " - "rc:%d\n", dmi->dmi_xs_id, rc); + "rc:%d\n", + dmi->dmi_xs_id, rc); D_GOTO(tse_fini, rc); } @@ -555,7 +679,7 @@ dss_srv_handler(void *arg) ABT_mutex_lock(xstream_data.xd_mutex); /* initialized everything for the ULT, notify the creator */ D_ASSERT(!xstream_data.xd_ult_signal); - xstream_data.xd_ult_signal = true; + xstream_data.xd_ult_signal = true; xstream_data.xd_ult_init_rc = 0; ABT_cond_signal(xstream_data.xd_ult_init); @@ -567,24 +691,23 @@ dss_srv_handler(void *arg) * respond to incoming pings. It is out of the scope of * dss_{thread,task}_collective. */ - if (dx->dx_xs_id != 1 /* DSS_XS_SWIM */) + if (xs_type != DSS_XS_SWIM) ABT_cond_wait(xstream_data.xd_ult_barrier, xstream_data.xd_mutex); ABT_mutex_unlock(xstream_data.xd_mutex); /* SWIM doesn't require RPC protocol */ if (dx->dx_xs_id != 1) dmi->dmi_version = dss_get_join_version(); - if (dx->dx_comm) + if (has_crt_context(dx)) dx->dx_progress_started = true; signal_caller = false; /* main service progress loop */ for (;;) { - if (dx->dx_comm) { + if (has_crt_context(dx)) { rc = crt_progress(dmi->dmi_ctx, dx->dx_timeout); if (rc != 0 && rc != -DER_TIMEDOUT) { - D_ERROR("failed to progress CART context: %d\n", - rc); + D_ERROR("failed to progress CART context: %d\n", rc); /* XXX Sometimes the failure might be just * temporary, Let's keep progressing for now. */ @@ -599,7 +722,7 @@ dss_srv_handler(void *arg) ABT_thread_yield(); } - if (dx->dx_comm) + if (has_crt_context(dx)) dx->dx_progress_started = false; if (with_chore_queue) @@ -617,7 +740,7 @@ dss_srv_handler(void *arg) tse_fini: tse_sched_fini(&dx->dx_sched_dsc); crt_destroy: - if (dx->dx_comm) + if (has_crt_context(dx)) crt_context_destroy(dmi->dmi_ctx, true); tls_fini: dss_tls_fini(dtc); @@ -626,7 +749,7 @@ dss_srv_handler(void *arg) ABT_mutex_lock(xstream_data.xd_mutex); /* initialized everything for the ULT, notify the creator */ D_ASSERT(!xstream_data.xd_ult_signal); - xstream_data.xd_ult_signal = true; + xstream_data.xd_ult_signal = true; xstream_data.xd_ult_init_rc = rc; ABT_cond_signal(xstream_data.xd_ult_init); ABT_mutex_unlock(xstream_data.xd_mutex); @@ -637,9 +760,9 @@ dss_srv_handler(void *arg) static inline struct dss_xstream * dss_xstream_alloc(hwloc_cpuset_t cpus) { - struct dss_xstream *dx; - int i; - int rc = 0; + struct dss_xstream *dx; + int i; + int rc = 0; D_ALLOC_PTR(dx); if (dx == NULL) { @@ -670,9 +793,9 @@ dss_xstream_alloc(hwloc_cpuset_t cpus) for (i = 0; i < DSS_POOL_CNT; i++) dx->dx_pools[i] = ABT_POOL_NULL; - dx->dx_xstream = ABT_XSTREAM_NULL; - dx->dx_sched = ABT_SCHED_NULL; - dx->dx_progress = ABT_THREAD_NULL; + dx->dx_xstream = ABT_XSTREAM_NULL; + dx->dx_sched = ABT_SCHED_NULL; + dx->dx_progress = ABT_THREAD_NULL; return dx; @@ -698,15 +821,15 @@ dss_mem_stats_init(struct mem_stats *stats, int xs_id) { int rc; - rc = d_tm_add_metric(&stats->ms_total_usage, D_TM_GAUGE, - "Total memory usage", "byte", "mem/total_mem/xs_%u", xs_id); + rc = d_tm_add_metric(&stats->ms_total_usage, D_TM_GAUGE, "Total memory usage", "byte", + "mem/total_mem/xs_%u", xs_id); if (rc) - D_WARN("Failed to create memory telemetry: "DF_RC"\n", DP_RC(rc)); + D_WARN("Failed to create memory telemetry: " DF_RC "\n", DP_RC(rc)); - rc = d_tm_add_metric(&stats->ms_mallinfo, D_TM_MEMINFO, - "Total memory arena", "", "mem/meminfo/xs_%u", xs_id); + rc = d_tm_add_metric(&stats->ms_mallinfo, D_TM_MEMINFO, "Total memory arena", "", + "mem/meminfo/xs_%u", xs_id); if (rc) - D_WARN("Failed to create memory telemetry: "DF_RC"\n", DP_RC(rc)); + D_WARN("Failed to create memory telemetry: " DF_RC "\n", DP_RC(rc)); stats->ms_current = 0; } @@ -746,84 +869,49 @@ dss_mem_total_free_track(void *arg, daos_size_t bytes) static int dss_start_one_xstream(hwloc_cpuset_t cpus, int tag, int xs_id) { - struct dss_xstream *dx; - ABT_thread_attr attr = ABT_THREAD_ATTR_NULL; - int rc = 0; - bool comm; /* true to create cart ctx for RPC */ - int xs_offset = 0; + struct dss_xstream *dx; + ABT_thread_attr attr = ABT_THREAD_ATTR_NULL; + int rc = 0; + unsigned int xs_type = xs_id2type(xs_id); /** allocate & init xstream configuration data */ dx = dss_xstream_alloc(cpus); if (dx == NULL) return -DER_NOMEM; - /* Partial XS need the RPC communication ability - system XS, each - * main XS and its first offload XS (for IO dispatch). - * The 2nd offload XS(if exists) does not need RPC communication - * as it is only for EC/checksum/compress offloading. + /* + * SYS, SWIM, every main xstream (VOS) and its first offloading xstream + * (IOFW for IO forwarding) requires primary cart context. The 2nd offloading + * xstream (OFFLOAD for EC/csum/compress calculation) have no cart context. */ - if (dss_helper_pool) { - comm = (xs_id == 0) || /* DSS_XS_SYS */ - (xs_id == 1) || /* DSS_XS_SWIM */ - (xs_id >= dss_sys_xs_nr && - xs_id < (dss_sys_xs_nr + 2 * dss_tgt_nr)); - } else { - int helper_per_tgt; - - helper_per_tgt = dss_tgt_offload_xs_nr / dss_tgt_nr; - D_ASSERT(helper_per_tgt == 0 || - helper_per_tgt == 1 || - helper_per_tgt == 2); - - if ((xs_id >= dss_sys_xs_nr) && - (xs_id < (dss_sys_xs_nr + dss_tgt_nr + dss_tgt_offload_xs_nr))) - xs_offset = (xs_id - dss_sys_xs_nr) % (helper_per_tgt + 1); - else - xs_offset = -1; - - comm = (xs_id == 0) || /* DSS_XS_SYS */ - (xs_id == 1) || /* DSS_XS_SWIM */ - (xs_offset == 0) || /* main XS */ - (xs_offset == 1); /* first offload XS */ - } - - dx->dx_tag = tag; - dx->dx_xs_id = xs_id; - dx->dx_ctx_id = -1; - dx->dx_comm = comm; - if (dss_helper_pool) { - dx->dx_main_xs = (xs_id >= dss_sys_xs_nr) && - (xs_id < (dss_sys_xs_nr + dss_tgt_nr)); - } else { - dx->dx_main_xs = (xs_id >= dss_sys_xs_nr) && (xs_offset == 0); - } - /* See the DSS_XS_IOFW case in sched_ult2xs. */ - dx->dx_iofw = xs_id >= dss_sys_xs_nr && (!dx->dx_main_xs || dss_tgt_offload_xs_nr == 0); + dx->dx_tag = tag; + dx->dx_xs_id = xs_id; + dx->dx_ctx_id = -1; + dx->dx_comm = (xs_type == DSS_XS_SYS) || (xs_type == DSS_XS_SWIM) || + (xs_type == DSS_XS_VOS) || (xs_type == DSS_XS_IOFW); + dx->dx_main_xs = (xs_type == DSS_XS_VOS); dx->dx_dsc_started = false; + dx->dx_tgt_id = xs_id2tgt(xs_id); /** * Generate name for each xstreams so that they can be easily identified * and monitored independently (e.g. via ps(1)) */ - dx->dx_tgt_id = dss_xs2tgt(xs_id); - if (xs_id < dss_sys_xs_nr) { - /** system xtreams are named daos_sys_$num */ - snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_SYS_XS_NAME_FMT, - xs_id); - } else if (dx->dx_main_xs) { - /** primary I/O xstreams are named daos_io_$tgtid */ - snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_IO_XS_NAME_FMT, - dx->dx_tgt_id); - } else { - /** offload xstreams are named daos_off_$num */ - snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_OFFLOAD_XS_NAME_FMT, - xs_id); - } + if (xs_id < dss_sys_xs_nr) + snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_SYS_XS_NAME_FMT, xs_id); + else if (xs_type == DSS_XS_VOS) + snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_IO_XS_NAME_FMT, dx->dx_tgt_id); + else if (xs_type == DSS_XS_IOFW) + snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_IOFW_XS_NAME_FMT, xs_id); + else if (xs_type == DSS_XS_OFFLOAD) + snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_OFFLOAD_XS_NAME_FMT, xs_id); + else + snprintf(dx->dx_name, DSS_XS_NAME_LEN, DSS_SEC_XS_NAME_FMT, xs_id); /** create ABT scheduler in charge of this xstream */ rc = dss_sched_init(dx); if (rc != 0) { - D_ERROR("create scheduler fails: "DF_RC"\n", DP_RC(rc)); + D_ERROR("create scheduler fails: " DF_RC "\n", DP_RC(rc)); D_GOTO(out_dx, rc); } @@ -836,8 +924,7 @@ dss_start_one_xstream(hwloc_cpuset_t cpus, int tag, int xs_id) dss_mem_stats_init(&dx->dx_mem_stats, xs_id); /** start XS, ABT rank 0 is reserved for the primary xstream */ - rc = ABT_xstream_create_with_rank(dx->dx_sched, xs_id + 1, - &dx->dx_xstream); + rc = ABT_xstream_create_with_rank(dx->dx_sched, xs_id + 1, &dx->dx_xstream); if (rc != ABT_SUCCESS) { D_ERROR("create xstream fails %d\n", rc); D_GOTO(out_chore_queue, rc = dss_abterr2der(rc)); @@ -868,7 +955,7 @@ dss_start_one_xstream(hwloc_cpuset_t cpus, int tag, int xs_id) if (!xstream_data.xd_ult_signal) ABT_cond_wait(xstream_data.xd_ult_init, xstream_data.xd_mutex); xstream_data.xd_ult_signal = false; - rc = xstream_data.xd_ult_init_rc; + rc = xstream_data.xd_ult_init_rc; if (rc != 0) { ABT_mutex_unlock(xstream_data.xd_mutex); goto out_xstream; @@ -877,10 +964,11 @@ dss_start_one_xstream(hwloc_cpuset_t cpus, int tag, int xs_id) ABT_mutex_unlock(xstream_data.xd_mutex); ABT_thread_attr_free(&attr); - D_DEBUG(DB_TRACE, "created xstream name(%s)xs_id(%d)/tgt_id(%d)/" + D_DEBUG(DB_TRACE, + "created xstream name(%s)xs_id(%d)/tgt_id(%d)/" "ctx_id(%d)/comm(%d)/is_main_xs(%d).\n", - dx->dx_name, dx->dx_xs_id, dx->dx_tgt_id, dx->dx_ctx_id, - dx->dx_comm, dx->dx_main_xs); + dx->dx_name, dx->dx_xs_id, dx->dx_tgt_id, dx->dx_ctx_id, dx->dx_comm, + dx->dx_main_xs); return 0; out_xstream: @@ -900,10 +988,10 @@ dss_start_one_xstream(hwloc_cpuset_t cpus, int tag, int xs_id) static void dss_xstreams_fini(bool force) { - struct dss_xstream *dx; - int i; - int rc; - bool started = false; + struct dss_xstream *dx; + int i; + int rc; + bool started = false; D_DEBUG(DB_TRACE, "Stopping execution streams\n"); dss_xstreams_open_barrier(true); @@ -957,7 +1045,7 @@ dss_xstreams_fini(bool force) /* All other xstreams have terminated. */ xstream_data.xd_xs_nr = 0; - dss_tgt_nr = 0; + dss_tgt_nr = 0; D_DEBUG(DB_TRACE, "Execution streams stopped\n"); } @@ -994,83 +1082,223 @@ dss_xstreams_empty(void) bool dss_xstream_is_busy(void) { - struct dss_rpc_cntr *cntr = dss_rpc_cntr_get(DSS_RC_OBJ); - uint64_t cur_msec; + struct dss_rpc_cntr *cntr = dss_rpc_cntr_get(DSS_RC_OBJ); + uint64_t cur_msec; cur_msec = sched_cur_msec(); /* No IO requests for more than 5 seconds */ return cur_msec < (cntr->rc_active_time + 5000); } +struct core_assignment { + int *ca_assigned; /* Assigned core idx array */ + int ca_sub_off[DSS_XS_MAX]; /* Offset of ca_assigned for XS types */ + int ca_sub_nr[DSS_XS_MAX]; /* Number of assigned for XS types */ +}; + +static void +ca_assign(struct core_assignment *ca, unsigned int xs_type, unsigned idx) +{ + int sub_off, sub_nr; + + D_ASSERT(xs_type < DSS_XS_MAX); + + /* IOFW and OFFLOAD share the same sub-array */ + if (xs_type == DSS_XS_OFFLOAD) + xs_type = DSS_XS_IOFW; + sub_off = ca->ca_sub_off[xs_type]; + sub_nr = ca->ca_sub_nr[xs_type]; + + D_ASSERT(ca->ca_assigned[sub_off + sub_nr] == -1); + ca->ca_assigned[sub_off + sub_nr] = idx; + ca->ca_sub_nr[xs_type] += 1; +} + +static void +ca_free(struct core_assignment *ca) +{ + D_FREE(ca->ca_assigned); + D_FREE(ca); +} + +static struct core_assignment * +ca_alloc(unsigned int xs_nr) +{ + struct core_assignment *ca; + int i, off = 0; + + D_ALLOC_PTR(ca); + if (ca == NULL) + return NULL; + + D_ALLOC_ARRAY(ca->ca_assigned, xs_nr); + if (ca->ca_assigned == NULL) { + D_FREE(ca); + return NULL; + } + + for (i = 0; i < xs_nr; i++) + ca->ca_assigned[i] = -1; + + ca->ca_sub_off[DSS_XS_SYS] = off; + off += 1; + + ca->ca_sub_off[DSS_XS_SWIM] = off; + off += 1; + + ca->ca_sub_off[DSS_XS_DRPC] = off; + off += DRPC_XS_NR; + + ca->ca_sub_off[DSS_XS_VOS] = off; + off += dss_tgt_nr; + + ca->ca_sub_off[DSS_XS_IOFW] = off; + ca->ca_sub_off[DSS_XS_OFFLOAD] = off; + off += dss_tgt_offload_xs_nr; + + ca->ca_sub_off[DSS_XS_SEC] = off; + off += dss_sec_xs_nr; + D_ASSERT(off == xs_nr); + + return ca; +} + +/* Reuse a core form the cores assigned to 'assigned_type' xstream */ +static unsigned +ca_reuse_core(struct core_assignment *ca, unsigned int xs_id, unsigned int assigned_type) +{ + int sub_off, sub_nr, idx; + + sub_off = ca->ca_sub_off[assigned_type]; + sub_nr = ca->ca_sub_nr[assigned_type]; + + D_ASSERT(sub_nr > 0); + if (sub_nr > 1) + sub_off += (xs_id % sub_nr); + + idx = ca->ca_assigned[sub_off]; + D_ASSERT(idx != -1); + + return idx; +} + +/* There are not enough cores for DRPC and SEC xstreams */ +static inline bool +insufficient_cores() +{ + if (dss_numa && dss_numa_node != -1) + return (dss_numa[dss_numa_node].ni_core_nr < DSS_XS_NR_TOTAL); + else + return (dss_core_nr < DSS_XS_NR_TOTAL); +} + static int -dss_start_xs_id(int tag, int xs_id) +dss_start_xs_id(int tag, int xs_id, struct core_assignment *ca) { - hwloc_obj_t obj; + hwloc_obj_t obj; int tgt; - int rc; - int xs_core_offset; - unsigned int idx; - char *cpuset; + int rc; + unsigned idx; + unsigned int xs_type; + char *cpuset; struct dss_numa_info *ninfo; - bool clear = false; - D_DEBUG(DB_TRACE, "start xs_id called for %d.\n", xs_id); + /* + * Rules for assigning cores to xstreams: + * + * - SYS always uses the first core; + * - SWIM always uses dedicated core (see dss_tgt_nr_get()); + * - DRPC uses dedicated core when possible, otherwise, share the SYS core; + * - VOS, IOFW and OFFLOAD xtreams always use dedicated cores; + * - SEC xstreams use dedicated cores when possible, otherwise, share cores + * with IOFW and OFFLOAD. + */ + D_DEBUG(DB_TRACE, "start xs_id called for %d.", xs_id); + + xs_type = xs_id2type(xs_id); /* if we are NUMA aware, use the NUMA information */ if (dss_numa) { if (dss_numa_node == -1) { - tgt = dss_xs2tgt(xs_id); - if (xs_id == 1) { + tgt = xs_id2tgt(xs_id); + if (xs_type == DSS_XS_SYS || xs_type == DSS_XS_DRPC) { + /** Put the system and DRPC on numa 0 */ + ninfo = &dss_numa[0]; + } else if (xs_type == DSS_XS_SWIM) { /** Put swim on first core of numa 1, core 0 */ ninfo = &dss_numa[1]; - } else if (tgt != -1) { + } else if (xs_type == DSS_XS_VOS) { /** Split I/O targets evenly among numa nodes */ ninfo = &dss_numa[tgt / dss_tgt_per_numa_nr]; - } else if (xs_id > 2) { - /** Split helper xstreams evenly among numa nodes */ + } else if (xs_type == DSS_XS_IOFW || xs_type == DSS_XS_OFFLOAD || + xs_type == DSS_XS_SEC) { + /** Split helper & secondary xstreams evenly among numa nodes */ tgt = xs_id - dss_sys_xs_nr - dss_tgt_nr; ninfo = &dss_numa[tgt / dss_offload_per_numa_nr]; } else { - /** Put the system and DRPC on numa 0, core 0 */ - ninfo = &dss_numa[0]; + D_ASSERTF(0, "Invalid XS type %u\n", xs_type); } D_DEBUG(DB_TRACE, "Using numa node %d for XS %d\n", ninfo->ni_idx, xs_id); - - if (xs_id != 0) - clear = true; } else { ninfo = &dss_numa[dss_numa_node]; - if (xs_id > 1 || (xs_id == 0 && dss_core_nr > dss_tgt_nr)) - clear = true; } - idx = hwloc_bitmap_first(ninfo->ni_coremap); - if (idx == -1) { - D_ERROR("No core available for XS: %d\n", xs_id); - return -DER_INVAL; - } - D_DEBUG(DB_TRACE, "Choosing next available core index %d on numa %d.\n", idx, - ninfo->ni_idx); - /* - * All system XS will reuse the first XS' core, but - * the SWIM and DRPC XS will use separate core if enough cores - */ - if (clear) + if (xs_type == DSS_XS_DRPC && insufficient_cores()) { + idx = ca_reuse_core(ca, xs_id, DSS_XS_SYS); + } else if (xs_type == DSS_XS_SEC && insufficient_cores()) { + if (dss_tgt_offload_xs_nr == 0) { + D_ERROR("No avail cores for secondary context\n"); + return -DER_INVAL; + } + idx = ca_reuse_core(ca, xs_id, DSS_XS_IOFW); + } else { + idx = hwloc_bitmap_first(ninfo->ni_coremap); + if (idx == -1) { + D_ERROR("No core available for XS: %d", xs_id); + return -DER_INVAL; + } + D_DEBUG(DB_TRACE, "Choosing next available core index %d.", idx); hwloc_bitmap_clr(ninfo->ni_coremap, idx); - + } } else { D_DEBUG(DB_TRACE, "Using non-NUMA aware core allocation\n"); - /* - * All system XS will use the first core, but - * the SWIM XS will use separate core if enough cores - */ - if (xs_id > 2) - xs_core_offset = xs_id - ((dss_core_nr > dss_tgt_nr) ? 1 : 2); - else if (xs_id == 1) - xs_core_offset = (dss_core_nr > dss_tgt_nr) ? 1 : 0; - else - xs_core_offset = 0; - idx = (xs_core_offset + dss_core_offset) % dss_core_nr; + /* MOD operation on 'dss_core_nr' to support oversubscribe, see dss_tgt_nr_get() */ + switch (xs_type) { + case DSS_XS_SYS: + idx = dss_core_offset % dss_core_nr; + break; + case DSS_XS_SWIM: + idx = (dss_core_offset + 1) % dss_core_nr; + break; + case DSS_XS_DRPC: + if (insufficient_cores()) + idx = dss_core_offset % dss_core_nr; + else + idx = (dss_core_offset + 2) % dss_core_nr; + break; + case DSS_XS_VOS: + case DSS_XS_IOFW: + case DSS_XS_OFFLOAD: + if (insufficient_cores()) + idx = (dss_core_offset + xs_id - 1) % dss_core_nr; + else + idx = (dss_core_offset + xs_id) % dss_core_nr; + break; + case DSS_XS_SEC: + if (insufficient_cores()) { + if (dss_tgt_offload_xs_nr == 0) { + D_ERROR("No avail cores for secondary context\n"); + return -DER_INVAL; + } + idx = ca_reuse_core(ca, xs_id, DSS_XS_IOFW); + } else { + idx = (dss_core_offset + xs_id) % dss_core_nr; + } + break; + default: + D_ASSERTF(0, "Invalid XS type: %u\n", xs_type); + return -DER_INVAL; + } } obj = hwloc_get_obj_by_depth(dss_topo, dss_core_depth, idx); @@ -1084,6 +1312,7 @@ dss_start_xs_id(int tag, int xs_id) D_DEBUG(DB_TRACE, "Using CPU set %s for XS %d\n", cpuset, xs_id); free(cpuset); } + ca_assign(ca, xs_type, idx); rc = dss_start_one_xstream(obj->cpuset, tag, xs_id); if (rc != 0) { @@ -1097,10 +1326,11 @@ dss_start_xs_id(int tag, int xs_id) static int dss_xstreams_init(void) { - char *env; - int rc = 0; - int i, xs_id; - int tags; + struct core_assignment *ca; + char *env; + int rc = 0; + int i, xs_id; + int tags; D_ASSERT(dss_tgt_nr >= 1); @@ -1109,14 +1339,12 @@ dss_xstreams_init(void) D_INFO("ULT prioritizing is disabled.\n"); d_getenv_uint("DAOS_SCHED_RELAX_INTVL", &sched_relax_intvl); - if (sched_relax_intvl == 0 || - sched_relax_intvl > SCHED_RELAX_INTVL_MAX) { - D_WARN("Invalid relax interval %u, set to default %u msecs.\n", - sched_relax_intvl, SCHED_RELAX_INTVL_DEFAULT); + if (sched_relax_intvl == 0 || sched_relax_intvl > SCHED_RELAX_INTVL_MAX) { + D_WARN("Invalid relax interval %u, set to default %u msecs.\n", sched_relax_intvl, + SCHED_RELAX_INTVL_DEFAULT); sched_relax_intvl = SCHED_RELAX_INTVL_DEFAULT; } else { - D_INFO("CPU relax interval is set to %u msecs\n", - sched_relax_intvl); + D_INFO("CPU relax interval is set to %u msecs\n", sched_relax_intvl); } d_agetenv_str(&env, "DAOS_SCHED_RELAX_MODE"); @@ -1128,8 +1356,7 @@ dss_xstreams_init(void) } d_freeenv_str(&env); } - D_INFO("CPU relax mode is set to [%s]\n", - sched_relax_mode2str(sched_relax_mode)); + D_INFO("CPU relax mode is set to [%s]\n", sched_relax_mode2str(sched_relax_mode)); d_getenv_uint("DAOS_SCHED_UNIT_RUNTIME_MAX", &sched_unit_runtime_max); d_getenv_bool("DAOS_SCHED_WATCHDOG_ALL", &sched_watchdog_all); @@ -1150,9 +1377,8 @@ dss_xstreams_init(void) D_INFO("Set DAOS IO chore credits as %u\n", dss_chore_credits); /* start the execution streams */ - D_DEBUG(DB_TRACE, - "%d cores total detected starting %d main xstreams\n", - dss_core_nr, dss_tgt_nr); + D_DEBUG(DB_TRACE, "%d cores total detected starting %d main xstreams\n", dss_core_nr, + dss_tgt_nr); if (dss_numa_node != -1) { D_DEBUG(DB_TRACE, "Detected %d cores on NUMA node %d\n", @@ -1160,11 +1386,17 @@ dss_xstreams_init(void) } xstream_data.xd_xs_nr = DSS_XS_NR_TOTAL; - tags = DAOS_SERVER_TAG - DAOS_TGT_TAG; + ca = ca_alloc(DSS_XS_NR_TOTAL); + if (ca == NULL) { + D_ERROR("Failed to alloc core assignment data\n"); + return -DER_NOMEM; + } + + tags = DAOS_SERVER_TAG - DAOS_TGT_TAG; /* start system service XS */ for (i = 0; i < dss_sys_xs_nr; i++) { xs_id = i; - rc = dss_start_xs_id(tags, xs_id); + rc = dss_start_xs_id(tags, xs_id, ca); if (rc) D_GOTO(out, rc); tags &= ~DAOS_RDB_TAG; @@ -1173,7 +1405,7 @@ dss_xstreams_init(void) /* start main IO service XS */ for (i = 0; i < dss_tgt_nr; i++) { xs_id = DSS_MAIN_XS_ID(i); - rc = dss_start_xs_id(DAOS_SERVER_TAG, xs_id); + rc = dss_start_xs_id(DAOS_SERVER_TAG, xs_id, ca); if (rc) D_GOTO(out, rc); } @@ -1183,7 +1415,7 @@ dss_xstreams_init(void) if (dss_helper_pool) { for (i = 0; i < dss_tgt_offload_xs_nr; i++) { xs_id = dss_sys_xs_nr + dss_tgt_nr + i; - rc = dss_start_xs_id(DAOS_OFF_TAG, xs_id); + rc = dss_start_xs_id(DAOS_OFF_TAG, xs_id, ca); if (rc) D_GOTO(out, rc); } @@ -1194,10 +1426,9 @@ dss_xstreams_init(void) for (i = 0; i < dss_tgt_nr; i++) { int j; - for (j = 0; j < dss_tgt_offload_xs_nr / - dss_tgt_nr; j++) { + for (j = 0; j < dss_tgt_offload_xs_nr / dss_tgt_nr; j++) { xs_id = DSS_MAIN_XS_ID(i) + j + 1; - rc = dss_start_xs_id(DAOS_OFF_TAG, xs_id); + rc = dss_start_xs_id(DAOS_OFF_TAG, xs_id, ca); if (rc) D_GOTO(out, rc); } @@ -1205,9 +1436,20 @@ dss_xstreams_init(void) } } - D_DEBUG(DB_TRACE, "%d execution streams successfully started " - "(first core %d)\n", dss_tgt_nr, dss_core_offset); + /* Start secondary cart context XS if any */ + for (i = 0; i < dss_sec_xs_nr; i++) { + xs_id = dss_sys_xs_nr + dss_tgt_nr + dss_tgt_offload_xs_nr + i; + rc = dss_start_xs_id(DAOS_OFF_TAG, xs_id, ca); + if (rc) + D_GOTO(out, rc); + } + + D_DEBUG(DB_TRACE, + "%d execution streams successfully started " + "(first core %d)\n", + dss_tgt_nr, dss_core_offset); out: + ca_free(ca); return rc; } @@ -1234,10 +1476,10 @@ dss_srv_tls_fini(int tags, void *data) } struct dss_module_key daos_srv_modkey = { - .dmk_tags = DAOS_SERVER_TAG, - .dmk_index = -1, - .dmk_init = dss_srv_tls_init, - .dmk_fini = dss_srv_tls_fini, + .dmk_tags = DAOS_SERVER_TAG, + .dmk_index = -1, + .dmk_init = dss_srv_tls_init, + .dmk_fini = dss_srv_tls_fini, }; /** TODO: use daos checksum library to offload checksum calculation */ @@ -1262,9 +1504,8 @@ compute_checksum_acc(void *args) int dss_acc_offload(struct dss_acc_task *at_args) { - - int rc = 0; - int tid; + int rc = 0; + int tid; /** * Currently just launching it in this stream, @@ -1284,12 +1525,8 @@ dss_acc_offload(struct dss_acc_task *at_args) switch (at_args->at_offload_type) { case DSS_OFFLOAD_ULT: - rc = dss_ult_execute(compute_checksum_ult, - at_args->at_params, - NULL /* user-cb */, - NULL /* user-cb args */, - DSS_XS_OFFLOAD, tid, - 0); + rc = dss_ult_execute(compute_checksum_ult, at_args->at_params, NULL /* user-cb */, + NULL /* user-cb args */, DSS_XS_OFFLOAD, tid, 0); break; case DSS_OFFLOAD_ACC: /** calls to offload to FPGA*/ @@ -1365,7 +1602,7 @@ dss_srv_fini(bool force) case XD_INIT_DRPC: rc = drpc_listener_fini(); if (rc != 0) - D_ERROR("failed to finalize dRPC listener: "DF_RC"\n", DP_RC(rc)); + D_ERROR("failed to finalize dRPC listener: " DF_RC "\n", DP_RC(rc)); /* fall through */ case XD_INIT_XSTREAMS: dss_xstreams_fini(force); @@ -1402,8 +1639,8 @@ dss_sys_db_init() int dss_srv_init(void) { - int rc; - bool started = true; + int rc; + bool started = true; xstream_data.xd_init_step = XD_INIT_NONE; xstream_data.xd_ult_signal = false; @@ -1420,7 +1657,7 @@ dss_srv_init(void) rc = ABT_mutex_create(&xstream_data.xd_mutex); if (rc != ABT_SUCCESS) { rc = dss_abterr2der(rc); - D_ERROR("Failed to create XS mutex: "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to create XS mutex: " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } xstream_data.xd_init_step = XD_INIT_MUTEX; @@ -1428,7 +1665,7 @@ dss_srv_init(void) rc = ABT_cond_create(&xstream_data.xd_ult_init); if (rc != ABT_SUCCESS) { rc = dss_abterr2der(rc); - D_ERROR("Failed to create XS ULT cond(1): "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to create XS ULT cond(1): " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } xstream_data.xd_init_step = XD_INIT_ULT_INIT; @@ -1436,7 +1673,7 @@ dss_srv_init(void) rc = ABT_cond_create(&xstream_data.xd_ult_barrier); if (rc != ABT_SUCCESS) { rc = dss_abterr2der(rc); - D_ERROR("Failed to create XS ULT cond(2): "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to create XS ULT cond(2): " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } xstream_data.xd_init_step = XD_INIT_ULT_BARRIER; @@ -1451,7 +1688,7 @@ dss_srv_init(void) rc = dss_sys_db_init(); if (rc != 0) { - D_ERROR("Failed to initialize local DB: "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to initialize local DB: " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } xstream_data.xd_init_step = XD_INIT_SYS_DB; @@ -1464,7 +1701,7 @@ dss_srv_init(void) xstream_data.xd_init_step = XD_INIT_XSTREAMS; if (rc != 0) { - D_ERROR("Failed to start XS: "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to start XS: " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } @@ -1474,7 +1711,7 @@ dss_srv_init(void) /* start up drpc listener */ rc = drpc_listener_init(); if (rc != 0) { - D_ERROR("Failed to start dRPC listener: "DF_RC"\n", DP_RC(rc)); + D_ERROR("Failed to start dRPC listener: " DF_RC "\n", DP_RC(rc)); D_GOTO(failed, rc); } xstream_data.xd_init_step = XD_INIT_DRPC; @@ -1505,14 +1742,14 @@ set_draining(void *arg) void dss_srv_set_shutting_down(void) { - int n = dss_xstream_cnt(); - int i; - int rc; + int n = dss_xstream_cnt(); + int i; + int rc; /* Could be parallel... */ for (i = 0; i < n; i++) { - struct dss_xstream *dx = dss_get_xstream(i); - ABT_task task; + struct dss_xstream *dx = dss_get_xstream(i); + ABT_task task; rc = ABT_task_create(dx->dx_pools[DSS_POOL_GENERIC], set_draining, NULL /* arg */, &task); @@ -1525,10 +1762,10 @@ dss_srv_set_shutting_down(void) void dss_dump_ABT_state(FILE *fp) { - int rc, num_pools, i, idx; - struct dss_xstream *dx; - ABT_sched sched; - ABT_pool pools[DSS_POOL_CNT]; + int rc, num_pools, i, idx; + struct dss_xstream *dx; + ABT_sched sched; + ABT_pool pools[DSS_POOL_CNT]; /* print Argobots config first */ fprintf(fp, " == ABT config ==\n"); @@ -1548,18 +1785,18 @@ dss_dump_ABT_state(FILE *fp) rc = ABT_info_print_xstream(fp, dx->dx_xstream); if (rc != ABT_SUCCESS) D_ERROR("ABT_info_print_xstream() error, rc = %d, for " - "DAOS xstream %p, ABT xstream %p\n", rc, dx, - dx->dx_xstream); + "DAOS xstream %p, ABT xstream %p\n", + rc, dx, dx->dx_xstream); /* one progress ULT per xstream */ if (dx->dx_progress != ABT_THREAD_NULL) { - fprintf(fp, "== ES (%p) progress ULT (%p) ==\n", - dx->dx_xstream, dx->dx_progress); + fprintf(fp, "== ES (%p) progress ULT (%p) ==\n", dx->dx_xstream, + dx->dx_progress); rc = ABT_info_print_thread(fp, dx->dx_progress); if (rc != ABT_SUCCESS) D_ERROR("ABT_info_print_thread() error, " "rc = %d, for DAOS xstream %p, ABT " - "xstream %p, progress ULT %p\n", rc, dx, - dx->dx_xstream, dx->dx_progress); + "xstream %p, progress ULT %p\n", + rc, dx, dx->dx_xstream, dx->dx_progress); /* XXX * do not print stack content as if unwiding with * libunwind is enabled current implementation runs @@ -1578,8 +1815,8 @@ dss_dump_ABT_state(FILE *fp) rc = ABT_xstream_get_main_sched(dx->dx_xstream, &sched); if (rc != ABT_SUCCESS) { D_ERROR("ABT_xstream_get_main_sched() error, rc = %d, " - "for DAOS xstream %p, ABT xstream %p\n", rc, dx, - dx->dx_xstream); + "for DAOS xstream %p, ABT xstream %p\n", + rc, dx, dx->dx_xstream); } else if (sched != dx->dx_sched) { /* it's unexpected, unless DAOS will use stacked * schedulers at some point of time, but try to @@ -1592,8 +1829,8 @@ dss_dump_ABT_state(FILE *fp) if (rc != ABT_SUCCESS) D_ERROR("ABT_info_print_sched() error, rc = " "%d, for DAOS xstream %p, ABT xstream " - "%p, sched %p\n", rc, dx, - dx->dx_xstream, sched); + "%p, sched %p\n", + rc, dx, dx->dx_xstream, sched); } rc = ABT_info_print_sched(fp, dx->dx_sched); if (rc != ABT_SUCCESS) @@ -1610,9 +1847,8 @@ dss_dump_ABT_state(FILE *fp) } if (num_pools != DSS_POOL_CNT) D_WARN("DAOS xstream %p, ABT xstream %p, sched %p " - "number of pools %d != %d\n", dx, - dx->dx_xstream, dx->dx_sched, num_pools, - DSS_POOL_CNT); + "number of pools %d != %d\n", + dx, dx->dx_xstream, dx->dx_sched, num_pools, DSS_POOL_CNT); rc = ABT_sched_get_pools(dx->dx_sched, num_pools, 0, pools); if (rc != ABT_SUCCESS) { D_ERROR("ABT_sched_get_pools() error, rc = %d, for " @@ -1624,22 +1860,21 @@ dss_dump_ABT_state(FILE *fp) fprintf(fp, "== per POOL (%p) details ==\n", pools[i]); if (pools[i] == ABT_POOL_NULL) { D_WARN("DAOS xstream %p, ABT xstream %p, " - "sched %p, no pool[%d]\n", dx, - dx->dx_xstream, dx->dx_sched, i); + "sched %p, no pool[%d]\n", + dx, dx->dx_xstream, dx->dx_sched, i); continue; } if (pools[i] != dx->dx_pools[i]) { D_WARN("DAOS xstream pool[%d]=%p differs from " "ABT registered one %p for sched %p\n", - i, dx->dx_pools[i], pools[i], - dx->dx_sched); + i, dx->dx_pools[i], pools[i], dx->dx_sched); } rc = ABT_info_print_pool(fp, pools[i]); if (rc != ABT_SUCCESS) D_ERROR("ABT_info_print_pool() error, rc = %d, " "for DAOS xstream %p, ABT xstream %p, " - "sched %p, pool[%d]\n", rc, dx, - dx->dx_xstream, dx->dx_sched, i); + "sched %p, pool[%d]\n", + rc, dx, dx->dx_xstream, dx->dx_sched, i); /* XXX * same concern than with ABT_info_print_thread_stack() * before diff --git a/src/engine/srv_internal.h b/src/engine/srv_internal.h index 2e1c83efc95..7012a39ce62 100644 --- a/src/engine/srv_internal.h +++ b/src/engine/srv_internal.h @@ -109,8 +109,7 @@ struct dss_xstream { /* Cart progress timeout in micro-seconds */ unsigned int dx_timeout; bool dx_main_xs; /* true for main XS */ - bool dx_comm; /* true with cart context */ - bool dx_iofw; /* true for DSS_XS_IOFW XS */ + bool dx_comm; /* true with primary cart context */ bool dx_dsc_started; /* DSC progress ULT started */ struct mem_stats dx_mem_stats; /* memory usages stats on this xstream */ bool dx_progress_started; /* Network poll started */ @@ -156,7 +155,9 @@ extern int dss_numa_node; /** Number of active numa nodes (only > 1 if multi-socket mode is enabled) */ extern int dss_numa_nr; /** number of system XS */ -extern unsigned int dss_sys_xs_nr; +extern unsigned int dss_sys_xs_nr; +/** Number of secondary cart context XS */ +extern unsigned int dss_sec_xs_nr; /** Flag of helper XS as a pool */ extern bool dss_helper_pool; /** Cached numa information */ @@ -335,7 +336,7 @@ void ds_iv_fini(void); /** Total number of XS */ #define DSS_XS_NR_TOTAL \ - (dss_sys_xs_nr + dss_tgt_nr + dss_tgt_offload_xs_nr) + (dss_sys_xs_nr + dss_tgt_nr + dss_tgt_offload_xs_nr + dss_sec_xs_nr) /** Total number of cart contexts created */ #define DSS_CTX_NR_TOTAL \ (DAOS_TGT0_OFFSET + dss_tgt_nr + \ @@ -352,33 +353,6 @@ void ds_iv_fini(void); #define DSS_IO_XS_NAME_FMT "daos_io_%d" #define DSS_OFFLOAD_XS_NAME_FMT "daos_off_%d" -/** - * get the VOS target ID of xstream. - * - * \param[in] xs_id xstream ID - * - * \return VOS target ID (-1 for system XS). - */ -static inline int -dss_xs2tgt(int xs_id) -{ - D_ASSERTF(xs_id >= 0 && xs_id < DSS_XS_NR_TOTAL, - "invalid xs_id %d, dss_tgt_nr %d, " - "dss_tgt_offload_xs_nr %d.\n", - xs_id, dss_tgt_nr, dss_tgt_offload_xs_nr); - if (dss_helper_pool) { - if (xs_id < dss_sys_xs_nr || - xs_id >= dss_sys_xs_nr + dss_tgt_nr) - return -1; - return xs_id - dss_sys_xs_nr; - } - - if (xs_id < dss_sys_xs_nr) - return -1; - return (xs_id - dss_sys_xs_nr) / - (dss_tgt_offload_xs_nr / dss_tgt_nr + 1); -} - static inline bool dss_xstream_has_nvme(struct dss_xstream *dx) { diff --git a/src/engine/tests/drpc_client_tests.c b/src/engine/tests/drpc_client_tests.c index c044a5a5cd3..1d40f6e12da 100644 --- a/src/engine/tests/drpc_client_tests.c +++ b/src/engine/tests/drpc_client_tests.c @@ -30,6 +30,7 @@ const char *dss_socket_dir = "/my/fake/path"; char *drpc_listener_socket_path = "/fake/listener.sock"; char dss_hostname[DSS_HOSTNAME_MAX_LEN] = "foo-host"; +unsigned int dss_sec_xs_nr = 1; /* DAOS internal globals - arbitrary values okay */ uint32_t dss_tgt_offload_xs_nr = 3; diff --git a/src/include/cart/api.h b/src/include/cart/api.h index 274edbc644e..f225d09301a 100644 --- a/src/include/cart/api.h +++ b/src/include/cart/api.h @@ -167,6 +167,29 @@ int crt_context_create_on_iface(const char *iface_name, crt_context_t *crt_ctx); +/** + * Create CRT transport context on one of secondary providers. + * + * \param[out] crt_ctx created CRT transport context + * \param[in] idx Currently unused. Specifies which + * of the secondary providers to use. + * + * \return DER_SUCCESS on success, negative value if error + */ +int +crt_context_create_secondary(crt_context_t *crt_ctx, int idx); + +/** + * Check whether specified context is primary or secondary. + * + * \param[in] crt_ctx CRT transport context + * + * \return true if primary, false otherwise + */ +bool +crt_context_is_primary(crt_context_t crt_ctx); + + /** * Set the timeout value for all RPC requests created on the specified context. * Setting the timeout after crt_req_create() call will not affect already @@ -515,6 +538,18 @@ crt_req_get(crt_rpc_t *rpc) int crt_req_src_rank_get(crt_rpc_t *req, d_rank_t *rank); +/** + * Return whether originator runs from a primary provider or not + * + * \param[in] req Pointer to RPC request + * \param[out] result Returned result + * + * \return DER_SUCCESS on success or error + * on failure + */ +int +crt_req_src_provider_is_primary(crt_rpc_t *req, bool *result); + /** * Return destination rank * @@ -2077,6 +2112,30 @@ crt_group_rank_remove(crt_group_t *group, d_rank_t rank); */ int crt_self_uri_get(int tag, char **uri); + +/** + * Retrieve a secondary uri of self for the specified tag. + * The uri must be freed by the user using D_FREE(). + * + * \param[in] idx Secondary provider index + * \param[out] uri Returned uri string This is a NULL terminated + * string of size up to CRT_ADDR_STR_MAX_LEN + * (including the trailing NULL). Must be freed by + * the user. + * + * \return DER_SUCCESS on success, negative value + * on failure. + */ +int crt_self_uri_get_secondary(int idx, char **uri); + +/** + * Returns number of secondary providers initialized. + * + * \return Number of secondary providers. + */ +int +crt_get_nr_secondary_providers(void); + /** * Retrieve incarnation of self. * @@ -2087,6 +2146,24 @@ int crt_self_uri_get(int tag, char **uri); */ int crt_self_incarnation_get(uint64_t *incarnation); +/** + * Sets the number of the remote tags for the secondary provider. + * + * Each tag corresponds to a remote context or an endpoint. + * By default, CaRT assumes 1 remote tag for each secondary provider. + * + * When a number of tags is set to more than 1 for any secondary provider then + * CaRT will round-robin across all secondary provider tags instead of defaulting + * to endpoint0 for secondary provider communications. + * + * \param[in] idx Secondary provider index. Currently only 0 is supported. + * \param[in] num_tags Number of remote tags to set. + * + * \return DER_SUCCESS on success, negative value + * on failure. + */ +int crt_nr_secondary_remote_tags_set(int idx, int num_tags); + /** * Retrieve list of ranks that belong to the specified group. * diff --git a/src/include/daos/drpc.pb-c.h b/src/include/daos/drpc.pb-c.h index 6083131d433..d837e6721ee 100644 --- a/src/include/daos/drpc.pb-c.h +++ b/src/include/daos/drpc.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1003003 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/src/include/daos/rpc.h b/src/include/daos/rpc.h index a92a6752c54..cfbcfe75e40 100644 --- a/src/include/daos/rpc.h +++ b/src/include/daos/rpc.h @@ -219,7 +219,7 @@ struct daos_req_comm_out { /** DAOS_TGT0_OFFSET is target 0's cart context offset */ -#define DAOS_TGT0_OFFSET (2) +#define DAOS_TGT0_OFFSET (2) /* 0 for SYS0, 1 for SWIM */ /** The cart context index of target index */ #define DAOS_IO_CTX_ID(tgt_idx) ((tgt_idx) + DAOS_TGT0_OFFSET) diff --git a/src/include/daos_srv/container.h b/src/include/daos_srv/container.h index 510ffc70ac4..4f52dcfbb0e 100644 --- a/src/include/daos_srv/container.h +++ b/src/include/daos_srv/container.h @@ -213,7 +213,7 @@ void ds_cont_hdl_put(struct ds_cont_hdl *hdl); void ds_cont_hdl_get(struct ds_cont_hdl *hdl); int ds_cont_close_by_pool_hdls(uuid_t pool_uuid, uuid_t *pool_hdls, - int n_pool_hdls, crt_context_t ctx); + int n_pool_hdls); int ds_cont_local_close(uuid_t cont_hdl_uuid); int ds_cont_child_start_all(struct ds_pool_child *pool_child); diff --git a/src/include/daos_srv/daos_engine.h b/src/include/daos_srv/daos_engine.h index c32b580db47..925c4fcbbf4 100644 --- a/src/include/daos_srv/daos_engine.h +++ b/src/include/daos_srv/daos_engine.h @@ -447,6 +447,9 @@ enum dss_xs_type { DSS_XS_SWIM = 4, /** drpc listener */ DSS_XS_DRPC = 5, + /** secondary cart context */ + DSS_XS_SEC = 6, + DSS_XS_MAX = 7, }; int dss_parameters_set(unsigned int key_id, uint64_t value); diff --git a/src/mgmt/cli_mgmt.c b/src/mgmt/cli_mgmt.c index 61a8c088a1e..19eced8f604 100644 --- a/src/mgmt/cli_mgmt.c +++ b/src/mgmt/cli_mgmt.c @@ -311,10 +311,7 @@ get_attach_info(const char *name, bool all_ranks, struct dc_mgmt_sys_info *info, char *domain = NULL; int rc; - D_DEBUG(DB_MGMT, "getting attach info for %s\n", name); - /* Connect to daos_agent. */ - D_ASSERT(dc_agent_sockpath != NULL); rc = drpc_connect(dc_agent_sockpath, &ctx); if (rc != -DER_SUCCESS) { D_ERROR("failed to connect to %s " DF_RC "\n", diff --git a/src/mgmt/smd.pb-c.c b/src/mgmt/smd.pb-c.c index c89dbef31e5..359a535fe6d 100644 --- a/src/mgmt/smd.pb-c.c +++ b/src/mgmt/smd.pb-c.c @@ -1784,7 +1784,7 @@ static const ProtobufCFieldDescriptor ctl__smd_device__field_descriptors[14] = offsetof(Ctl__SmdDevice, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2079,7 +2079,7 @@ static const ProtobufCFieldDescriptor ctl__smd_pool_resp__pool__field_descriptor offsetof(Ctl__SmdPoolResp__Pool, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2091,7 +2091,7 @@ static const ProtobufCFieldDescriptor ctl__smd_pool_resp__pool__field_descriptor offsetof(Ctl__SmdPoolResp__Pool, blobs), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; @@ -2284,7 +2284,7 @@ static const ProtobufCFieldDescriptor ctl__smd_query_resp__pool__field_descripto offsetof(Ctl__SmdQueryResp__Pool, tgt_ids), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { @@ -2296,7 +2296,7 @@ static const ProtobufCFieldDescriptor ctl__smd_query_resp__pool__field_descripto offsetof(Ctl__SmdQueryResp__Pool, blobs), NULL, NULL, - 0, /* flags */ + 0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; diff --git a/src/mgmt/smd.pb-c.h b/src/mgmt/smd.pb-c.h index 23c2823b6cc..89a7c51aa98 100644 --- a/src/mgmt/smd.pb-c.h +++ b/src/mgmt/smd.pb-c.h @@ -10,7 +10,7 @@ PROTOBUF_C__BEGIN_DECLS #if PROTOBUF_C_VERSION_NUMBER < 1003000 # error This file was generated by a newer version of protoc-c which is incompatible with your libprotobuf-c headers. Please update your headers. -#elif 1003000 < PROTOBUF_C_MIN_COMPILER_VERSION +#elif 1003003 < PROTOBUF_C_MIN_COMPILER_VERSION # error This file was generated by an older version of protoc-c which is incompatible with your libprotobuf-c headers. Please regenerate this file with a newer version of protoc-c. #endif diff --git a/src/object/srv_internal.h b/src/object/srv_internal.h index 3d3fbc15447..240e88e7301 100644 --- a/src/object/srv_internal.h +++ b/src/object/srv_internal.h @@ -110,6 +110,7 @@ struct obj_bulk_args { int bulks_inflight; int result; bool inited; + ABT_mutex lock; }; struct obj_tgt_query_args { diff --git a/src/object/srv_obj.c b/src/object/srv_obj.c index 2ecd52f1a0f..d20220c2dba 100644 --- a/src/object/srv_obj.c +++ b/src/object/srv_obj.c @@ -236,6 +236,89 @@ obj_rw_reply(crt_rpc_t *rpc, int status, uint64_t epoch, bool release_input, } } +static inline int +obj_bulk_args_fini(struct obj_bulk_args *args) +{ + int rc, *status; + + D_ASSERT(args->inited); + rc = ABT_eventual_wait(args->eventual, (void **)&status); + if (rc) + rc = dss_abterr2der(rc); + else + rc = *status; + + ABT_eventual_free(&args->eventual); + ABT_mutex_free(&args->lock); + + return rc; +} + +static inline int +obj_bulk_args_init(struct obj_bulk_args *args) +{ + int rc, *status; + + rc = ABT_eventual_create(sizeof(*status), &args->eventual); + if (rc != ABT_SUCCESS) + return dss_abterr2der(rc); + + rc = ABT_mutex_create(&args->lock); + if (rc != ABT_SUCCESS) { + ABT_eventual_free(&args->eventual); + return dss_abterr2der(rc); + } + + args->inited = true; + args->bulks_inflight = 1; + args->result = 0; + return 0; +} + +/* Get the original cart context that client intended to send to */ +static void * +rpc2orig_ctx(crt_rpc_t *rpc, bool *is_primary) +{ + int rc; + + /* + * TODO: + * For forwarded RPC (server always uses primary context to create forward RPC), + * we need some new cart API to query if the RPC is originated from a secondary + * client, considering multiple secondary contexts need be supported, the new + * API may need to return context ID as well. Then IO engine will be able to get + * the proper secondary context by 'is_primary' and 'context id'. + */ + rc = crt_req_src_provider_is_primary(rpc, is_primary); + if (rc) { + D_ERROR("Failed to query provider info. "DF_RC"\n", DP_RC(rc)); + *is_primary = true; + } + + return rpc->cr_ctx; +} + +static void +obj_bulk_inflights(struct obj_bulk_args *args, crt_rpc_t *rpc, int val) +{ + bool is_primary; + + D_ASSERT(val == 1 || val == -1); + rpc2orig_ctx(rpc, &is_primary); + + if (!is_primary) + ABT_mutex_lock(args->lock); + + D_ASSERT(args->bulks_inflight > 0); + args->bulks_inflight += val; + + if (!is_primary) + ABT_mutex_unlock(args->lock); + + if (args->bulks_inflight == 0) + ABT_eventual_set(args->eventual, &args->result, sizeof(args->result)); +} + static int obj_bulk_comp_cb(const struct crt_bulk_cb_info *cb_info) { @@ -256,11 +339,7 @@ obj_bulk_comp_cb(const struct crt_bulk_cb_info *cb_info) if (arg->result == 0) arg->result = cb_info->bci_rc; - D_ASSERT(arg->bulks_inflight > 0); - arg->bulks_inflight--; - if (arg->bulks_inflight == 0) - ABT_eventual_set(arg->eventual, &arg->result, - sizeof(arg->result)); + obj_bulk_inflights(arg, rpc, -1); crt_req_decref(rpc); return cb_info->bci_rc; @@ -282,6 +361,13 @@ bulk_cp(const struct crt_bulk_cb_info *cb_info) static inline int cached_bulk_cp(const struct crt_bulk_cb_info *cb_info) { + struct crt_bulk_desc *bulk_desc = cb_info->bci_bulk_desc; + crt_rpc_t *rpc = bulk_desc->bd_rpc; + bool is_primary; + + rpc2orig_ctx(rpc, &is_primary); + D_ASSERT(is_primary); + return obj_bulk_comp_cb(cb_info); } @@ -324,6 +410,26 @@ obj_bulk_bypass(d_sg_list_t *sgl, crt_bulk_op_t bulk_op) } } +/* Get the proper cart context for local bulk handle creation */ +static inline void * +rpc2bulk_ctx(crt_rpc_t *rpc, bool create) +{ + void *orig_ctx; + bool is_primary; + + /* + * - When the bulk is on primary provider, return primary cart context; + * - When the bulk is on secondary provider, return secondary cart context + * if 'create' is true, otherwise, return NULL since we don't use bulk + * cache for secondary provider now; + */ + orig_ctx = rpc2orig_ctx(rpc, &is_primary); + if (is_primary || create) + return orig_ctx; + + return NULL; +} + #define MAX_BULK_IOVS 1024 #define BULK_DELAY_MAX 3000 #define BULK_DELAY_STEP 1000 @@ -438,7 +544,7 @@ bulk_transfer_sgl(daos_handle_t ioh, crt_rpc_t *rpc, crt_bulk_t remote_bulk, bulk_iovs += sgl_sent.sg_nr; again: - rc = crt_bulk_create(rpc->cr_ctx, &sgl_sent, bulk_perm, + rc = crt_bulk_create(rpc2bulk_ctx(rpc, true), &sgl_sent, bulk_perm, &local_bulk); if (rc == -DER_NOMEM) { if (delay_tot >= BULK_DELAY_MAX) { @@ -487,8 +593,8 @@ bulk_transfer_sgl(daos_handle_t ioh, crt_rpc_t *rpc, crt_bulk_t remote_bulk, bulk_desc.bd_remote_off = remote_off; bulk_desc.bd_local_off = local_off; + obj_bulk_inflights(p_arg, rpc, 1); p_arg->bulk_size += length; - p_arg->bulks_inflight++; if (bulk_bind) rc = crt_bulk_bind_transfer(&bulk_desc, cached_bulk ? cached_bulk_cp : bulk_cp, p_arg, @@ -499,7 +605,7 @@ bulk_transfer_sgl(daos_handle_t ioh, crt_rpc_t *rpc, crt_bulk_t remote_bulk, &bulk_opid); if (rc < 0) { D_ERROR("crt_bulk_transfer %d error " DF_RC "\n", sgl_idx, DP_RC(rc)); - p_arg->bulks_inflight--; + obj_bulk_inflights(p_arg, rpc, -1); if (!cached_bulk) crt_bulk_free(local_bulk); crt_req_decref(rpc); @@ -526,7 +632,7 @@ obj_bulk_transfer(crt_rpc_t *rpc, crt_bulk_op_t bulk_op, bool bulk_bind, crt_bul int sgl_nr, int bulk_nr, struct obj_bulk_args *p_arg) { struct obj_bulk_args arg = { 0 }; - int i, rc, *status, ret; + int i, rc; int skip_nr = 0; bool async = true; uint64_t time = daos_get_ntime(); @@ -546,17 +652,14 @@ obj_bulk_transfer(crt_rpc_t *rpc, crt_bulk_op_t bulk_op, bool bulk_bind, crt_bul async = false; } - rc = ABT_eventual_create(sizeof(*status), &p_arg->eventual); - if (rc != 0) - return dss_abterr2der(rc); + rc = obj_bulk_args_init(p_arg); + if (rc) + return rc; - p_arg->inited = true; D_DEBUG(DB_IO, "bulk_op %d, sgl_nr %d, bulk_nr %d\n", bulk_op, sgl_nr, bulk_nr); - p_arg->bulks_inflight++; - if (daos_handle_is_valid(ioh)) { - rc = vos_dedup_verify_init(ioh, rpc->cr_ctx, CRT_BULK_RW); + rc = vos_dedup_verify_init(ioh, rpc2bulk_ctx(rpc, false), CRT_BULK_RW); if (rc) { D_ERROR("Dedup verify prep failed. "DF_RC"\n", DP_RC(rc)); @@ -623,17 +726,14 @@ obj_bulk_transfer(crt_rpc_t *rpc, crt_bulk_op_t bulk_op, bool bulk_bind, crt_bul skip_nr, sgl_nr, bulk_nr); done: - if (--(p_arg->bulks_inflight) == 0) - ABT_eventual_set(p_arg->eventual, &rc, sizeof(rc)); + if (rc) + p_arg->result = rc; + obj_bulk_inflights(p_arg, rpc, -1); if (async) return rc; - ret = ABT_eventual_wait(p_arg->eventual, (void **)&status); - if (rc == 0) - rc = ret ? dss_abterr2der(ret) : *status; - - ABT_eventual_free(&p_arg->eventual); + rc = obj_bulk_args_fini(p_arg); if (rc == 0) obj_update_latency(opc_get(rpc->cr_opc), BULK_LATENCY, daos_get_ntime() - time, @@ -1704,7 +1804,8 @@ obj_local_rw_internal(crt_rpc_t *rpc, struct obj_io_context *ioc, daos_iod_t *io time = daos_get_ntime(); biod = vos_ioh2desc(ioh); - rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rma ? rpc->cr_ctx : NULL, CRT_BULK_RW); + rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rma ? rpc2bulk_ctx(rpc, false) : NULL, + CRT_BULK_RW); if (rc) { D_ERROR(DF_UOID " bio_iod_prep failed: " DF_RC "\n", DP_UOID(orw->orw_oid), DP_RC(rc)); @@ -2570,7 +2671,7 @@ ds_obj_ec_rep_handler(crt_rpc_t *rpc) goto out_agg; } biod = vos_ioh2desc(ioh); - rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rpc->cr_ctx, CRT_BULK_RW); + rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rpc2bulk_ctx(rpc, false), CRT_BULK_RW); if (rc) { D_ERROR(DF_UOID " bio_iod_prep failed: " DF_RC "\n", DP_UOID(oer->er_oid), DP_RC(rc)); @@ -2651,8 +2752,7 @@ ds_obj_ec_agg_handler(crt_rpc_t *rpc) goto out_agg; } biod = vos_ioh2desc(ioh); - rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rpc->cr_ctx, - CRT_BULK_RW); + rc = bio_iod_prep(biod, BIO_CHK_TYPE_IO, rpc2bulk_ctx(rpc, false), CRT_BULK_RW); if (rc) { D_ERROR(DF_UOID " bio_iod_prep failed: " DF_RC "\n", DP_UOID(oea->ea_oid), DP_RC(rc)); @@ -4787,8 +4887,8 @@ ds_cpd_handle_one(crt_rpc_t *rpc, struct daos_cpd_sub_head *dcsh, struct daos_cp biods[i] = vos_ioh2desc(iohs[i]); rc = bio_iod_prep(biods[i], BIO_CHK_TYPE_IO, - dcu->dcu_flags & ORF_CPD_BULK ? - rpc->cr_ctx : NULL, CRT_BULK_RW); + dcu->dcu_flags & ORF_CPD_BULK ? rpc2bulk_ctx(rpc, false) : NULL, + CRT_BULK_RW); if (rc != 0) { D_ERROR("bio_iod_prep failed for obj "DF_UOID ", DTX "DF_DTI": "DF_RC"\n", @@ -4838,20 +4938,10 @@ ds_cpd_handle_one(crt_rpc_t *rpc, struct daos_cpd_sub_head *dcsh, struct daos_cp /* P3: bulk data transafer. */ for (i = 0; i < dcde->dcde_write_cnt && rma_idx < rma; i++) { - int *status; - if (!bulks[i].inited) continue; - rc = ABT_eventual_wait(bulks[i].eventual, (void **)&status); - if (rc != 0) - rc = dss_abterr2der(rc); - if (rc == 0 && *status != 0) - rc = *status; - if (rc == 0 && bulks[i].result != 0) - rc = bulks[i].result; - - ABT_eventual_free(&bulks[i].eventual); + rc = obj_bulk_args_fini(&bulks[i]); bio_iod_flush(biods[i]); rma_idx++; @@ -4978,6 +5068,7 @@ ds_cpd_handle_one(crt_rpc_t *rpc, struct daos_cpd_sub_head *dcsh, struct daos_cp if (!bulks[i].inited) continue; + obj_bulk_args_fini(&bulks[i]); if (bulks[i].eventual != ABT_EVENTUAL_NULL) { ABT_eventual_wait(bulks[i].eventual, NULL); ABT_eventual_free(&bulks[i].eventual); diff --git a/src/pool/srv_pool.c b/src/pool/srv_pool.c index c2a59cec0a9..5c30f9e6648 100644 --- a/src/pool/srv_pool.c +++ b/src/pool/srv_pool.c @@ -73,18 +73,18 @@ ds_pool_get_vos_df_version_default(void) return v; } -#define DUP_OP_MIN_RDB_SIZE (1 << 30) +#define DUP_OP_MIN_RDB_SIZE (1 << 30) /* Pool service crt event */ struct pool_svc_event { - d_rank_t psv_rank; - uint64_t psv_incarnation; - enum crt_event_source psv_src; - enum crt_event_type psv_type; + d_rank_t psv_rank; + uint64_t psv_incarnation; + enum crt_event_source psv_src; + enum crt_event_type psv_type; }; -#define DF_PS_EVENT "rank=%u inc="DF_U64" src=%d type=%d" -#define DP_PS_EVENT(e) e->psv_rank, e->psv_incarnation, e->psv_src, e->psv_type +#define DF_PS_EVENT "rank=%u inc=" DF_U64 " src=%d type=%d" +#define DP_PS_EVENT(e) e->psv_rank, e->psv_incarnation, e->psv_src, e->psv_type /* * Pool service crt event set @@ -124,12 +124,12 @@ struct pool_svc_events { /* Pool service schedule state */ struct pool_svc_sched { - ABT_mutex psc_mutex; /* only for psc_cv */ - ABT_cond psc_cv; - bool psc_in_progress; - bool psc_canceled; - void *psc_arg; - int psc_rc; + ABT_mutex psc_mutex; /* only for psc_cv */ + ABT_cond psc_cv; + bool psc_in_progress; + bool psc_canceled; + void *psc_arg; + int psc_rc; }; static int @@ -149,9 +149,9 @@ sched_init(struct pool_svc_sched *sched) } sched->psc_in_progress = false; - sched->psc_canceled = false; - sched->psc_arg = NULL; - sched->psc_rc = 0; + sched->psc_canceled = false; + sched->psc_arg = NULL; + sched->psc_rc = 0; return 0; } @@ -166,16 +166,16 @@ static void sched_begin(struct pool_svc_sched *sched, void *arg) { sched->psc_in_progress = true; - sched->psc_canceled = false; - sched->psc_arg = arg; - sched->psc_rc = 0; + sched->psc_canceled = false; + sched->psc_arg = arg; + sched->psc_rc = 0; } static void sched_end(struct pool_svc_sched *sched) { sched->psc_in_progress = false; - sched->psc_canceled = false; + sched->psc_canceled = false; } static void @@ -214,9 +214,9 @@ struct pool_space_cache { /* Pool service */ struct pool_svc { - struct ds_rsvc ps_rsvc; - uuid_t ps_uuid; /* pool UUID */ - struct ds_pool *ps_pool; + struct ds_rsvc ps_rsvc; + uuid_t ps_uuid; /* pool UUID */ + struct ds_pool *ps_pool; struct cont_svc *ps_cont_svc; /* one combined svc for now */ ABT_rwlock ps_lock; /* for DB data */ rdb_path_t ps_root; /* root KVS */ @@ -224,36 +224,37 @@ struct pool_svc { rdb_path_t ps_user; /* pool user attributes KVS */ rdb_path_t ps_ops; /* metadata ops KVS */ int ps_error; /* in DB data (see pool_svc_lookup_leader) */ - struct pool_svc_events ps_events; + struct pool_svc_events ps_events; struct pool_space_cache ps_space_cache; - uint32_t ps_global_version; - int ps_svc_rf; + uint32_t ps_global_version; + int ps_svc_rf; bool ps_force_notify; /* MS of PS membership */ - struct pool_svc_sched ps_reconf_sched; - struct pool_svc_sched ps_rfcheck_sched; /* Check all containers RF for the pool */ - uint32_t ps_ops_enabled; /* cached ds_pool_prop_svc_ops_enabled */ - uint32_t ps_ops_max; /* cached ds_pool_prop_svc_ops_max */ - uint32_t ps_ops_age; /* cached ds_pool_prop_svc_ops_age */ + struct pool_svc_sched ps_reconf_sched; + struct pool_svc_sched ps_rfcheck_sched; /* Check all containers RF for the pool */ + uint32_t ps_ops_enabled; /* cached ds_pool_prop_svc_ops_enabled */ + uint32_t ps_ops_max; /* cached ds_pool_prop_svc_ops_max */ + uint32_t ps_ops_age; /* cached ds_pool_prop_svc_ops_age */ }; /* Pool service failed to start */ struct pool_svc_failed { - uuid_t psf_uuid; /* pool UUID */ - int psf_error; /* error number */ - d_list_t psf_link; /* link to global list */ + uuid_t psf_uuid; /* pool UUID */ + int psf_error; /* error number */ + d_list_t psf_link; /* link to global list */ }; /** serialize operations on pool_svc_failed_list */ -static pthread_rwlock_t psfl_rwlock = PTHREAD_RWLOCK_INITIALIZER; +static pthread_rwlock_t psfl_rwlock = PTHREAD_RWLOCK_INITIALIZER; /* tracking failed pool service */ D_LIST_HEAD(pool_svc_failed_list); static bool pool_disable_exclude; -static int pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, - uint64_t bits, daos_prop_t **prop_out); static int - pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, - struct daos_pool_space *ps, uint64_t *mem_file_bytes); +pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, + daos_prop_t **prop_out); +static int +pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, + struct daos_pool_space *ps, uint64_t *mem_file_bytes); static int ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct pool_svc *svc, crt_rpc_t *rpc, uuid_t srv_pool_hdl, uuid_t srv_cont_hdl); @@ -280,14 +281,13 @@ pool_svc_obj(struct ds_rsvc *rsvc) } static int -write_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf *buf, - uint32_t version) +write_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf *buf, uint32_t version) { - d_iov_t value; - int rc; + d_iov_t value; + int rc; - D_DEBUG(DB_MD, "version=%u ntargets=%u ndomains=%u\n", version, - buf->pb_target_nr, buf->pb_domain_nr); + D_DEBUG(DB_MD, "version=%u ntargets=%u ndomains=%u\n", version, buf->pb_target_nr, + buf->pb_domain_nr); /* Write the version. */ d_iov_set(&value, &version, sizeof(version)); @@ -305,12 +305,11 @@ write_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf *buf, * version into "map_buf" and "map_version", respectively. */ static int -locate_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, - uint32_t *version) +locate_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, uint32_t *version) { - uint32_t ver; - d_iov_t value; - int rc; + uint32_t ver; + d_iov_t value; + int rc; /* Read the version. */ d_iov_set(&value, &ver, sizeof(ver)); @@ -324,21 +323,20 @@ locate_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, if (rc != 0) return rc; - *buf = value.iov_buf; + *buf = value.iov_buf; *version = ver; - D_DEBUG(DB_MD, "version=%u ntargets=%u ndomains=%u\n", *version, - (*buf)->pb_target_nr, (*buf)->pb_domain_nr); + D_DEBUG(DB_MD, "version=%u ntargets=%u ndomains=%u\n", *version, (*buf)->pb_target_nr, + (*buf)->pb_domain_nr); return 0; } /* Callers are responsible for freeing buf with D_FREE. */ static int -read_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, - uint32_t *version) +read_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, uint32_t *version) { - struct pool_buf *b; - size_t size; - int rc; + struct pool_buf *b; + size_t size; + int rc; rc = locate_map_buf(tx, kvs, &b, version); if (rc != 0) @@ -355,9 +353,9 @@ read_map_buf(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_buf **buf, static int read_map(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_map **map) { - struct pool_buf *buf; - uint32_t version; - int rc; + struct pool_buf *buf; + uint32_t version; + int rc; rc = locate_map_buf(tx, kvs, &buf, &version); if (rc != 0) @@ -369,11 +367,11 @@ read_map(struct rdb_tx *tx, const rdb_path_t *kvs, struct pool_map **map) static char * pool_svc_rdb_path_common(const uuid_t pool_uuid, const char *suffix) { - char *name; - char *path; - int rc; + char *name; + char *path; + int rc; - D_ASPRINTF(name, RDB_FILE"pool%s", suffix); + D_ASPRINTF(name, RDB_FILE "pool%s", suffix); if (name == NULL) return NULL; rc = ds_mgmt_file(dss_storage_path, pool_uuid, name, NULL /* idx */, &path); @@ -394,10 +392,10 @@ ds_pool_svc_rdb_path(const uuid_t pool_uuid) static int pool_prop_default_copy(daos_prop_t *prop_def, daos_prop_t *prop) { - struct daos_prop_entry *entry; - struct daos_prop_entry *entry_def; - int i; - int rc; + struct daos_prop_entry *entry; + struct daos_prop_entry *entry_def; + int i; + int rc; if (prop == NULL || prop->dpp_nr == 0 || prop->dpp_entries == NULL) return 0; @@ -408,23 +406,23 @@ pool_prop_default_copy(daos_prop_t *prop_def, daos_prop_t *prop) } for (i = 0; i < prop->dpp_nr; i++) { - entry = &prop->dpp_entries[i]; + entry = &prop->dpp_entries[i]; entry_def = daos_prop_entry_get(prop_def, entry->dpe_type); - D_ASSERTF(entry_def != NULL, "type %d not found in " - "default prop.\n", entry->dpe_type); + D_ASSERTF(entry_def != NULL, + "type %d not found in " + "default prop.\n", + entry->dpe_type); switch (entry->dpe_type) { case DAOS_PROP_PO_LABEL: D_FREE(entry_def->dpe_str); - D_STRNDUP(entry_def->dpe_str, entry->dpe_str, - DAOS_PROP_LABEL_MAX_LEN); + D_STRNDUP(entry_def->dpe_str, entry->dpe_str, DAOS_PROP_LABEL_MAX_LEN); if (entry_def->dpe_str == NULL) return -DER_NOMEM; break; case DAOS_PROP_PO_OWNER: case DAOS_PROP_PO_OWNER_GROUP: D_FREE(entry_def->dpe_str); - D_STRNDUP(entry_def->dpe_str, entry->dpe_str, - DAOS_ACL_MAX_PRINCIPAL_LEN); + D_STRNDUP(entry_def->dpe_str, entry->dpe_str, DAOS_ACL_MAX_PRINCIPAL_LEN); if (entry_def->dpe_str == NULL) return -DER_NOMEM; break; @@ -489,12 +487,12 @@ pool_prop_default_copy(daos_prop_t *prop_def, daos_prop_t *prop) static int pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) { - struct daos_prop_entry *entry; - d_iov_t value; - int i; - int rc = 0; - uint32_t val32; - uint32_t global_ver; + struct daos_prop_entry *entry; + d_iov_t value; + int i; + int rc = 0; + uint32_t val32; + uint32_t global_ver; if (prop == NULL || prop->dpp_nr == 0 || prop->dpp_entries == NULL) return 0; @@ -523,28 +521,20 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) entry = &prop->dpp_entries[i]; switch (entry->dpe_type) { case DAOS_PROP_PO_LABEL: - if (entry->dpe_str == NULL || - strlen(entry->dpe_str) == 0) { - entry = daos_prop_entry_get(&pool_prop_default, - entry->dpe_type); + if (entry->dpe_str == NULL || strlen(entry->dpe_str) == 0) { + entry = daos_prop_entry_get(&pool_prop_default, entry->dpe_type); D_ASSERT(entry != NULL); } - d_iov_set(&value, entry->dpe_str, - strlen(entry->dpe_str)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_label, - &value); + d_iov_set(&value, entry->dpe_str, strlen(entry->dpe_str)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_label, &value); break; case DAOS_PROP_PO_OWNER: - d_iov_set(&value, entry->dpe_str, - strlen(entry->dpe_str)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_owner, - &value); + d_iov_set(&value, entry->dpe_str, strlen(entry->dpe_str)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_owner, &value); break; case DAOS_PROP_PO_OWNER_GROUP: - d_iov_set(&value, entry->dpe_str, - strlen(entry->dpe_str)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_owner_group, - &value); + d_iov_set(&value, entry->dpe_str, strlen(entry->dpe_str)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_owner_group, &value); break; case DAOS_PROP_PO_ACL: if (entry->dpe_val_ptr != NULL) { @@ -552,50 +542,37 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) acl = entry->dpe_val_ptr; d_iov_set(&value, acl, daos_acl_get_size(acl)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_acl, - &value); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_acl, &value); } break; case DAOS_PROP_PO_SPACE_RB: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_space_rb, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_space_rb, &value); break; case DAOS_PROP_PO_SELF_HEAL: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_self_heal, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_self_heal, &value); break; case DAOS_PROP_PO_RECLAIM: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_reclaim, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_reclaim, &value); break; case DAOS_PROP_PO_EC_CELL_SZ: if (!daos_ec_cs_valid(entry->dpe_val)) { D_ERROR("DAOS_PROP_PO_EC_CELL_SZ property value" - " "DF_U64" should within rage of " - "["DF_U64", "DF_U64"] and multiplier of "DF_U64"\n", - entry->dpe_val, - DAOS_PROP_PO_EC_CELL_SZ_MIN, - DAOS_PROP_PO_EC_CELL_SZ_MAX, - DAOS_PROP_PO_EC_CELL_SZ_MIN); + " " DF_U64 " should within rage of " + "[" DF_U64 ", " DF_U64 "] and multiplier of " DF_U64 "\n", + entry->dpe_val, DAOS_PROP_PO_EC_CELL_SZ_MIN, + DAOS_PROP_PO_EC_CELL_SZ_MAX, DAOS_PROP_PO_EC_CELL_SZ_MIN); rc = -DER_INVAL; break; } - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_ec_cell_sz, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_ec_cell_sz, &value); break; case DAOS_PROP_PO_REDUN_FAC: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_redun_fac, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_redun_fac, &value); break; case DAOS_PROP_PO_DATA_THRESH: if (!daos_data_thresh_valid(entry->dpe_val)) { @@ -612,42 +589,32 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) rc = -DER_INVAL; break; } - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_ec_pda, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_ec_pda, &value); break; case DAOS_PROP_PO_RP_PDA: if (!daos_rp_pda_valid(entry->dpe_val)) { rc = -DER_INVAL; break; } - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_rp_pda, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_rp_pda, &value); break; case DAOS_PROP_PO_SCRUB_MODE: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_mode, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_mode, &value); if (rc) return rc; break; case DAOS_PROP_PO_SCRUB_FREQ: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_freq, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_freq, &value); if (rc) return rc; break; case DAOS_PROP_PO_SCRUB_THRESH: - d_iov_set(&value, &entry->dpe_val, - sizeof(entry->dpe_val)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_thresh, - &value); + d_iov_set(&value, &entry->dpe_val, sizeof(entry->dpe_val)); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_scrub_thresh, &value); if (rc) return rc; break; @@ -658,8 +625,7 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) } val32 = entry->dpe_val; d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_global_version, - &value); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_global_version, &value); break; case DAOS_PROP_PO_UPGRADE_STATUS: if (entry->dpe_val > DAOS_UPGRADE_STATUS_COMPLETED) { @@ -668,14 +634,12 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) } val32 = entry->dpe_val; d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_upgrade_status, - &value); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_upgrade_status, &value); break; case DAOS_PROP_PO_PERF_DOMAIN: val32 = entry->dpe_val; d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_perf_domain, - &value); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_perf_domain, &value); break; case DAOS_PROP_PO_SVC_REDUN_FAC: if (global_ver < 2) { @@ -729,8 +693,7 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) case DAOS_PROP_PO_REINT_MODE: val32 = entry->dpe_val; d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_update(tx, kvs, &ds_pool_prop_reint_mode, - &value); + rc = rdb_tx_update(tx, kvs, &ds_pool_prop_reint_mode, &value); if (rc) return rc; break; @@ -753,8 +716,8 @@ pool_prop_write(struct rdb_tx *tx, const rdb_path_t *kvs, daos_prop_t *prop) return -DER_INVAL; } if (rc) { - D_ERROR("Failed to update entry type=%d, rc="DF_RC"\n", - entry->dpe_type, DP_RC(rc)); + D_ERROR("Failed to update entry type=%d, rc=" DF_RC "\n", entry->dpe_type, + DP_RC(rc)); break; } } @@ -766,14 +729,14 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co const d_rank_list_t *ranks, daos_prop_t *prop_orig, uint32_t ndomains, const uint32_t *domains) { - struct pool_buf *map_buf; - uint32_t map_version = 1; - uint32_t connectable; - uint32_t nhandles = 0; - d_iov_t value; - struct rdb_kvs_attr attr; - int ntargets = nnodes * dss_tgt_nr; - uint32_t upgrade_global_version = DAOS_POOL_GLOBAL_VERSION; + struct pool_buf *map_buf; + uint32_t map_version = 1; + uint32_t connectable; + uint32_t nhandles = 0; + d_iov_t value; + struct rdb_kvs_attr attr; + int ntargets = nnodes * dss_tgt_nr; + uint32_t upgrade_global_version = DAOS_POOL_GLOBAL_VERSION; uint32_t svc_ops_enabled = 1; /* max number of entries in svc_ops KVS: equivalent of max age (sec) x PS_OPS_PER_SEC */ uint32_t svc_ops_age = DAOS_PROP_PO_SVC_OPS_ENTRY_AGE_DEFAULT; @@ -838,13 +801,13 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co /* Initialize the pool map properties. */ rc = write_map_buf(tx, kvs, map_buf, map_version); if (rc != 0) { - D_ERROR("failed to write map properties, "DF_RC"\n", DP_RC(rc)); + D_ERROR("failed to write map properties, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } rc = pool_prop_write(tx, kvs, prop); if (rc != 0) { - D_ERROR("failed to write props, "DF_RC"\n", DP_RC(rc)); + D_ERROR("failed to write props, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } @@ -853,8 +816,7 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co d_iov_set(&value, &connectable, sizeof(connectable)); rc = rdb_tx_update(tx, kvs, &ds_pool_prop_connectable, &value); if (rc != 0) { - D_ERROR("failed to write connectable prop, "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to write connectable prop, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } @@ -866,8 +828,7 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co d_iov_set(&value, &upgrade_global_version, sizeof(upgrade_global_version)); rc = rdb_tx_update(tx, kvs, &ds_pool_prop_upgrade_global_version, &value); if (rc != 0) { - D_ERROR("failed to write upgrade global version prop, "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to write upgrade global version prop, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } @@ -875,29 +836,28 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co d_iov_set(&value, &nhandles, sizeof(nhandles)); rc = rdb_tx_update(tx, kvs, &ds_pool_prop_nhandles, &value); if (rc != 0) { - D_ERROR("failed to update handle props, "DF_RC"\n", DP_RC(rc)); + D_ERROR("failed to update handle props, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } attr.dsa_class = RDB_KVS_GENERIC; attr.dsa_order = 16; - rc = rdb_tx_create_kvs(tx, kvs, &ds_pool_prop_handles, &attr); + rc = rdb_tx_create_kvs(tx, kvs, &ds_pool_prop_handles, &attr); if (rc != 0) { - D_ERROR("failed to create handle prop KVS, "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to create handle prop KVS, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } /* Create pool user attributes KVS */ rc = rdb_tx_create_kvs(tx, kvs, &ds_pool_attr_user, &attr); if (rc != 0) { - D_ERROR("failed to create user attr KVS, "DF_RC"\n", DP_RC(rc)); + D_ERROR("failed to create user attr KVS, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; } /* Create pool service operations KVS */ attr.dsa_class = RDB_KVS_LEXICAL; attr.dsa_order = 16; - rc = rdb_tx_create_kvs(tx, kvs, &ds_pool_prop_svc_ops, &attr); + rc = rdb_tx_create_kvs(tx, kvs, &ds_pool_prop_svc_ops, &attr); if (rc != 0) { D_ERROR("failed to create service ops KVS, " DF_RC "\n", DP_RC(rc)); goto out_map_buf; @@ -979,8 +939,7 @@ init_pool_metadata(struct rdb_tx *tx, const rdb_path_t *kvs, uint32_t nnodes, co * calling d_rank_list_free(*ranksp). */ static int -select_svc_ranks(int svc_rf, struct pool_buf *map_buf, uint32_t map_version, - d_rank_list_t **ranksp) +select_svc_ranks(int svc_rf, struct pool_buf *map_buf, uint32_t map_version, d_rank_list_t **ranksp) { struct pool_map *map; d_rank_list_t replicas = {0}; @@ -1015,8 +974,8 @@ select_svc_ranks(int svc_rf, struct pool_buf *map_buf, uint32_t map_version, * RSVC_CLIENT_PROCEED OK; proceed to process the reply */ static int -pool_rsvc_client_complete_rpc(struct rsvc_client *client, const crt_endpoint_t *ep, - int rc_crt, struct pool_op_out *out) +pool_rsvc_client_complete_rpc(struct rsvc_client *client, const crt_endpoint_t *ep, int rc_crt, + struct pool_op_out *out) { int rc; @@ -1080,16 +1039,15 @@ ds_pool_svc_dist_create(const uuid_t pool_uuid, int ntargets, const char *group, D_ASSERT(def_lbl_ent != NULL); lbl_ent = daos_prop_entry_get(prop, DAOS_PROP_PO_LABEL); if (lbl_ent != NULL) { - if (strncmp(def_lbl_ent->dpe_str, lbl_ent->dpe_str, - DAOS_PROP_LABEL_MAX_LEN) == 0) { - D_ERROR(DF_UUID": label is the same as default label\n", + if (strncmp(def_lbl_ent->dpe_str, lbl_ent->dpe_str, DAOS_PROP_LABEL_MAX_LEN) == 0) { + D_ERROR(DF_UUID ": label is the same as default label\n", DP_UUID(pool_uuid)); D_GOTO(out, rc = -DER_INVAL); } } - D_ASSERTF(ntargets == target_addrs->rl_nr, "ntargets=%d num=%u\n", - ntargets, target_addrs->rl_nr); + D_ASSERTF(ntargets == target_addrs->rl_nr, "ntargets=%d num=%u\n", ntargets, + target_addrs->rl_nr); rc = gen_pool_buf(NULL /* map */, &map_buf, map_version, ndomains, target_addrs->rl_nr, target_addrs->rl_nr * dss_tgt_nr, domains, dss_tgt_nr); @@ -1098,9 +1056,9 @@ ds_pool_svc_dist_create(const uuid_t pool_uuid, int ntargets, const char *group, svc_rf_entry = daos_prop_entry_get(prop, DAOS_PROP_PO_SVC_REDUN_FAC); D_ASSERT(svc_rf_entry != NULL && !(svc_rf_entry->dpe_flags & DAOS_PROP_ENTRY_NOT_SET)); - D_ASSERTF(daos_svc_rf_is_valid(svc_rf_entry->dpe_val), DF_U64"\n", svc_rf_entry->dpe_val); + D_ASSERTF(daos_svc_rf_is_valid(svc_rf_entry->dpe_val), DF_U64 "\n", svc_rf_entry->dpe_val); - D_DEBUG(DB_MD, DF_UUID": creating PS: ntargets=%d ndomains=%d svc_rf="DF_U64"\n", + D_DEBUG(DB_MD, DF_UUID ": creating PS: ntargets=%d ndomains=%d svc_rf=" DF_U64 "\n", DP_UUID(pool_uuid), ntargets, ndomains, svc_rf_entry->dpe_val); /* Determine the ranks and IDs of the PS replicas. */ @@ -1135,17 +1093,17 @@ ds_pool_svc_dist_create(const uuid_t pool_uuid, int ntargets, const char *group, if (rc != 0) goto out_replicas; - rc = d_backoff_seq_init(&backoff_seq, 0 /* nzeros */, 16 /* factor */, - 8 /* next (ms) */, 1 << 10 /* max (ms) */); - D_ASSERTF(rc == 0, "d_backoff_seq_init: "DF_RC"\n", DP_RC(rc)); + rc = d_backoff_seq_init(&backoff_seq, 0 /* nzeros */, 16 /* factor */, 8 /* next (ms) */, + 1 << 10 /* max (ms) */); + D_ASSERTF(rc == 0, "d_backoff_seq_init: " DF_RC "\n", DP_RC(rc)); rechoose: /* Create a POOL_CREATE request. */ ep.ep_grp = NULL; - rc = rsvc_client_choose(&client, &ep); + rc = rsvc_client_choose(&client, &ep); if (rc != 0) { - D_ERROR(DF_UUID": cannot find pool service: "DF_RC"\n", - DP_UUID(pool_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": cannot find pool service: " DF_RC "\n", DP_UUID(pool_uuid), + DP_RC(rc)); goto out_backoff_seq; } if (n_attempts == 0) @@ -1171,8 +1129,7 @@ ds_pool_svc_dist_create(const uuid_t pool_uuid, int ntargets, const char *group, n_attempts++; out = crt_reply_get(rpc); D_ASSERT(out != NULL); - rc = rsvc_client_complete_rpc(&client, &ep, rc, - rc == 0 ? out->pro_op.po_rc : -DER_IO, + rc = rsvc_client_complete_rpc(&client, &ep, rc, rc == 0 ? out->pro_op.po_rc : -DER_IO, rc == 0 ? &out->pro_op.po_hint : NULL); if (rc == RSVC_CLIENT_RECHOOSE || (rc == RSVC_CLIENT_PROCEED && daos_rpc_retryable_rc(out->pro_op.po_rc))) { @@ -1182,8 +1139,8 @@ ds_pool_svc_dist_create(const uuid_t pool_uuid, int ntargets, const char *group, } rc = out->pro_op.po_rc; if (rc != 0) { - D_ERROR(DF_UUID": failed to create pool: "DF_RC"\n", - DP_UUID(pool_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": failed to create pool: " DF_RC "\n", DP_UUID(pool_uuid), + DP_RC(rc)); D_GOTO(out_rpc, rc); } @@ -1242,7 +1199,7 @@ ds_pool_svc_start(uuid_t uuid) rc = ds_rsvc_start(DS_RSVC_CLASS_POOL, &id, uuid, RDB_NIL_TERM, DS_RSVC_START, NULL /* create_params */, NULL /* arg */); if (rc == -DER_ALREADY) { - D_DEBUG(DB_MD, DF_UUID": pool service already started\n", DP_UUID(uuid)); + D_DEBUG(DB_MD, DF_UUID ": pool service already started\n", DP_UUID(uuid)); return 0; } else if (rc != 0) { DL_ERROR(rc, DF_UUID ": failed to start pool service", DP_UUID(uuid)); @@ -1256,7 +1213,7 @@ ds_pool_svc_start(uuid_t uuid) int ds_pool_svc_stop(uuid_t pool_uuid) { - d_iov_t id; + d_iov_t id; d_iov_set(&id, pool_uuid, sizeof(uuid_t)); return ds_rsvc_stop(DS_RSVC_CLASS_POOL, &id, RDB_NIL_TERM, false /* destroy */); @@ -1273,7 +1230,7 @@ pool_svc_name_cb(d_iov_t *id, char **name) if (s == NULL) return -DER_NOMEM; uuid_unparse_lower(id->iov_buf, s); - s[8] = '\0'; /* strlen(DF_UUID) */ + s[8] = '\0'; /* strlen(DF_UUID) */ *name = s; return 0; } @@ -1304,8 +1261,8 @@ get_crt_event_delay(void) static int pool_svc_alloc_cb(d_iov_t *id, struct ds_rsvc **rsvc) { - struct pool_svc *svc; - int rc; + struct pool_svc *svc; + int rc; if (id->iov_len != sizeof(uuid_t)) { rc = -DER_INVAL; @@ -1323,8 +1280,8 @@ pool_svc_alloc_cb(d_iov_t *id, struct ds_rsvc **rsvc) uuid_copy(svc->ps_uuid, id->iov_buf); svc->ps_events.pse_timeout = get_crt_event_delay(); svc->ps_events.pse_handler = ABT_THREAD_NULL; - svc->ps_svc_rf = -1; - svc->ps_force_notify = false; + svc->ps_svc_rf = -1; + svc->ps_force_notify = false; rc = ds_pool_lookup(svc->ps_uuid, &svc->ps_pool); if (rc != 0) { @@ -1393,8 +1350,7 @@ pool_svc_alloc_cb(d_iov_t *id, struct ds_rsvc **rsvc) if (rc != 0) goto err_sched; - rc = ds_cont_svc_init(&svc->ps_cont_svc, svc->ps_uuid, 0 /* id */, - &svc->ps_rsvc); + rc = ds_cont_svc_init(&svc->ps_cont_svc, svc->ps_uuid, 0 /* id */, &svc->ps_rsvc); if (rc != 0) goto err_cont_rf_sched; @@ -1590,17 +1546,17 @@ resume_event_handling(struct pool_svc *svc) static void pool_restart_rebuild_if_rank_wip(struct ds_pool *pool, d_rank_t rank) { - struct pool_domain *dom; + struct pool_domain *dom; dom = pool_map_find_dom_by_rank(pool->sp_map, rank); if (dom == NULL) { - D_DEBUG(DB_MD, DF_UUID": rank %d non-exist on pool map.\n", - DP_UUID(pool->sp_uuid), rank); + D_DEBUG(DB_MD, DF_UUID ": rank %d non-exist on pool map.\n", DP_UUID(pool->sp_uuid), + rank); return; } if (dom->do_comp.co_status != PO_COMP_ST_UPIN) { - D_INFO(DF_UUID": rank %d status %d in pool map, got CRT_EVT_ALIVE.\n", + D_INFO(DF_UUID ": rank %d status %d in pool map, got CRT_EVT_ALIVE.\n", DP_UUID(pool->sp_uuid), rank, dom->do_comp.co_status); return; } @@ -1610,7 +1566,8 @@ pool_restart_rebuild_if_rank_wip(struct ds_pool *pool, d_rank_t rank) return; } -static int pool_svc_exclude_ranks(struct pool_svc *svc, struct pool_svc_event_set *event_set); +static int +pool_svc_exclude_ranks(struct pool_svc *svc, struct pool_svc_event_set *event_set); static int handle_event(struct pool_svc *svc, struct pool_svc_event_set *event_set) @@ -1643,7 +1600,7 @@ handle_event(struct pool_svc *svc, struct pool_svc_event_set *event_set) continue; D_DEBUG(DB_MD, DF_UUID ": got CRT_EVT_ALIVE event, psv_src %d, psv_rank %d\n", - DP_UUID(svc->ps_uuid), event->psv_src, event->psv_rank); + DP_UUID(svc->ps_uuid), event->psv_src, event->psv_rank); pool_restart_rebuild_if_rank_wip(svc->ps_pool, event->psv_rank); if (ds_pool_map_rank_up(svc->ps_pool->sp_map, event->psv_rank)) { @@ -1671,8 +1628,8 @@ struct event_timer_arg { static void event_timer(void *varg) { - struct event_timer_arg *arg = varg; - struct pool_svc_events *events = arg->eta_events; + struct event_timer_arg *arg = varg; + struct pool_svc_events *events = arg->eta_events; int64_t time_left = arg->eta_deadline - daos_gettime_coarse(); if (time_left > 0) @@ -1710,10 +1667,10 @@ stop_event_timer(struct event_timer_arg *arg) static void events_handler(void *arg) { - struct pool_svc *svc = arg; + struct pool_svc *svc = arg; struct pool_svc_events *events = &svc->ps_events; - D_DEBUG(DB_MD, DF_UUID": starting\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": starting\n", DP_UUID(svc->ps_uuid)); for (;;) { struct pool_svc_event_set *event_set = NULL; @@ -1738,7 +1695,7 @@ events_handler(void *arg) time_left = timer_arg.eta_deadline - daos_gettime_coarse(); if (events->pse_pending != NULL && !events->pse_paused && time_left <= 0) { - event_set = events->pse_pending; + event_set = events->pse_pending; events->pse_pending = NULL; break; } @@ -1787,7 +1744,7 @@ events_handler(void *arg) free_event_set(&events->pse_pending); } events->pse_pending = event_set; - event_set = NULL; + event_set = NULL; ABT_mutex_unlock(events->pse_mutex); } @@ -1796,7 +1753,7 @@ events_handler(void *arg) ABT_thread_yield(); } - D_DEBUG(DB_MD, DF_UUID": stopping\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": stopping\n", DP_UUID(svc->ps_uuid)); } static bool @@ -1809,22 +1766,23 @@ static void ds_pool_crt_event_cb(d_rank_t rank, uint64_t incarnation, enum crt_event_source src, enum crt_event_type type, void *arg) { - struct pool_svc *svc = arg; - int rc; + struct pool_svc *svc = arg; + int rc; rc = queue_event(svc, rank, incarnation, src, type); if (rc != 0) - D_ERROR(DF_UUID": failed to queue event: "DF_PS_EVENT": "DF_RC"\n", + D_ERROR(DF_UUID ": failed to queue event: " DF_PS_EVENT ": " DF_RC "\n", DP_UUID(svc->ps_uuid), rank, incarnation, src, type, DP_RC(rc)); } -static int pool_svc_check_node_status(struct pool_svc *svc); +static int +pool_svc_check_node_status(struct pool_svc *svc); static int init_events(struct pool_svc *svc) { struct pool_svc_events *events = &svc->ps_events; - int rc; + int rc; D_ASSERT(events->pse_pending == NULL); D_ASSERT(events->pse_timer == NULL); @@ -1835,7 +1793,7 @@ init_events(struct pool_svc *svc) if (!ds_pool_restricted(svc->ps_pool, false)) { rc = crt_register_event_cb(ds_pool_crt_event_cb, svc); if (rc != 0) { - D_ERROR(DF_UUID": failed to register event callback: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to register event callback: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto err; } @@ -1848,14 +1806,14 @@ init_events(struct pool_svc *svc) */ rc = pool_svc_check_node_status(svc); if (rc != 0) { - D_ERROR(DF_UUID": failed to create event handler: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to create event handler: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto err_cb; } rc = dss_ult_create(events_handler, svc, DSS_XS_SELF, 0, 0, &events->pse_handler); if (rc != 0) { - D_ERROR(DF_UUID": failed to create event handler: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to create event handler: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto err_cb; } @@ -1888,7 +1846,7 @@ fini_events(struct pool_svc *svc) ABT_thread_free(&events->pse_handler); events->pse_handler = ABT_THREAD_NULL; - events->pse_stop = false; + events->pse_stop = false; } static void @@ -1944,11 +1902,11 @@ update_svc_pool(struct pool_svc *svc, struct pool_buf *map_buf, uint32_t map_ver static bool primary_group_initialized(void) { - uint32_t version; - int rc; + uint32_t version; + int rc; rc = crt_group_version(NULL /* grp */, &version); - D_ASSERTF(rc == 0, "crt_group_version: "DF_RC"\n", DP_RC(rc)); + D_ASSERTF(rc == 0, "crt_group_version: " DF_RC "\n", DP_RC(rc)); return (version > 0); } @@ -1961,13 +1919,13 @@ int ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *global_version_out, struct pool_buf **map_buf_out, uint32_t *map_version_out) { - uuid_t uuid_tmp; - d_iov_t value; - uint32_t global_version; - struct pool_buf *map_buf; - uint32_t map_version; - bool version_exists = false; - int rc; + uuid_t uuid_tmp; + d_iov_t value; + uint32_t global_version; + struct pool_buf *map_buf; + uint32_t map_version; + bool version_exists = false; + int rc; /* * For the ds_notify_ras_eventf calls below, use a copy to avoid @@ -1984,11 +1942,11 @@ ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *glo * the pool map to find out which is the case. (See the * references to version_exists below.) */ - D_DEBUG(DB_MD, DF_UUID": no layout version\n", DP_UUID(uuid)); + D_DEBUG(DB_MD, DF_UUID ": no layout version\n", DP_UUID(uuid)); goto check_map; } else if (rc != 0) { - D_ERROR(DF_UUID": failed to look up layout version: "DF_RC"\n", - DP_UUID(uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": failed to look up layout version: " DF_RC "\n", DP_UUID(uuid), + DP_RC(rc)); goto out; } D_INFO(DF_UUID ": layout version %u\n", DP_UUID(uuid), global_version); @@ -1999,16 +1957,13 @@ ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *glo * a proper RAS error. */ if (global_version > DAOS_POOL_GLOBAL_VERSION) { - ds_notify_ras_eventf(RAS_POOL_DF_INCOMPAT, RAS_TYPE_INFO, - RAS_SEV_ERROR, NULL /* hwid */, - NULL /* rank */, NULL /* inc */, - NULL /* jobid */, - &uuid_tmp, NULL /* cont */, - NULL /* objid */, NULL /* ctlop */, - NULL /* data */, + ds_notify_ras_eventf(RAS_POOL_DF_INCOMPAT, RAS_TYPE_INFO, RAS_SEV_ERROR, + NULL /* hwid */, NULL /* rank */, NULL /* inc */, + NULL /* jobid */, &uuid_tmp, NULL /* cont */, NULL /* objid */, + NULL /* ctlop */, NULL /* data */, "incompatible layout version: %u larger than " - "%u", global_version, - DAOS_POOL_GLOBAL_VERSION); + "%u", + global_version, DAOS_POOL_GLOBAL_VERSION); rc = -DER_DF_INCOMPT; goto out; } @@ -2022,10 +1977,10 @@ ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *glo * exists, then the pool map must also exist; * otherwise, it is an error. */ - D_DEBUG(DB_MD, DF_UUID": new db\n", DP_UUID(uuid)); + D_DEBUG(DB_MD, DF_UUID ": new db\n", DP_UUID(uuid)); rc = DER_UNINIT; /* positive error number */ } else { - D_ERROR(DF_UUID": failed to read pool map buffer: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to read pool map buffer: " DF_RC "\n", DP_UUID(uuid), DP_RC(rc)); } goto out; @@ -2033,12 +1988,12 @@ ds_pool_svc_load(struct rdb_tx *tx, uuid_t uuid, rdb_path_t *root, uint32_t *glo if (!version_exists) /* This could also be a 1.x pool, which we assume nobody cares. */ - D_DEBUG(DB_MD, DF_UUID": assuming 2.0\n", DP_UUID(uuid)); + D_DEBUG(DB_MD, DF_UUID ": assuming 2.0\n", DP_UUID(uuid)); - D_ASSERTF(rc == 0, DF_RC"\n", DP_RC(rc)); + D_ASSERTF(rc == 0, DF_RC "\n", DP_RC(rc)); *global_version_out = global_version; - *map_buf_out = map_buf; - *map_version_out = map_version; + *map_buf_out = map_buf; + *map_version_out = map_version; out: return rc; } @@ -2139,7 +2094,7 @@ read_db_for_stepping_up(struct pool_svc *svc, struct pool_buf **map_buf_out, rc = pool_prop_read(&tx, svc, DAOS_PO_QUERY_PROP_ALL, &prop); if (rc != 0) { - D_ERROR(DF_UUID": failed to read pool properties: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to read pool properties: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto out_free; } @@ -2245,7 +2200,7 @@ read_db_for_stepping_up(struct pool_svc *svc, struct pool_buf **map_buf_out, *iv_hdls = arg.iv_hdls; *map_buf_out = map_buf; *map_version_out = map_version; - *prop_out = prop; + *prop_out = prop; out_free: if (rc != 0) { @@ -2292,20 +2247,19 @@ ds_pool_svc_rf_from_nreplicas(int nreplicas) static int pool_svc_check_node_status(struct pool_svc *svc) { - struct pool_domain *doms; - int doms_cnt; - int i; - int rc = 0; + struct pool_domain *doms; + int doms_cnt; + int i; + int rc = 0; if (pool_disable_exclude) { - D_DEBUG(DB_MD, DF_UUID": skip: exclusion disabled\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": skip: exclusion disabled\n", DP_UUID(svc->ps_uuid)); return 0; } - D_DEBUG(DB_MD, DF_UUID": checking node status\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": checking node status\n", DP_UUID(svc->ps_uuid)); ABT_rwlock_rdlock(svc->ps_pool->sp_lock); - doms_cnt = pool_map_find_ranks(svc->ps_pool->sp_map, PO_COMP_ID_ALL, - &doms); + doms_cnt = pool_map_find_ranks(svc->ps_pool->sp_map, PO_COMP_ID_ALL, &doms); D_ASSERT(doms_cnt >= 0); for (i = 0; i < doms_cnt; i++) { struct swim_member_state state; @@ -2314,11 +2268,10 @@ pool_svc_check_node_status(struct pool_svc *svc) if (!(doms[i].do_comp.co_status & PO_COMP_ST_UPIN)) continue; - rc = crt_rank_state_get(crt_group_lookup(NULL), - doms[i].do_comp.co_rank, &state); + rc = crt_rank_state_get(crt_group_lookup(NULL), doms[i].do_comp.co_rank, &state); if (rc != 0 && rc != -DER_NONEXIST) { - D_ERROR("failed to get status of rank %u: %d\n", - doms[i].do_comp.co_rank, rc); + D_ERROR("failed to get status of rank %u: %d\n", doms[i].do_comp.co_rank, + rc); break; } @@ -2326,16 +2279,15 @@ pool_svc_check_node_status(struct pool_svc *svc) * ACTIVE soon, let's only evict the DEAD node rank for the * moment. */ - D_DEBUG(DB_REBUILD, "rank/state %d/%d\n", - doms[i].do_comp.co_rank, + D_DEBUG(DB_REBUILD, "rank/state %d/%d\n", doms[i].do_comp.co_rank, rc == -DER_NONEXIST ? -1 : state.sms_status); if (rc == -DER_NONEXIST || state.sms_status == SWIM_MEMBER_DEAD) { rc = queue_event(svc, doms[i].do_comp.co_rank, 0 /* incarnation */, rc == -DER_NONEXIST ? CRT_EVS_GRPMOD : CRT_EVS_SWIM, CRT_EVT_DEAD); if (rc) { - D_ERROR("failed to exclude rank %u: %d\n", - doms[i].do_comp.co_rank, rc); + D_ERROR("failed to exclude rank %u: %d\n", doms[i].do_comp.co_rank, + rc); break; } } @@ -2348,10 +2300,11 @@ pool_svc_check_node_status(struct pool_svc *svc) * Log as well as print a message. Arguments may be evaluated more * than once. */ -#define DS_POOL_LOG_PRINT(log, fmt, ...) do { \ - D_##log(fmt, ## __VA_ARGS__); \ - D_PRINT(fmt, ## __VA_ARGS__); \ -} while (0) +#define DS_POOL_LOG_PRINT(log, fmt, ...) \ + do { \ + D_##log(fmt, ##__VA_ARGS__); \ + D_PRINT(fmt, ##__VA_ARGS__); \ + } while (0) static void pool_svc_update_map_metrics(uuid_t uuid, struct pool_map *map, struct pool_metrics *metrics) @@ -2475,11 +2428,14 @@ pool_svc_step_down_metrics(struct pool_svc *svc) d_tm_set_gauge(metrics->total_ranks, 0); } -static int pool_svc_schedule(struct pool_svc *svc, struct pool_svc_sched *sched, - void (*func)(void *), void *arg); -static int pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, - uint32_t map_version_for, bool sync_remove); -static void pool_svc_rfcheck_ult(void *arg); +static int +pool_svc_schedule(struct pool_svc *svc, struct pool_svc_sched *sched, void (*func)(void *), + void *arg); +static int +pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, uint32_t map_version_for, + bool sync_remove); +static void +pool_svc_rfcheck_ult(void *arg); /* Abort condition of ds_mgmt_get_self_heal_policy for pool_svc. */ static bool @@ -2566,11 +2522,11 @@ pool_svc_step_up_cb(struct ds_rsvc *rsvc) svc->ps_force_notify = true; rc = pool_svc_schedule_reconf(svc, NULL /* map */, map_version, false /* sync_remove */); if (rc == -DER_OP_CANCELED) { - DL_INFO(rc, DF_UUID": not scheduling pool service reconfiguration", + DL_INFO(rc, DF_UUID ": not scheduling pool service reconfiguration", DP_UUID(svc->ps_uuid)); rc = 0; } else if (rc != 0) { - DL_ERROR(rc, DF_UUID": failed to schedule pool service reconfiguration", + DL_ERROR(rc, DF_UUID ": failed to schedule pool service reconfiguration", DP_UUID(svc->ps_uuid)); goto out; } @@ -2580,7 +2536,7 @@ pool_svc_step_up_cb(struct ds_rsvc *rsvc) DL_INFO(rc, DF_UUID ": not scheduling RF check", DP_UUID(svc->ps_uuid)); rc = 0; } else if (rc != 0) { - DL_ERROR(rc, DF_UUID": failed to schedule RF check", DP_UUID(svc->ps_uuid)); + DL_ERROR(rc, DF_UUID ": failed to schedule RF check", DP_UUID(svc->ps_uuid)); goto out; } @@ -2666,9 +2622,11 @@ pool_svc_step_up_cb(struct ds_rsvc *rsvc) * Step up with the error anyway, so that RPCs to the PS * receive an error instead of timeouts. */ - DS_POOL_LOG_PRINT(NOTE, DF_UUID": rank %u became pool service leader "DF_U64 - " with error: "DF_RC"\n", DP_UUID(svc->ps_uuid), rank, - svc->ps_rsvc.s_term, DP_RC(svc->ps_error)); + DS_POOL_LOG_PRINT(NOTE, + DF_UUID ": rank %u became pool service leader " DF_U64 + " with error: " DF_RC "\n", + DP_UUID(svc->ps_uuid), rank, svc->ps_rsvc.s_term, + DP_RC(svc->ps_error)); rc = 0; } return rc; @@ -2686,12 +2644,15 @@ pool_svc_step_down_cb(struct ds_rsvc *rsvc) sched_cancel_and_wait(&svc->ps_reconf_sched); sched_cancel_and_wait(&svc->ps_rfcheck_sched); ds_cont_svc_step_down(svc->ps_cont_svc); - DS_POOL_LOG_PRINT(NOTE, DF_UUID": rank %u no longer pool service leader "DF_U64"\n", + DS_POOL_LOG_PRINT(NOTE, + DF_UUID ": rank %u no longer pool service leader " DF_U64 "\n", DP_UUID(svc->ps_uuid), rank, svc->ps_rsvc.s_term); } else { - DS_POOL_LOG_PRINT(NOTE, DF_UUID": rank %u no longer pool service leader "DF_U64 - " with error: "DF_RC"\n", DP_UUID(svc->ps_uuid), rank, - svc->ps_rsvc.s_term, DP_RC(svc->ps_error)); + DS_POOL_LOG_PRINT(NOTE, + DF_UUID ": rank %u no longer pool service leader " DF_U64 + " with error: " DF_RC "\n", + DP_UUID(svc->ps_uuid), rank, svc->ps_rsvc.s_term, + DP_RC(svc->ps_error)); svc->ps_error = 0; } } @@ -2704,12 +2665,12 @@ pool_svc_drain_cb(struct ds_rsvc *rsvc) static int pool_svc_map_dist_cb(struct ds_rsvc *rsvc, uint32_t *version) { - struct pool_svc *svc = pool_svc_obj(rsvc); - struct pool_metrics *metrics; - struct rdb_tx tx; - struct pool_buf *map_buf = NULL; - uint32_t map_version; - int rc; + struct pool_svc *svc = pool_svc_obj(rsvc); + struct pool_metrics *metrics; + struct rdb_tx tx; + struct pool_buf *map_buf = NULL; + uint32_t map_version; + int rc; /* Read the pool map into map_buf and map_version. */ rc = rdb_tx_begin(rsvc->s_db, rsvc->s_term, &tx); @@ -2838,8 +2799,8 @@ pool_svc_put_leader(struct pool_svc *svc) int ds_pool_svc_lookup_leader(uuid_t uuid, struct ds_pool_svc **ds_svcp, struct rsvc_hint *hint) { - struct pool_svc *svc = NULL; - int rc; + struct pool_svc *svc = NULL; + int rc; rc = pool_svc_lookup_leader(uuid, &svc, hint); if (rc == 0) @@ -2851,7 +2812,7 @@ ds_pool_svc_lookup_leader(uuid_t uuid, struct ds_pool_svc **ds_svcp, struct rsvc void ds_pool_svc_put_leader(struct ds_pool_svc *ds_svc) { - struct pool_svc *svc = pool_ds2svc(ds_svc); + struct pool_svc *svc = pool_ds2svc(ds_svc); if (svc != NULL) ds_rsvc_put_leader(&svc->ps_rsvc); @@ -2859,11 +2820,10 @@ ds_pool_svc_put_leader(struct ds_pool_svc *ds_svc) /** Look up container service \a pool_uuid. */ int -ds_pool_cont_svc_lookup_leader(uuid_t pool_uuid, struct cont_svc **svcp, - struct rsvc_hint *hint) +ds_pool_cont_svc_lookup_leader(uuid_t pool_uuid, struct cont_svc **svcp, struct rsvc_hint *hint) { - struct pool_svc *pool_svc; - int rc; + struct pool_svc *pool_svc; + int rc; rc = pool_svc_lookup_leader(pool_uuid, &pool_svc, hint); if (rc != 0) @@ -2872,10 +2832,11 @@ ds_pool_cont_svc_lookup_leader(uuid_t pool_uuid, struct cont_svc **svcp, return 0; } -int ds_pool_failed_add(uuid_t uuid, int rc) +int +ds_pool_failed_add(uuid_t uuid, int rc) { - struct pool_svc_failed *psf; - int ret = 0; + struct pool_svc_failed *psf; + int ret = 0; if (rc == 0) return 0; @@ -2903,10 +2864,11 @@ int ds_pool_failed_add(uuid_t uuid, int rc) return ret; } -void ds_pool_failed_remove(uuid_t uuid) +void +ds_pool_failed_remove(uuid_t uuid) { - struct pool_svc_failed *psf; - struct pool_svc_failed *tmp; + struct pool_svc_failed *psf; + struct pool_svc_failed *tmp; D_RWLOCK_WRLOCK(&psfl_rwlock); d_list_for_each_entry_safe(psf, tmp, &pool_svc_failed_list, psf_link) { @@ -2922,9 +2884,10 @@ void ds_pool_failed_remove(uuid_t uuid) } /* return error if failed pool found, otherwise 0 is returned */ -int ds_pool_failed_lookup(uuid_t uuid) +int +ds_pool_failed_lookup(uuid_t uuid) { - struct pool_svc_failed *psf; + struct pool_svc_failed *psf; D_RWLOCK_RDLOCK(&psfl_rwlock); d_list_for_each_entry(psf, &pool_svc_failed_list, psf_link) { @@ -2939,8 +2902,8 @@ int ds_pool_failed_lookup(uuid_t uuid) } struct pool_start_args { - bool psa_aft_chk; - bool psa_immutable; + bool psa_aft_chk; + bool psa_immutable; }; /* @@ -2950,10 +2913,10 @@ struct pool_start_args { static int start_one(uuid_t uuid, void *varg) { - struct pool_start_args *psa = varg; - bool aft_chk; - bool immutable; - int rc; + struct pool_start_args *psa = varg; + bool aft_chk; + bool immutable; + int rc; if (ds_mgmt_pbl_has_pool(uuid)) { D_INFO(DF_UUID ": not starting: in pool blacklist\n", DP_UUID(uuid)); @@ -2962,15 +2925,15 @@ start_one(uuid_t uuid, void *varg) } if (psa != NULL) { - aft_chk = psa->psa_aft_chk; + aft_chk = psa->psa_aft_chk; immutable = psa->psa_immutable; } else { - aft_chk = false; + aft_chk = false; immutable = false; } - D_DEBUG(DB_MD, DF_UUID ": starting pool, aft_chk %s, immutable %s\n", - DP_UUID(uuid), aft_chk ? "yes" : "no", immutable ? "yes" : "no"); + D_DEBUG(DB_MD, DF_UUID ": starting pool, aft_chk %s, immutable %s\n", DP_UUID(uuid), + aft_chk ? "yes" : "no", immutable ? "yes" : "no"); rc = ds_pool_start(uuid, aft_chk, immutable); if (rc != 0) { @@ -3016,9 +2979,9 @@ ds_pool_restricted(struct ds_pool *pool, bool immutable) int ds_pool_start_after_check(uuid_t uuid, bool immutable) { - struct pool_start_args psa; + struct pool_start_args psa; - psa.psa_aft_chk = true; + psa.psa_aft_chk = true; psa.psa_immutable = immutable; return start_one(uuid, &psa); @@ -3028,15 +2991,14 @@ ds_pool_start_after_check(uuid_t uuid, bool immutable) int ds_pool_start_all(void) { - ABT_thread thread; - int rc; + ABT_thread thread; + int rc; /* Create a ULT to call ds_rsvc_start() in xstream 0. */ - rc = dss_ult_create(pool_start_all, NULL /* arg */, DSS_XS_SYS, - 0 /* tgt_idx */, 0 /* stack_size */, &thread); + rc = dss_ult_create(pool_start_all, NULL /* arg */, DSS_XS_SYS, 0 /* tgt_idx */, + 0 /* stack_size */, &thread); if (rc != 0) { - D_ERROR("failed to create pool start ULT: "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to create pool start ULT: " DF_RC "\n", DP_RC(rc)); return rc; } ABT_thread_free(&thread); @@ -3115,15 +3077,14 @@ pool_stop_all(void *varg) int ds_pool_stop_all(void) { - ABT_thread thread; - int rc; + ABT_thread thread; + int rc; /* Create a ULT to stop pools, since it requires TLS */ - rc = dss_ult_create(pool_stop_all, NULL /* arg */, DSS_XS_SYS, - 0 /* tgt_idx */, 0 /* stack_size */, &thread); + rc = dss_ult_create(pool_stop_all, NULL /* arg */, DSS_XS_SYS, 0 /* tgt_idx */, + 0 /* stack_size */, &thread); if (rc != 0) { - D_ERROR("failed to create pool stop ULT: "DF_RC"\n", - DP_RC(rc)); + D_ERROR("failed to create pool stop ULT: " DF_RC "\n", DP_RC(rc)); return rc; } ABT_thread_free(&thread); @@ -3132,8 +3093,8 @@ ds_pool_stop_all(void) } static int -bcast_create(crt_context_t ctx, struct pool_svc *svc, crt_opcode_t opcode, - crt_bulk_t bulk_hdl, crt_rpc_t **rpc) +bcast_create(crt_context_t ctx, struct pool_svc *svc, crt_opcode_t opcode, crt_bulk_t bulk_hdl, + crt_rpc_t **rpc) { uint8_t rpc_ver; int rc; @@ -3164,18 +3125,16 @@ ds_pool_set_hint(struct rdb *db, struct rsvc_hint *hint) } static int -pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, - daos_prop_t **prop_out) +pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, daos_prop_t **prop_out) { - daos_prop_t *prop; - d_iov_t value; - uint64_t val; - uint64_t bit; - uint32_t idx = 0, nr = 0, val32 = 0, global_ver; - int rc; + daos_prop_t *prop; + d_iov_t value; + uint64_t val; + uint64_t bit; + uint32_t idx = 0, nr = 0, val32 = 0, global_ver; + int rc; - for (bit = DAOS_PO_QUERY_PROP_BIT_START; - bit <= DAOS_PO_QUERY_PROP_BIT_END; bit++) { + for (bit = DAOS_PO_QUERY_PROP_BIT_START; bit <= DAOS_PO_QUERY_PROP_BIT_END; bit++) { if (bits & (1L << bit)) nr++; } @@ -3184,8 +3143,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, /* get pool global version */ d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_global_version, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_global_version, &value); if (rc && rc != -DER_NONEXIST) return rc; else if (rc == -DER_NONEXIST) @@ -3198,8 +3156,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, return -DER_NOMEM; if (bits & DAOS_PO_QUERY_PROP_LABEL) { d_iov_set(&value, NULL, 0); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_label, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_label, &value); if (rc != 0) D_GOTO(out_prop, rc); if (value.iov_len > DAOS_PROP_LABEL_MAX_LEN) { @@ -3209,79 +3166,72 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_LABEL; - D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, - value.iov_len); + D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, value.iov_len); if (prop->dpp_entries[idx].dpe_str == NULL) D_GOTO(out_prop, rc = -DER_NOMEM); idx++; } if (bits & DAOS_PO_QUERY_PROP_SPACE_RB) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_space_rb, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_space_rb, &value); if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SPACE_RB; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_SELF_HEAL) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_self_heal, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_self_heal, &value); if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SELF_HEAL; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_RECLAIM) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_reclaim, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_reclaim, &value); if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_RECLAIM; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_EC_CELL_SZ) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_ec_cell_sz, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_ec_cell_sz, &value); if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_EC_CELL_SZ; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_REDUN_FAC) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_redun_fac, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_redun_fac, &value); /** * For upgrading, redunc fac might not exist, use * default(0) for this case. */ if (rc == -DER_NONEXIST && global_ver < 1) { - rc = 0; + rc = 0; val = DAOS_PROP_PO_REDUN_FAC_DEFAULT; } else if (rc != 0) { D_GOTO(out_prop, rc); } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_REDUN_FAC; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_ACL) { d_iov_set(&value, NULL, 0); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_acl, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_acl, &value); if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); @@ -3289,14 +3239,12 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, D_ALLOC(prop->dpp_entries[idx].dpe_val_ptr, value.iov_buf_len); if (prop->dpp_entries[idx].dpe_val_ptr == NULL) D_GOTO(out_prop, rc = -DER_NOMEM); - memcpy(prop->dpp_entries[idx].dpe_val_ptr, value.iov_buf, - value.iov_buf_len); + memcpy(prop->dpp_entries[idx].dpe_val_ptr, value.iov_buf, value.iov_buf_len); idx++; } if (bits & DAOS_PO_QUERY_PROP_OWNER) { d_iov_set(&value, NULL, 0); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_owner, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_owner, &value); if (rc != 0) D_GOTO(out_prop, rc); if (value.iov_len > DAOS_ACL_MAX_PRINCIPAL_LEN) { @@ -3306,34 +3254,30 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_OWNER; - D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, - value.iov_len); + D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, value.iov_len); if (prop->dpp_entries[idx].dpe_str == NULL) D_GOTO(out_prop, rc = -DER_NOMEM); idx++; } if (bits & DAOS_PO_QUERY_PROP_OWNER_GROUP) { d_iov_set(&value, NULL, 0); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_owner_group, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_owner_group, &value); if (rc != 0) D_GOTO(out_prop, rc); if (value.iov_len > DAOS_ACL_MAX_PRINCIPAL_LEN) { - D_ERROR("bad owner group length %zu (> %d).\n", - value.iov_len, + D_ERROR("bad owner group length %zu (> %d).\n", value.iov_len, DAOS_ACL_MAX_PRINCIPAL_LEN); D_GOTO(out_prop, rc = -DER_IO); } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_OWNER_GROUP; - D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, - value.iov_len); + D_STRNDUP(prop->dpp_entries[idx].dpe_str, value.iov_buf, value.iov_len); if (prop->dpp_entries[idx].dpe_str == NULL) D_GOTO(out_prop, rc = -DER_NOMEM); idx++; } if (bits & DAOS_PO_QUERY_PROP_SVC_LIST) { - d_rank_list_t *svc_list = NULL; + d_rank_list_t *svc_list = NULL; d_iov_set(&value, NULL, 0); rc = rdb_get_ranks(svc->ps_rsvc.s_db, &svc_list); @@ -3341,22 +3285,21 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, D_ERROR("get svc list failed: rc " DF_RC "\n", DP_RC(rc)); D_GOTO(out_prop, rc); } - prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SVC_LIST; + prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SVC_LIST; prop->dpp_entries[idx].dpe_val_ptr = svc_list; idx++; } if (bits & DAOS_PO_QUERY_PROP_EC_PDA) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_ec_pda, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_ec_pda, &value); D_ASSERT(idx < nr); if (rc == -DER_NONEXIST && global_ver < 1) val = DAOS_PROP_PO_EC_PDA_DEFAULT; - else if (rc != 0) + else if (rc != 0) D_GOTO(out_prop, rc); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_EC_PDA; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; if (rc == -DER_NONEXIST) { rc = 0; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; @@ -3365,15 +3308,14 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } if (bits & DAOS_PO_QUERY_PROP_RP_PDA) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_rp_pda, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_rp_pda, &value); if (rc == -DER_NONEXIST && global_ver < 1) val = DAOS_PROP_PO_RP_PDA_DEFAULT; - else if (rc != 0) + else if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_RP_PDA; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; if (rc == -DER_NONEXIST) { rc = 0; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; @@ -3396,7 +3338,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_DATA_THRESH; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } @@ -3405,7 +3347,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, if (global_ver < 1) prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_GLOBAL_VERSION; - prop->dpp_entries[idx].dpe_val = global_ver; + prop->dpp_entries[idx].dpe_val = global_ver; idx++; } @@ -3415,8 +3357,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, D_ASSERT(idx < nr); /* get pool global version */ d_iov_set(&value, &obj_ver, sizeof(obj_ver)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_obj_version, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_obj_version, &value); if (rc == -DER_NONEXIST && global_ver <= 1) { obj_ver = 0; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; @@ -3425,22 +3366,21 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_OBJ_VERSION; - prop->dpp_entries[idx].dpe_val = obj_ver; + prop->dpp_entries[idx].dpe_val = obj_ver; idx++; } if (bits & DAOS_PO_QUERY_PROP_UPGRADE_STATUS) { d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_upgrade_status, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_upgrade_status, &value); if (rc == -DER_NONEXIST && global_ver < 1) val32 = DAOS_UPGRADE_STATUS_NOT_STARTED; - else if (rc != 0) + else if (rc != 0) D_GOTO(out_prop, rc); D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_UPGRADE_STATUS; - prop->dpp_entries[idx].dpe_val = val32; + prop->dpp_entries[idx].dpe_val = val32; if (rc == -DER_NONEXIST) { rc = 0; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; @@ -3450,8 +3390,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, if (bits & DAOS_PO_QUERY_PROP_PERF_DOMAIN) { d_iov_set(&value, &val32, sizeof(val32)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_perf_domain, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_perf_domain, &value); if (rc == -DER_NONEXIST && global_ver < 2) val32 = DAOS_PROP_PO_PERF_DOMAIN_DEFAULT; else if (rc != 0) @@ -3459,7 +3398,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_PERF_DOMAIN; - prop->dpp_entries[idx].dpe_val = val32; + prop->dpp_entries[idx].dpe_val = val32; if (rc == -DER_NONEXIST) { rc = 0; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; @@ -3469,10 +3408,9 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, if (bits & DAOS_PO_QUERY_PROP_SCRUB_MODE) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_mode, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_mode, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val = DAOS_PROP_PO_SCRUB_MODE_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3480,16 +3418,15 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SCRUB_MODE; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_SCRUB_FREQ) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_freq, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_freq, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val = DAOS_PROP_PO_SCRUB_FREQ_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3497,16 +3434,15 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SCRUB_FREQ; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } if (bits & DAOS_PO_QUERY_PROP_SCRUB_THRESH) { d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_thresh, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_scrub_thresh, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val = DAOS_PROP_PO_SCRUB_THRESH_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3514,7 +3450,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SCRUB_THRESH; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } @@ -3522,7 +3458,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, d_iov_set(&value, &val, sizeof(val)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_svc_redun_fac, &value); if (rc == -DER_NONEXIST && global_ver < 2) { - rc = 0; + rc = 0; val = DAOS_PROP_PO_SVC_REDUN_FAC_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3530,7 +3466,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, } D_ASSERT(idx < nr); prop->dpp_entries[idx].dpe_type = DAOS_PROP_PO_SVC_REDUN_FAC; - prop->dpp_entries[idx].dpe_val = val; + prop->dpp_entries[idx].dpe_val = val; idx++; } @@ -3538,7 +3474,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, d_iov_set(&value, &val32, sizeof(val32)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_checkpoint_mode, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val32 = DAOS_PROP_PO_CHECKPOINT_MODE_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3554,7 +3490,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, d_iov_set(&value, &val32, sizeof(val32)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_checkpoint_freq, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val32 = DAOS_PROP_PO_CHECKPOINT_FREQ_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3570,7 +3506,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, d_iov_set(&value, &val32, sizeof(val32)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_checkpoint_thresh, &value); if (rc == -DER_NONEXIST && global_ver < 2) { /* needs to be upgraded */ - rc = 0; + rc = 0; val32 = DAOS_PROP_PO_CHECKPOINT_THRESH_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3587,7 +3523,7 @@ pool_prop_read(struct rdb_tx *tx, const struct pool_svc *svc, uint64_t bits, rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_reint_mode, &value); /* NB: would test global_ver < 2, but on master branch, code added after v3 bump. */ if (rc == -DER_NONEXIST && global_ver < 3) { /* needs to be upgraded */ - rc = 0; + rc = 0; val32 = DAOS_PROP_PO_REINT_MODE_DEFAULT; prop->dpp_entries[idx].dpe_flags |= DAOS_PROP_ENTRY_NOT_SET; } else if (rc != 0) { @@ -3766,7 +3702,7 @@ ds_pool_svc_ops_lookup(struct rdb_tx *tx, void *pool_svc, uuid_t pool_uuid, uuid struct ds_pool_svc_op_val op_val; d_iov_t val; bool duplicate = false; - int rc = 0; + int rc = 0; if (!svc) { rc = pool_svc_lookup_leader(pool_uuid, &svc, NULL /* hint */); @@ -3834,9 +3770,9 @@ static int pool_op_lookup(struct rdb_tx *tx, struct pool_svc *svc, crt_rpc_t *rpc, int pool_proto_ver, bool *is_dup, struct ds_pool_svc_op_val *valp) { - struct pool_op_in *in = crt_req_get(rpc); - crt_opcode_t opc = opc_get(rpc->cr_opc); - int rc = 0; + struct pool_op_in *in = crt_req_get(rpc); + crt_opcode_t opc = opc_get(rpc->cr_opc); + int rc = 0; D_ASSERT(pool_proto_ver >= POOL_PROTO_VER_WITH_SVC_OP_KEY); /* If the operation is not a write, skip (read-only ops not tracked for duplicates) */ @@ -3938,9 +3874,9 @@ static int pool_op_save(struct rdb_tx *tx, struct pool_svc *svc, crt_rpc_t *rpc, int pool_proto_ver, bool dup_op, int rc_in, struct ds_pool_svc_op_val *op_valp) { - struct pool_op_in *in = crt_req_get(rpc); - crt_opcode_t opc = opc_get(rpc->cr_opc); - int rc = 0; + struct pool_op_in *in = crt_req_get(rpc); + crt_opcode_t opc = opc_get(rpc->cr_opc); + int rc = 0; if (!dup_op) op_valp->ov_rc = rc_in; @@ -4018,7 +3954,7 @@ ds_pool_eval_self_heal_handler(crt_rpc_t *rpc) void ds_pool_create_handler(crt_rpc_t *rpc) { - struct pool_create_in *in = crt_req_get(rpc); + struct pool_create_in *in = crt_req_get(rpc); struct pool_create_out *out = crt_reply_get(rpc); struct pool_svc *svc; struct rdb_tx tx; @@ -4029,10 +3965,9 @@ ds_pool_create_handler(crt_rpc_t *rpc) uint32_t ndomains; uint32_t ntgts; uint32_t *domains; - int rc; + int rc; - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->pri_op.pi_uuid), rpc); + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->pri_op.pi_uuid), rpc); pool_create_in_get_data(rpc, &tgt_ranks, &prop, &ndomains, &ntgts, &domains); @@ -4047,8 +3982,7 @@ ds_pool_create_handler(crt_rpc_t *rpc) ABT_mutex_lock(svc->ps_rsvc.s_mutex); if (svc->ps_rsvc.s_stop) { - D_DEBUG(DB_MD, DF_UUID": pool service already stopping\n", - DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": pool service already stopping\n", DP_UUID(svc->ps_uuid)); D_GOTO(out_mutex, rc = -DER_CANCELED); } @@ -4059,7 +3993,7 @@ ds_pool_create_handler(crt_rpc_t *rpc) * errors. */ rc = rdb_campaign(svc->ps_rsvc.s_db); - D_DEBUG(DB_MD, DF_UUID": campaign: "DF_RC"\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": campaign: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); } if (ds_rsvc_get_state(&svc->ps_rsvc) == DS_RSVC_UP) { @@ -4090,12 +4024,10 @@ ds_pool_create_handler(crt_rpc_t *rpc) /* See if the DB has already been initialized. */ d_iov_set(&value, NULL /* buf */, 0 /* size */); - rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_map_buffer, - &value); + rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_map_buffer, &value); if (rc != -DER_NONEXIST) { if (rc == 0) - D_DEBUG(DB_MD, DF_UUID": db already initialized\n", - DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": db already initialized\n", DP_UUID(svc->ps_uuid)); else DL_ERROR(rc, DF_UUID ": failed to look up pool map", DP_UUID(svc->ps_uuid)); D_GOTO(out_tx, rc); @@ -4104,7 +4036,7 @@ ds_pool_create_handler(crt_rpc_t *rpc) /* Initialize the DB and the metadata for this pool. */ attr.dsa_class = RDB_KVS_GENERIC; attr.dsa_order = 8; - rc = rdb_tx_create_root(&tx, &attr); + rc = rdb_tx_create_root(&tx, &attr); if (rc != 0) D_GOTO(out_tx, rc); rc = init_pool_metadata(&tx, &svc->ps_root, ntgts, NULL /* group */, tgt_ranks, prop, @@ -4144,32 +4076,30 @@ ds_pool_create_handler(crt_rpc_t *rpc) } static int -pool_connect_iv_dist(struct pool_svc *svc, uuid_t pool_hdl, - uint64_t flags, uint64_t sec_capas, d_iov_t *cred, - uint32_t global_ver, uint32_t layout_ver) +pool_connect_iv_dist(struct pool_svc *svc, uuid_t pool_hdl, uint64_t flags, uint64_t sec_capas, + d_iov_t *cred, uint32_t global_ver, uint32_t layout_ver) { d_rank_t rank; - int rc; + int rc; - D_DEBUG(DB_MD, DF_UUID": bcasting\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": bcasting\n", DP_UUID(svc->ps_uuid)); rc = crt_group_rank(svc->ps_pool->sp_group, &rank); if (rc != 0) D_GOTO(out, rc); - rc = ds_pool_iv_conn_hdl_update(svc->ps_pool, pool_hdl, flags, - sec_capas, cred, global_ver, layout_ver); + rc = ds_pool_iv_conn_hdl_update(svc->ps_pool, pool_hdl, flags, sec_capas, cred, global_ver, + layout_ver); if (rc) { if (rc == -DER_SHUTDOWN) { - D_DEBUG(DB_MD, DF_UUID":"DF_UUID" some ranks stop.\n", + D_DEBUG(DB_MD, DF_UUID ":" DF_UUID " some ranks stop.\n", DP_UUID(svc->ps_uuid), DP_UUID(pool_hdl)); rc = 0; } D_GOTO(out, rc); } out: - D_DEBUG(DB_MD, DF_UUID": bcasted: "DF_RC"\n", DP_UUID(svc->ps_uuid), - DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": bcasted: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return rc; } @@ -4178,8 +4108,7 @@ bulk_cb(const struct crt_bulk_cb_info *cb_info) { ABT_eventual *eventual = cb_info->bci_arg; - ABT_eventual_set(*eventual, (void *)&cb_info->bci_rc, - sizeof(cb_info->bci_rc)); + ABT_eventual_set(*eventual, (void *)&cb_info->bci_rc, sizeof(cb_info->bci_rc)); return 0; } @@ -4204,46 +4133,46 @@ pool_query_set_rebuild_status_degraded(struct pool_svc *svc, struct daos_rebuild } /* Currently we only maintain compatibility between 2 metadata layout versions */ -#define NUM_POOL_VERSIONS 2 +#define NUM_POOL_VERSIONS 2 static void pool_connect_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_connect_in *in = crt_req_get(rpc); - struct pool_connect_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - uint32_t connectable; - uint32_t global_ver; - uint32_t obj_layout_ver; - struct rdb_tx tx; - d_iov_t key; - d_iov_t value; - struct pool_hdl *hdl = NULL; - uint32_t nhandles; - int skip_update = 0; - int rc; - daos_prop_t *prop = NULL; - uint64_t prop_bits; - struct daos_prop_entry *acl_entry; - struct d_ownership owner; - struct daos_prop_entry *owner_entry, *global_ver_entry; - struct daos_prop_entry *owner_grp_entry; - struct daos_prop_entry *obj_ver_entry; - uint64_t sec_capas = 0; - struct pool_metrics *metrics; - char *machine = NULL; - d_iov_t *credp; - uint64_t flags; - uint64_t query_bits; - crt_bulk_t bulk; - uint32_t cli_pool_version; - bool dup_op = false; - struct ds_pool_svc_op_val op_val; - bool transfer_map = false; - bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); - bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - bool fi_pass_nl_noreply; - bool fi_fail_nl_noreply; + struct pool_connect_in *in = crt_req_get(rpc); + struct pool_connect_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + uint32_t connectable; + uint32_t global_ver; + uint32_t obj_layout_ver; + struct rdb_tx tx; + d_iov_t key; + d_iov_t value; + struct pool_hdl *hdl = NULL; + uint32_t nhandles; + int skip_update = 0; + int rc; + daos_prop_t *prop = NULL; + uint64_t prop_bits; + struct daos_prop_entry *acl_entry; + struct d_ownership owner; + struct daos_prop_entry *owner_entry, *global_ver_entry; + struct daos_prop_entry *owner_grp_entry; + struct daos_prop_entry *obj_ver_entry; + uint64_t sec_capas = 0; + struct pool_metrics *metrics; + char *machine = NULL; + d_iov_t *credp; + uint64_t flags; + uint64_t query_bits; + crt_bulk_t bulk; + uint32_t cli_pool_version; + bool dup_op = false; + struct ds_pool_svc_op_val op_val; + bool transfer_map = false; + bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); + bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); + bool fi_pass_nl_noreply; + bool fi_fail_nl_noreply; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pci_op.pi_uuid), rpc, DP_UUID(in->pci_op.pi_hdl)); @@ -4282,12 +4211,11 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) /* Check if pool is being destroyed and not accepting connections */ d_iov_set(&value, &connectable, sizeof(connectable)); - rc = rdb_tx_lookup(&tx, &svc->ps_root, - &ds_pool_prop_connectable, &value); + rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_connectable, &value); if (rc != 0) goto out_lock; if (!connectable) { - D_ERROR(DF_UUID": being destroyed, not accepting connections\n", + D_ERROR(DF_UUID ": being destroyed, not accepting connections\n", DP_UUID(in->pci_op.pi_uuid)); D_GOTO(out_lock, rc = -DER_BUSY); } @@ -4325,7 +4253,7 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) skip_update = 1; } else { /* The existing one does not match the new one. */ - D_ERROR(DF_UUID": found conflicting pool handle\n", + D_ERROR(DF_UUID ": found conflicting pool handle\n", DP_UUID(in->pci_op.pi_uuid)); D_GOTO(out_lock, rc = -DER_EXIST); } @@ -4337,10 +4265,11 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) * all properties will update to IV. */ prop_bits = DAOS_PO_QUERY_PROP_ALL; - rc = pool_prop_read(&tx, svc, prop_bits, &prop); + rc = pool_prop_read(&tx, svc, prop_bits, &prop); if (rc != 0) { - D_ERROR(DF_UUID": cannot get access data for pool, " - "rc="DF_RC"\n", DP_UUID(in->pci_op.pi_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": cannot get access data for pool, " + "rc=" DF_RC "\n", + DP_UUID(in->pci_op.pi_uuid), DP_RC(rc)); D_GOTO(out_map_version, rc); } D_ASSERT(prop != NULL); @@ -4402,7 +4331,7 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) D_ASSERT(owner_grp_entry != NULL); D_ASSERT(owner_grp_entry->dpe_str != NULL); - owner.user = owner_entry->dpe_str; + owner.user = owner_entry->dpe_str; owner.group = owner_grp_entry->dpe_str; obj_ver_entry = daos_prop_entry_get(prop, DAOS_PROP_PO_OBJ_VERSION); @@ -4452,7 +4381,7 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) /* Take care of exclusive handles. */ if (nhandles != 0) { if (flags & DAOS_PC_EX) { - D_DEBUG(DB_MD, DF_UUID": others already connected\n", + D_DEBUG(DB_MD, DF_UUID ": others already connected\n", DP_UUID(in->pci_op.pi_uuid)); D_GOTO(out_map_version, rc = -DER_BUSY); } else { @@ -4461,8 +4390,7 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) * are non-exclusive. */ d_iov_set(&value, NULL, 0); - rc = rdb_tx_fetch(&tx, &svc->ps_handles, - RDB_PROBE_FIRST, NULL /* key_in */, + rc = rdb_tx_fetch(&tx, &svc->ps_handles, RDB_PROBE_FIRST, NULL /* key_in */, NULL /* key_out */, &value); if (rc != 0) D_GOTO(out_map_version, rc); @@ -4471,20 +4399,21 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) } } - D_DEBUG(DB_MD, DF_UUID "/" DF_UUID ": connecting to %s pool with flags " - DF_X64", sec_capas " DF_X64 "\n", + D_DEBUG(DB_MD, + DF_UUID "/" DF_UUID ": connecting to %s pool with flags " DF_X64 + ", sec_capas " DF_X64 "\n", DP_UUID(in->pci_op.pi_uuid), DP_UUID(in->pci_op.pi_hdl), svc->ps_pool->sp_immutable ? "immutable" : "regular", flags, sec_capas); rc = pool_connect_iv_dist(svc, in->pci_op.pi_hdl, flags, sec_capas, credp, global_ver, obj_layout_ver); if (rc == 0 && DAOS_FAIL_CHECK(DAOS_POOL_CONNECT_FAIL_CORPC)) { - D_DEBUG(DB_MD, DF_UUID": fault injected: DAOS_POOL_CONNECT_FAIL_CORPC\n", + D_DEBUG(DB_MD, DF_UUID ": fault injected: DAOS_POOL_CONNECT_FAIL_CORPC\n", DP_UUID(in->pci_op.pi_uuid)); rc = -DER_TIMEDOUT; } if (rc != 0) { - D_ERROR(DF_UUID": failed to connect to targets: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to connect to targets: " DF_RC "\n", DP_UUID(in->pci_op.pi_uuid), DP_RC(rc)); D_GOTO(out_map_version, rc); } @@ -4505,8 +4434,9 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) nhandles++; d_iov_set(&key, in->pci_op.pi_hdl, sizeof(uuid_t)); d_iov_set(&value, hdl, - svc->ps_global_version >= DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED ? - sizeof(struct pool_hdl) + hdl->ph_cred_len : sizeof(struct pool_hdl_v0)); + svc->ps_global_version >= DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED + ? sizeof(struct pool_hdl) + hdl->ph_cred_len + : sizeof(struct pool_hdl_v0)); D_DEBUG(DB_MD, "writing a pool connect handle in db, size %zu, pool version %u\n", value.iov_len, svc->ps_global_version); rc = rdb_tx_update(&tx, &svc->ps_handles, &key, &value); @@ -4541,8 +4471,8 @@ pool_connect_handler(crt_rpc_t *rpc, int handler_version) } if ((rc == 0) && (query_bits & DAOS_PO_QUERY_SPACE)) - rc = pool_space_query_bcast(rpc->cr_ctx, svc, in->pci_op.pi_hdl, &out->pco_space, - NULL); + rc = pool_space_query_bcast(dss_get_module_info()->dmi_ctx, svc, in->pci_op.pi_hdl, + &out->pco_space, NULL); out_lock: ABT_rwlock_unlock(svc->ps_lock); @@ -4606,20 +4536,19 @@ ds_pool_connect_handler(crt_rpc_t *rpc) } static int -pool_disconnect_bcast(crt_context_t ctx, struct pool_svc *svc, - uuid_t *pool_hdls, int n_pool_hdls) +pool_disconnect_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t *pool_hdls, int n_pool_hdls) { struct pool_tgt_disconnect_in *in; struct pool_tgt_disconnect_out *out; - crt_rpc_t *rpc; - int rc; + crt_rpc_t *rpc; + int rc; crt_opcode_t opc = POOL_TGT_DISCONNECT; rc = ds_pool_encode_opc(&opc); if (rc) return rc; - D_DEBUG(DB_MD, DF_UUID": bcasting\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": bcasting\n", DP_UUID(svc->ps_uuid)); rc = bcast_create(ctx, svc, opc, NULL, &rpc); if (rc != 0) @@ -4628,10 +4557,10 @@ pool_disconnect_bcast(crt_context_t ctx, struct pool_svc *svc, in = crt_req_get(rpc); uuid_copy(in->tdi_uuid, svc->ps_uuid); in->tdi_hdls.ca_arrays = pool_hdls; - in->tdi_hdls.ca_count = n_pool_hdls; - rc = dss_rpc_send(rpc); + in->tdi_hdls.ca_count = n_pool_hdls; + rc = dss_rpc_send(rpc); if (rc == 0 && DAOS_FAIL_CHECK(DAOS_POOL_DISCONNECT_FAIL_CORPC)) { - D_DEBUG(DB_MD, DF_UUID": fault injected: DAOS_POOL_DISCONNECT_FAIL_CORPC\n", + D_DEBUG(DB_MD, DF_UUID ": fault injected: DAOS_POOL_DISCONNECT_FAIL_CORPC\n", DP_UUID(svc->ps_uuid)); rc = -DER_TIMEDOUT; } @@ -4639,7 +4568,7 @@ pool_disconnect_bcast(crt_context_t ctx, struct pool_svc *svc, D_GOTO(out_rpc, rc); out = crt_reply_get(rpc); - rc = out->tdo_rc; + rc = out->tdo_rc; if (rc != 0) { D_ERROR(DF_UUID ": failed to disconnect from targets: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); @@ -4649,33 +4578,30 @@ pool_disconnect_bcast(crt_context_t ctx, struct pool_svc *svc, out_rpc: crt_req_decref(rpc); out: - D_DEBUG(DB_MD, DF_UUID": bcasted: "DF_RC"\n", DP_UUID(svc->ps_uuid), - DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": bcasted: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return rc; } static int -pool_disconnect_hdls(struct rdb_tx *tx, struct pool_svc *svc, uuid_t *hdl_uuids, - int n_hdl_uuids, crt_context_t ctx) +pool_disconnect_hdls(struct rdb_tx *tx, struct pool_svc *svc, uuid_t *hdl_uuids, int n_hdl_uuids, + crt_context_t ctx) { - d_iov_t value; - uint32_t nhandles; - struct pool_metrics *metrics; - int i; - int rc; + d_iov_t value; + uint32_t nhandles; + struct pool_metrics *metrics; + int i; + int rc; D_ASSERTF(n_hdl_uuids > 0, "%d\n", n_hdl_uuids); - D_DEBUG(DB_MD, DF_UUID": disconnecting %d hdls: hdl_uuids[0]="DF_UUID - "\n", DP_UUID(svc->ps_uuid), n_hdl_uuids, - DP_UUID(hdl_uuids[0])); + D_DEBUG(DB_MD, DF_UUID ": disconnecting %d hdls: hdl_uuids[0]=" DF_UUID "\n", + DP_UUID(svc->ps_uuid), n_hdl_uuids, DP_UUID(hdl_uuids[0])); /* * TODO: Send POOL_TGT_CLOSE_CONTS and somehow retry until every * container service has responded (through ds_pool). */ - rc = ds_cont_close_by_pool_hdls(svc->ps_uuid, hdl_uuids, n_hdl_uuids, - ctx); + rc = ds_cont_close_by_pool_hdls(svc->ps_uuid, hdl_uuids, n_hdl_uuids); if (rc != 0) D_GOTO(out, rc); @@ -4708,24 +4634,24 @@ pool_disconnect_hdls(struct rdb_tx *tx, struct pool_svc *svc, uuid_t *hdl_uuids, d_tm_dec_gauge(metrics->open_handles, n_hdl_uuids); out: if (rc == 0) - D_INFO(DF_UUID": success\n", DP_UUID(svc->ps_uuid)); + D_INFO(DF_UUID ": success\n", DP_UUID(svc->ps_uuid)); return rc; } static void pool_disconnect_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_disconnect_in *pdi = crt_req_get(rpc); - struct pool_disconnect_out *pdo = crt_reply_get(rpc); - struct pool_svc *svc; - struct rdb_tx tx; - d_iov_t key; - d_iov_t value; - bool dup_op = false; - struct ds_pool_svc_op_val op_val; - bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); - bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - int rc; + struct pool_disconnect_in *pdi = crt_req_get(rpc); + struct pool_disconnect_out *pdo = crt_reply_get(rpc); + struct pool_svc *svc; + struct rdb_tx tx; + d_iov_t key; + d_iov_t value; + bool dup_op = false; + struct ds_pool_svc_op_val op_val; + bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); + bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(pdi->pdi_op.pi_uuid), rpc, DP_UUID(pdi->pdi_op.pi_hdl)); @@ -4734,8 +4660,7 @@ pool_disconnect_handler(crt_rpc_t *rpc, int handler_version) D_DEBUG(DB_MD, DF_UUID ": client= " DF_UUID ", time=" DF_X64 "\n", DP_UUID(pdi->pdi_op.pi_uuid), DP_UUID(pdi->pdi_op.pi_cli_id), pdi->pdi_op.pi_time); - rc = pool_svc_lookup_leader(pdi->pdi_op.pi_uuid, &svc, - &pdo->pdo_op.po_hint); + rc = pool_svc_lookup_leader(pdi->pdi_op.pi_uuid, &svc, &pdo->pdo_op.po_hint); if (rc != 0) goto out; @@ -4763,8 +4688,8 @@ pool_disconnect_handler(crt_rpc_t *rpc, int handler_version) D_GOTO(out_commit, rc); } - rc = pool_disconnect_hdls(&tx, svc, &pdi->pdi_op.pi_hdl, - 1 /* n_hdl_uuids */, rpc->cr_ctx); + rc = pool_disconnect_hdls(&tx, svc, &pdi->pdi_op.pi_hdl, 1 /* n_hdl_uuids */, + dss_get_module_info()->dmi_ctx); if (rc != 0) goto out_commit; @@ -4821,14 +4746,14 @@ static int pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, struct daos_pool_space *ps, uint64_t *mem_file_bytes) { - struct pool_tgt_query_in *in; - struct pool_tgt_query_out *out; - crt_rpc_t *rpc; - struct pool_space_cache *cache = &svc->ps_space_cache; - uint64_t cur_time = 0; - bool unlock = false; - int rc; - crt_opcode_t opc = POOL_TGT_QUERY; + struct pool_tgt_query_in *in; + struct pool_tgt_query_out *out; + crt_rpc_t *rpc; + struct pool_space_cache *cache = &svc->ps_space_cache; + uint64_t cur_time = 0; + bool unlock = false; + int rc; + crt_opcode_t opc = POOL_TGT_QUERY; rc = ds_pool_encode_opc(&opc); if (rc) @@ -4848,7 +4773,7 @@ pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, unlock = true; } - D_DEBUG(DB_MD, DF_UUID": bcasting\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": bcasting\n", DP_UUID(svc->ps_uuid)); rc = bcast_create(ctx, svc, opc, NULL, &rpc); if (rc != 0) @@ -4859,7 +4784,7 @@ pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, uuid_copy(in->tqi_op.pi_hdl, pool_hdl); rc = dss_rpc_send(rpc); if (rc == 0 && DAOS_FAIL_CHECK(DAOS_POOL_QUERY_FAIL_CORPC)) { - D_DEBUG(DB_MD, DF_UUID": fault injected: DAOS_POOL_QUERY_FAIL_CORPC\n", + D_DEBUG(DB_MD, DF_UUID ": fault injected: DAOS_POOL_QUERY_FAIL_CORPC\n", DP_UUID(svc->ps_uuid)); rc = -DER_TIMEDOUT; } @@ -4867,7 +4792,7 @@ pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, goto out_rpc; out = crt_reply_get(rpc); - rc = out->tqo_rc; + rc = out->tqo_rc; D_ASSERT(ps != NULL); if (rc == 0) { *ps = out->tqo_space; @@ -4891,8 +4816,7 @@ pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, if (unlock) ABT_mutex_unlock(cache->psc_lock); - D_DEBUG(DB_MD, DF_UUID": bcasted: "DF_RC"\n", DP_UUID(svc->ps_uuid), - DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": bcasted: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return rc; } @@ -4903,18 +4827,18 @@ pool_space_query_bcast(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, * for another RPC request. */ static int -transfer_cont_buf(void *cont_buf, size_t cont_buf_size, struct pool_svc *svc, - crt_rpc_t *rpc, crt_bulk_t remote_bulk) -{ - daos_size_t remote_bulk_size; - d_iov_t cont_iov; - d_sg_list_t cont_sgl; - crt_bulk_t bulk = CRT_BULK_NULL; - struct crt_bulk_desc bulk_desc; - crt_bulk_opid_t bulk_opid; - ABT_eventual eventual; - int *status; - int rc; +transfer_cont_buf(void *cont_buf, size_t cont_buf_size, struct pool_svc *svc, crt_rpc_t *rpc, + crt_bulk_t remote_bulk) +{ + daos_size_t remote_bulk_size; + d_iov_t cont_iov; + d_sg_list_t cont_sgl; + crt_bulk_t bulk = CRT_BULK_NULL; + struct crt_bulk_desc bulk_desc; + crt_bulk_opid_t bulk_opid; + ABT_eventual eventual; + int *status; + int rc; D_ASSERT(cont_buf_size > 0); @@ -4923,28 +4847,28 @@ transfer_cont_buf(void *cont_buf, size_t cont_buf_size, struct pool_svc *svc, if (rc != 0) D_GOTO(out, rc); if (remote_bulk_size < cont_buf_size) { - D_ERROR(DF_UUID": remote container buffer("DF_U64") < required (%zu)\n", + D_ERROR(DF_UUID ": remote container buffer(" DF_U64 ") < required (%zu)\n", DP_UUID(svc->ps_uuid), remote_bulk_size, cont_buf_size); D_GOTO(out, rc = -DER_TRUNC); } d_iov_set(&cont_iov, cont_buf, cont_buf_size); - cont_sgl.sg_nr = 1; + cont_sgl.sg_nr = 1; cont_sgl.sg_nr_out = 0; - cont_sgl.sg_iovs = &cont_iov; + cont_sgl.sg_iovs = &cont_iov; rc = crt_bulk_create(rpc->cr_ctx, &cont_sgl, CRT_BULK_RO, &bulk); if (rc != 0) D_GOTO(out, rc); /* Prepare for crt_bulk_transfer(). */ - bulk_desc.bd_rpc = rpc; - bulk_desc.bd_bulk_op = CRT_BULK_PUT; + bulk_desc.bd_rpc = rpc; + bulk_desc.bd_bulk_op = CRT_BULK_PUT; bulk_desc.bd_remote_hdl = remote_bulk; bulk_desc.bd_remote_off = 0; - bulk_desc.bd_local_hdl = bulk; - bulk_desc.bd_local_off = 0; - bulk_desc.bd_len = cont_iov.iov_len; + bulk_desc.bd_local_hdl = bulk; + bulk_desc.bd_local_off = 0; + bulk_desc.bd_len = cont_iov.iov_len; rc = ABT_eventual_create(sizeof(*status), &eventual); if (rc != ABT_SUCCESS) @@ -4982,25 +4906,24 @@ transfer_cont_buf(void *cont_buf, size_t cont_buf_size, struct pool_svc *svc, * */ int -ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, - struct daos_pool_cont_info **containers, +ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, struct daos_pool_cont_info **containers, uint64_t *ncontainers) { - int rc; - struct rsvc_client client; - crt_endpoint_t ep; - struct dss_module_info *info = dss_get_module_info(); - crt_rpc_t *rpc; - struct pool_list_cont_in *in; - struct pool_list_cont_out *out; - uint64_t resp_ncont = 1024; - struct daos_pool_cont_info *resp_cont = NULL; - uint64_t ncont; - crt_bulk_t bulk; - uuid_t no_uuid; - uint64_t req_time = 0; - - D_DEBUG(DB_MGMT, DF_UUID": Getting container list\n", DP_UUID(uuid)); + int rc; + struct rsvc_client client; + crt_endpoint_t ep; + struct dss_module_info *info = dss_get_module_info(); + crt_rpc_t *rpc; + struct pool_list_cont_in *in; + struct pool_list_cont_out *out; + uint64_t resp_ncont = 1024; + struct daos_pool_cont_info *resp_cont = NULL; + uint64_t ncont; + crt_bulk_t bulk; + uuid_t no_uuid; + uint64_t req_time = 0; + + D_DEBUG(DB_MGMT, DF_UUID ": Getting container list\n", DP_UUID(uuid)); uuid_clear(no_uuid); *containers = NULL; @@ -5010,10 +4933,10 @@ ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, rechoose: ep.ep_grp = NULL; /* primary group */ - rc = rsvc_client_choose(&client, &ep); + rc = rsvc_client_choose(&client, &ep); if (rc != 0) { - D_ERROR(DF_UUID": cannot find pool service: "DF_RC"\n", - DP_UUID(uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": cannot find pool service: " DF_RC "\n", DP_UUID(uuid), + DP_RC(rc)); goto out_client; } @@ -5040,7 +4963,7 @@ ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, pool_list_cont_in_set_data(rpc, bulk, ncont); - rc = dss_rpc_send(rpc); + rc = dss_rpc_send(rpc); out = crt_reply_get(rpc); D_ASSERT(out != NULL); @@ -5063,11 +4986,10 @@ ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, crt_req_decref(rpc); D_GOTO(realloc_resp, rc); } else if (rc != 0) { - D_ERROR(DF_UUID": failed to get container list for pool: %d\n", - DP_UUID(uuid), rc); + D_ERROR(DF_UUID ": failed to get container list for pool: %d\n", DP_UUID(uuid), rc); } else { *ncontainers = out->plco_ncont; - *containers = resp_cont; + *containers = resp_cont; } list_cont_bulk_destroy(bulk); @@ -5082,7 +5004,8 @@ ds_pool_svc_list_cont(uuid_t uuid, d_rank_list_t *ranks, return rc; } -static bool is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid); +static bool +is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid); /* CaRT RPC handler for pool container listing * Requires a pool handle (except for rebuild). @@ -5090,23 +5013,22 @@ static bool is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid); static void pool_list_cont_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_list_cont_in *in = crt_req_get(rpc); - struct pool_list_cont_out *out = crt_reply_get(rpc); - struct daos_pool_cont_info *cont_buf = NULL; - uint64_t ncont = 0; - struct pool_svc *svc; - uint64_t ncont_in; - crt_bulk_t bulk; - struct rdb_tx tx; - d_iov_t key; - d_iov_t value; - int rc; + struct pool_list_cont_in *in = crt_req_get(rpc); + struct pool_list_cont_out *out = crt_reply_get(rpc); + struct daos_pool_cont_info *cont_buf = NULL; + uint64_t ncont = 0; + struct pool_svc *svc; + uint64_t ncont_in; + crt_bulk_t bulk; + struct rdb_tx tx; + d_iov_t key; + d_iov_t value; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->plci_op.pi_uuid), rpc, DP_UUID(in->plci_op.pi_hdl)); - rc = pool_svc_lookup_leader(in->plci_op.pi_uuid, &svc, - &out->plco_op.po_hint); + rc = pool_svc_lookup_leader(in->plci_op.pi_uuid, &svc, &out->plco_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -5126,14 +5048,13 @@ pool_list_cont_handler(crt_rpc_t *rpc, int handler_version) * connect the pool, so we only verify the non-rebuild * pool. */ - if (!is_pool_from_srv(in->plci_op.pi_uuid, - in->plci_op.pi_hdl)) { + if (!is_pool_from_srv(in->plci_op.pi_uuid, in->plci_op.pi_hdl)) { d_iov_set(&key, in->plci_op.pi_hdl, sizeof(uuid_t)); d_iov_set(&value, NULL, 0); rc = rdb_tx_lookup(&tx, &svc->ps_handles, &key, &value); if (rc == -DER_NONEXIST) rc = -DER_NO_HDL; - /* defer goto out_svc until unlock/tx_end */ + /* defer goto out_svc until unlock/tx_end */ } ABT_rwlock_unlock(svc->ps_lock); @@ -5156,7 +5077,7 @@ pool_list_cont_handler(crt_rpc_t *rpc, int handler_version) } else { size_t nbytes = ncont * sizeof(struct daos_pool_cont_info); - D_DEBUG(DB_MD, DF_UUID": hdl="DF_UUID": has %"PRIu64 "containers\n", + D_DEBUG(DB_MD, DF_UUID ": hdl=" DF_UUID ": has %" PRIu64 "containers\n", DP_UUID(in->plci_op.pi_uuid), DP_UUID(in->plci_op.pi_hdl), ncont); /* Send any results only if client provided a handle */ @@ -5174,7 +5095,7 @@ pool_list_cont_handler(crt_rpc_t *rpc, int handler_version) pool_svc_put_leader(svc); out: out->plco_op.po_rc = rc; - out->plco_ncont = ncont; + out->plco_ncont = ncont; D_DEBUG(DB_MD, DF_UUID ": replying rpc: %p %d\n", DP_UUID(in->plci_op.pi_uuid), rpc, rc); crt_reply_send(rpc); } @@ -5189,15 +5110,15 @@ ds_pool_list_cont_handler(crt_rpc_t *rpc) static bool pool_cont_filter_is_valid(uuid_t pool_uuid, daos_pool_cont_filter_t *filt) { - uint32_t i; + uint32_t i; /* TODO: decide if filt == NULL is ok especially on client side */ D_ASSERT(filt != NULL); - D_DEBUG(DB_MD, DF_UUID": filter with %u parts, combine with logical %s\n", + D_DEBUG(DB_MD, DF_UUID ": filter with %u parts, combine with logical %s\n", DP_UUID(pool_uuid), filt->pcf_nparts, (filt->pcf_combine_func == 0) ? "AND" : "OR"); if ((filt->pcf_nparts > 0) && (filt->pcf_parts == NULL)) { - D_ERROR(DF_UUID": filter has %u parts but pcf_parts is NULL\n", DP_UUID(pool_uuid), + D_ERROR(DF_UUID ": filter has %u parts but pcf_parts is NULL\n", DP_UUID(pool_uuid), filt->pcf_nparts); return false; } @@ -5205,20 +5126,18 @@ pool_cont_filter_is_valid(uuid_t pool_uuid, daos_pool_cont_filter_t *filt) daos_pool_cont_filter_part_t *part = filt->pcf_parts[i]; if (part->pcfp_key >= PCF_KEY_MAX) { - D_ERROR(DF_UUID": filter part key %u is outside of valid range %u..%u\n", + D_ERROR(DF_UUID ": filter part key %u is outside of valid range %u..%u\n", DP_UUID(pool_uuid), part->pcfp_key, 0, (PCF_KEY_MAX - 1)); return false; } if (part->pcfp_func >= PCF_FUNC_MAX) { - D_ERROR(DF_UUID": filter part func %u is outside of valid range %u..%u\n", + D_ERROR(DF_UUID ": filter part func %u is outside of valid range %u..%u\n", DP_UUID(pool_uuid), part->pcfp_key, 0, (PCF_FUNC_MAX - 1)); return false; } - D_DEBUG(DB_MD, DF_UUID": filter part %u: key(%s) %s "DF_U64"\n", - DP_UUID(pool_uuid), i, - daos_pool_cont_filter_key_str(part->pcfp_key), - daos_pool_cont_filter_func_str(part->pcfp_func), - part->pcfp_val64); + D_DEBUG(DB_MD, DF_UUID ": filter part %u: key(%s) %s " DF_U64 "\n", + DP_UUID(pool_uuid), i, daos_pool_cont_filter_key_str(part->pcfp_key), + daos_pool_cont_filter_func_str(part->pcfp_func), part->pcfp_val64); } return true; @@ -5230,18 +5149,18 @@ pool_cont_filter_is_valid(uuid_t pool_uuid, daos_pool_cont_filter_t *filt) static void pool_filter_cont_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_filter_cont_in *in = crt_req_get(rpc); - struct pool_filter_cont_out *out = crt_reply_get(rpc); - struct daos_pool_cont_info2 *cont_buf = NULL; - uint64_t ncont = 0; - struct pool_svc *svc; - uint64_t ncont_in; - crt_bulk_t bulk; - daos_pool_cont_filter_t *filt_in; - struct rdb_tx tx; - d_iov_t key; - d_iov_t value; - int rc; + struct pool_filter_cont_in *in = crt_req_get(rpc); + struct pool_filter_cont_out *out = crt_reply_get(rpc); + struct daos_pool_cont_info2 *cont_buf = NULL; + uint64_t ncont = 0; + struct pool_svc *svc; + uint64_t ncont_in; + crt_bulk_t bulk; + daos_pool_cont_filter_t *filt_in; + struct rdb_tx tx; + d_iov_t key; + d_iov_t value; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pfci_op.pi_uuid), rpc, DP_UUID(in->pfci_op.pi_hdl)); @@ -5266,14 +5185,13 @@ pool_filter_cont_handler(crt_rpc_t *rpc, int handler_version) * connect the pool, so we only verify the non-rebuild * pool. */ - if (!is_pool_from_srv(in->pfci_op.pi_uuid, - in->pfci_op.pi_hdl)) { + if (!is_pool_from_srv(in->pfci_op.pi_uuid, in->pfci_op.pi_hdl)) { d_iov_set(&key, in->pfci_op.pi_hdl, sizeof(uuid_t)); d_iov_set(&value, NULL, 0); rc = rdb_tx_lookup(&tx, &svc->ps_handles, &key, &value); if (rc == -DER_NONEXIST) rc = -DER_NO_HDL; - /* defer goto out_svc until unlock/tx_end */ + /* defer goto out_svc until unlock/tx_end */ } ABT_rwlock_unlock(svc->ps_lock); @@ -5303,7 +5221,7 @@ pool_filter_cont_handler(crt_rpc_t *rpc, int handler_version) } else { size_t nbytes = ncont * sizeof(struct daos_pool_cont_info2); - D_DEBUG(DB_MD, DF_UUID": hdl="DF_UUID": %"PRIu64" matching containers\n", + D_DEBUG(DB_MD, DF_UUID ": hdl=" DF_UUID ": %" PRIu64 " matching containers\n", DP_UUID(in->pfci_op.pi_uuid), DP_UUID(in->pfci_op.pi_hdl), ncont); /* Send any results only if client provided a handle */ @@ -5320,7 +5238,7 @@ pool_filter_cont_handler(crt_rpc_t *rpc, int handler_version) pool_svc_put_leader(svc); out: out->pfco_op.po_rc = rc; - out->pfco_ncont = ncont; + out->pfco_ncont = ncont; D_DEBUG(DB_MD, DF_UUID ": replying rpc: %p %d\n", DP_UUID(in->pfci_op.pi_uuid), rpc, rc); crt_reply_send(rpc); } @@ -5334,26 +5252,25 @@ ds_pool_filter_cont_handler(crt_rpc_t *rpc) static void pool_query_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_query_in *in = crt_req_get(rpc); - struct pool_query_out *out = crt_reply_get(rpc); - daos_prop_t *prop = NULL; - struct ds_pool_map_bc *map_bc; - uint32_t map_version = 0; - struct pool_svc *svc; - struct pool_metrics *metrics; - struct rdb_tx tx; - d_iov_t key; - d_iov_t value; - crt_bulk_t bulk; - uint64_t query_bits; - int rc; - struct daos_prop_entry *entry; + struct pool_query_in *in = crt_req_get(rpc); + struct pool_query_out *out = crt_reply_get(rpc); + daos_prop_t *prop = NULL; + struct ds_pool_map_bc *map_bc; + uint32_t map_version = 0; + struct pool_svc *svc; + struct pool_metrics *metrics; + struct rdb_tx tx; + d_iov_t key; + d_iov_t value; + crt_bulk_t bulk; + uint64_t query_bits; + int rc; + struct daos_prop_entry *entry; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pqi_op.pi_uuid), rpc, DP_UUID(in->pqi_op.pi_hdl)); - rc = pool_svc_lookup_leader(in->pqi_op.pi_uuid, &svc, - &out->pqo_op.po_hint); + rc = pool_svc_lookup_leader(in->pqi_op.pi_uuid, &svc, &out->pqo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -5376,8 +5293,7 @@ pool_query_handler(crt_rpc_t *rpc, int handler_version) * the non-rebuild pool. Server-to-server calls also don't have a * handle. */ - if (daos_rpc_from_client(rpc) && - !is_pool_from_srv(in->pqi_op.pi_uuid, in->pqi_op.pi_hdl)) { + if (daos_rpc_from_client(rpc) && !is_pool_from_srv(in->pqi_op.pi_uuid, in->pqi_op.pi_hdl)) { d_iov_set(&key, in->pqi_op.pi_hdl, sizeof(uuid_t)); d_iov_set(&value, NULL, 0); rc = rdb_tx_lookup(&tx, &svc->ps_handles, &key, &value); @@ -5406,9 +5322,9 @@ pool_query_handler(crt_rpc_t *rpc, int handler_version) out->pqo_prop = prop; if (unlikely(DAOS_FAIL_CHECK(DAOS_FORCE_PROP_VERIFY) && prop != NULL)) { - daos_prop_t *iv_prop = NULL; - struct daos_prop_entry *iv_entry; - int i; + daos_prop_t *iv_prop = NULL; + struct daos_prop_entry *iv_entry; + int i; D_ALLOC_PTR(iv_prop); if (iv_prop == NULL) @@ -5416,38 +5332,31 @@ pool_query_handler(crt_rpc_t *rpc, int handler_version) rc = ds_pool_iv_prop_fetch(svc->ps_pool, iv_prop); if (rc) { - D_ERROR("ds_pool_iv_prop_fetch failed "DF_RC"\n", - DP_RC(rc)); + D_ERROR("ds_pool_iv_prop_fetch failed " DF_RC "\n", DP_RC(rc)); daos_prop_free(iv_prop); D_GOTO(out_lock, rc); } for (i = 0; i < prop->dpp_nr; i++) { - entry = &prop->dpp_entries[i]; - iv_entry = daos_prop_entry_get(iv_prop, - entry->dpe_type); + entry = &prop->dpp_entries[i]; + iv_entry = daos_prop_entry_get(iv_prop, entry->dpe_type); D_ASSERT(iv_entry != NULL); switch (entry->dpe_type) { case DAOS_PROP_PO_LABEL: - D_ASSERT(strlen(entry->dpe_str) <= - DAOS_PROP_LABEL_MAX_LEN); + D_ASSERT(strlen(entry->dpe_str) <= DAOS_PROP_LABEL_MAX_LEN); if (strncmp(entry->dpe_str, iv_entry->dpe_str, DAOS_PROP_LABEL_MAX_LEN) != 0) { - D_ERROR("mismatch %s - %s.\n", - entry->dpe_str, + D_ERROR("mismatch %s - %s.\n", entry->dpe_str, iv_entry->dpe_str); rc = -DER_IO; } break; case DAOS_PROP_PO_OWNER: case DAOS_PROP_PO_OWNER_GROUP: - D_ASSERT(strlen(entry->dpe_str) <= - DAOS_ACL_MAX_PRINCIPAL_LEN); + D_ASSERT(strlen(entry->dpe_str) <= DAOS_ACL_MAX_PRINCIPAL_LEN); if (strncmp(entry->dpe_str, iv_entry->dpe_str, - DAOS_ACL_MAX_PRINCIPAL_BUF_LEN) - != 0) { - D_ERROR("mismatch %s - %s.\n", - entry->dpe_str, + DAOS_ACL_MAX_PRINCIPAL_BUF_LEN) != 0) { + D_ERROR("mismatch %s - %s.\n", entry->dpe_str, iv_entry->dpe_str); rc = -DER_IO; } @@ -5475,29 +5384,25 @@ pool_query_handler(crt_rpc_t *rpc, int handler_version) case DAOS_PROP_PO_SVC_OPS_ENTRY_AGE: case DAOS_PROP_PO_DATA_THRESH: if (entry->dpe_val != iv_entry->dpe_val) { - D_ERROR("type %d mismatch "DF_U64" - " - DF_U64".\n", entry->dpe_type, - entry->dpe_val, - iv_entry->dpe_val); + D_ERROR("type %d mismatch " DF_U64 " - " DF_U64 ".\n", + entry->dpe_type, entry->dpe_val, iv_entry->dpe_val); rc = -DER_IO; - } + } break; case DAOS_PROP_PO_ACL: - if (daos_prop_entry_cmp_acl(entry, - iv_entry) != 0) + if (daos_prop_entry_cmp_acl(entry, iv_entry) != 0) rc = -DER_IO; break; case DAOS_PROP_PO_SVC_LIST: break; default: - D_ASSERTF(0, "bad dpe_type %d\n", - entry->dpe_type); + D_ASSERTF(0, "bad dpe_type %d\n", entry->dpe_type); break; }; } daos_prop_free(iv_prop); if (rc) { - D_ERROR("iv_prop verify failed "DF_RC"\n", DP_RC(rc)); + D_ERROR("iv_prop verify failed " DF_RC "\n", DP_RC(rc)); D_GOTO(out_lock, rc); } } @@ -5528,8 +5433,8 @@ pool_query_handler(crt_rpc_t *rpc, int handler_version) if (query_bits & DAOS_PO_QUERY_SPACE) { uint64_t *mem_file_bytes = handler_version >= 7 ? &out->pqo_mem_file_bytes : NULL; - rc = pool_space_query_bcast(rpc->cr_ctx, svc, in->pqi_op.pi_hdl, &out->pqo_space, - mem_file_bytes); + rc = pool_space_query_bcast(dss_get_module_info()->dmi_ctx, svc, in->pqi_op.pi_hdl, + &out->pqo_space, mem_file_bytes); if (unlikely(rc)) goto out_svc; @@ -5570,13 +5475,20 @@ static daos_target_state_t enum_pool_comp_state_to_tgt_state(int tgt_state) { switch (tgt_state) { - case PO_COMP_ST_UNKNOWN: return DAOS_TS_UNKNOWN; - case PO_COMP_ST_NEW: return DAOS_TS_NEW; - case PO_COMP_ST_UP: return DAOS_TS_UP; - case PO_COMP_ST_UPIN: return DAOS_TS_UP_IN; - case PO_COMP_ST_DOWN: return DAOS_TS_DOWN; - case PO_COMP_ST_DOWNOUT: return DAOS_TS_DOWN_OUT; - case PO_COMP_ST_DRAIN: return DAOS_TS_DRAIN; + case PO_COMP_ST_UNKNOWN: + return DAOS_TS_UNKNOWN; + case PO_COMP_ST_NEW: + return DAOS_TS_NEW; + case PO_COMP_ST_UP: + return DAOS_TS_UP; + case PO_COMP_ST_UPIN: + return DAOS_TS_UP_IN; + case PO_COMP_ST_DOWN: + return DAOS_TS_DOWN; + case PO_COMP_ST_DOWNOUT: + return DAOS_TS_DOWN_OUT; + case PO_COMP_ST_DRAIN: + return DAOS_TS_DRAIN; } return DAOS_TS_UNKNOWN; @@ -5586,15 +5498,15 @@ static int pool_query_tgt_space(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, d_rank_t rank, uint32_t tgt_idx, struct daos_space *ds, uint64_t *mem_file_bytes) { - struct pool_tgt_query_in *in; - struct pool_tgt_query_out *out; - crt_rpc_t *rpc; - crt_endpoint_t tgt_ep = { 0 }; - crt_opcode_t opcode = POOL_TGT_QUERY; - int rc; + struct pool_tgt_query_in *in; + struct pool_tgt_query_out *out; + crt_rpc_t *rpc; + crt_endpoint_t tgt_ep = {0}; + crt_opcode_t opcode = POOL_TGT_QUERY; + int rc; - D_DEBUG(DB_MD, DF_UUID": query target for rank:%u tgt:%u\n", - DP_UUID(svc->ps_uuid), rank, tgt_idx); + D_DEBUG(DB_MD, DF_UUID ": query target for rank:%u tgt:%u\n", DP_UUID(svc->ps_uuid), rank, + tgt_idx); rc = ds_pool_encode_opc(&opcode); if (rc) @@ -5602,9 +5514,9 @@ pool_query_tgt_space(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, d tgt_ep.ep_rank = rank; tgt_ep.ep_tag = daos_rpc_tag(DAOS_REQ_TGT, tgt_idx); - rc = crt_req_create(ctx, &tgt_ep, opcode, &rpc); + rc = crt_req_create(ctx, &tgt_ep, opcode, &rpc); if (rc) { - D_ERROR("crt_req_create failed: "DF_RC"\n", DP_RC(rc)); + D_ERROR("crt_req_create failed: " DF_RC "\n", DP_RC(rc)); return rc; } @@ -5635,22 +5547,21 @@ pool_query_tgt_space(crt_context_t ctx, struct pool_svc *svc, uuid_t pool_hdl, d static void pool_query_info_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_query_info_in *in = crt_req_get(rpc); - struct pool_query_info_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct pool_target *target = NULL; - int tgt_state; - uint32_t rank; - uint32_t tgt; - int rc; + struct pool_query_info_in *in = crt_req_get(rpc); + struct pool_query_info_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct pool_target *target = NULL; + int tgt_state; + uint32_t rank; + uint32_t tgt; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pqii_op.pi_uuid), rpc, DP_UUID(in->pqii_op.pi_hdl)); pool_query_info_in_get_data(rpc, &rank, &tgt); - rc = pool_svc_lookup_leader(in->pqii_op.pi_uuid, &svc, - &out->pqio_op.po_hint); + rc = pool_svc_lookup_leader(in->pqii_op.pi_uuid, &svc, &out->pqio_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -5668,8 +5579,8 @@ pool_query_info_handler(crt_rpc_t *rpc, int handler_version) D_ASSERT(target != NULL); - tgt_state = target->ta_comp.co_status; - out->pqio_state = enum_pool_comp_state_to_tgt_state(tgt_state); + tgt_state = target->ta_comp.co_status; + out->pqio_state = enum_pool_comp_state_to_tgt_state(tgt_state); out->pqio_op.po_map_version = pool_map_get_version(svc->ps_pool->sp_map); ABT_rwlock_unlock(svc->ps_pool->sp_lock); @@ -5677,8 +5588,8 @@ pool_query_info_handler(crt_rpc_t *rpc, int handler_version) if (tgt_state == PO_COMP_ST_UPIN) { uint64_t *mem_file_bytes = handler_version >= 7 ? &out->pqio_mem_file_bytes : NULL; - rc = pool_query_tgt_space(rpc->cr_ctx, svc, in->pqii_op.pi_hdl, rank, tgt, - &out->pqio_space, mem_file_bytes); + rc = pool_query_tgt_space(dss_get_module_info()->dmi_ctx, svc, in->pqii_op.pi_hdl, + rank, tgt, &out->pqio_space, mem_file_bytes); if (rc) DL_ERROR(rc, DF_UUID ": Failed to query rank:%u, tgt:%d", DP_UUID(in->pqii_op.pi_uuid), rank, tgt); @@ -5716,21 +5627,19 @@ ds_pool_query_info_handler(crt_rpc_t *rpc) void ds_pool_prop_get_handler(crt_rpc_t *rpc) { - struct pool_prop_get_in *in = crt_req_get(rpc); - struct pool_prop_get_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct rdb_tx tx; - uint64_t query_bits; - int rc; - daos_prop_t *prop = NULL; + struct pool_prop_get_in *in = crt_req_get(rpc); + struct pool_prop_get_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct rdb_tx tx; + uint64_t query_bits; + int rc; + daos_prop_t *prop = NULL; - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->pgi_op.pi_uuid), rpc); + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->pgi_op.pi_uuid), rpc); pool_prop_get_in_get_data(rpc, &query_bits); - rc = pool_svc_lookup_leader(in->pgi_op.pi_uuid, &svc, - &out->pgo_op.po_hint); + rc = pool_svc_lookup_leader(in->pgi_op.pi_uuid, &svc, &out->pgo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -5766,20 +5675,19 @@ ds_pool_prop_get_handler(crt_rpc_t *rpc) void ds_pool_prop_set_handler(crt_rpc_t *rpc) { - struct pool_prop_set_in *in = crt_req_get(rpc); - struct pool_prop_set_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct rdb_tx tx; - daos_prop_t *prop_in = NULL; - daos_prop_t *prop = NULL; - bool dup_op = false; - struct ds_pool_svc_op_val op_val; - bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); - bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - int rc; - - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->psi_op.pi_uuid), rpc); + struct pool_prop_set_in *in = crt_req_get(rpc); + struct pool_prop_set_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct rdb_tx tx; + daos_prop_t *prop_in = NULL; + daos_prop_t *prop = NULL; + bool dup_op = false; + struct ds_pool_svc_op_val op_val; + bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); + bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); + int rc; + + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->psi_op.pi_uuid), rpc); pool_prop_set_in_get_data(rpc, &prop_in); @@ -5788,8 +5696,7 @@ ds_pool_prop_set_handler(crt_rpc_t *rpc) D_GOTO(out, rc); if (!daos_prop_valid(prop_in, true /* pool */, true /* input */)) { - D_ERROR(DF_UUID": invalid properties input\n", - DP_UUID(in->psi_op.pi_uuid)); + D_ERROR(DF_UUID ": invalid properties input\n", DP_UUID(in->psi_op.pi_uuid)); D_GOTO(out_svc, rc = -DER_INVAL); } @@ -5807,7 +5714,7 @@ ds_pool_prop_set_handler(crt_rpc_t *rpc) rc = pool_prop_write(&tx, &svc->ps_root, prop_in); if (rc != 0) { - D_ERROR(DF_UUID": failed to write prop for pool: %d\n", + D_ERROR(DF_UUID ": failed to write prop for pool: %d\n", DP_UUID(in->psi_op.pi_uuid), rc); D_GOTO(out_commit, rc); } @@ -5828,7 +5735,7 @@ ds_pool_prop_set_handler(crt_rpc_t *rpc) /* Read all props & update prop IV */ rc = pool_prop_read(&tx, svc, DAOS_PO_QUERY_PROP_ALL, &prop); if (rc != 0) { - D_ERROR(DF_UUID": failed to read prop for pool, rc=%d\n", + D_ERROR(DF_UUID ": failed to read prop for pool, rc=%d\n", DP_UUID(in->psi_op.pi_uuid), rc); D_GOTO(out_lock, rc); } @@ -5845,8 +5752,9 @@ ds_pool_prop_set_handler(crt_rpc_t *rpc) if (!rc && prop != NULL) { rc = ds_pool_iv_prop_update(svc->ps_pool, prop); if (rc) - D_ERROR(DF_UUID": failed to update prop IV for pool, " - "%d.\n", DP_UUID(in->psi_op.pi_uuid), rc); + D_ERROR(DF_UUID ": failed to update prop IV for pool, " + "%d.\n", + DP_UUID(in->psi_op.pi_uuid), rc); daos_prop_free(prop); } /* If self_heal.exclude is set, resume event handling. */ @@ -5882,7 +5790,7 @@ static int pool_upgrade_one_prop(struct rdb_tx *tx, struct pool_svc *svc, bool *need_commit, d_iov_t *prop_iov, d_iov_t *value) { - int rc; + int rc; rc = rdb_tx_lookup(tx, &svc->ps_root, prop_iov, value); if (rc && rc != -DER_NONEXIST) { @@ -5936,23 +5844,22 @@ static int pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, crt_rpc_t *rpc, uuid_t srv_pool_hdl, uuid_t srv_cont_hdl) { - d_iov_t value; - uint64_t val; - uint32_t val32; - uuid_t valuuid; - int rc; - bool need_commit = false; - uuid_t *hdl_uuids = NULL; - size_t hdl_uuids_size; - int n_hdl_uuids = 0; - uint32_t connectable; - uint32_t svc_ops_enabled = 0; - uint32_t svc_ops_age; - uint32_t svc_ops_max; + d_iov_t value; + uint64_t val; + uint32_t val32; + uuid_t valuuid; + int rc; + bool need_commit = false; + uuid_t *hdl_uuids = NULL; + size_t hdl_uuids_size; + int n_hdl_uuids = 0; + uint32_t connectable; + uint32_t svc_ops_enabled = 0; + uint32_t svc_ops_age; + uint32_t svc_ops_max; if (rpc) { - rc = find_hdls_to_evict(tx, svc, &hdl_uuids, &hdl_uuids_size, - &n_hdl_uuids, NULL); + rc = find_hdls_to_evict(tx, svc, &hdl_uuids, &hdl_uuids_size, &n_hdl_uuids, NULL); if (rc) return rc; D_DEBUG(DB_MD, "number of handles found was: %d\n", n_hdl_uuids); @@ -5960,15 +5867,14 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr if (n_hdl_uuids > 0) { rc = pool_disconnect_hdls(tx, svc, hdl_uuids, n_hdl_uuids, - rpc->cr_ctx); + dss_get_module_info()->dmi_ctx); if (rc != 0) D_GOTO(out_free, rc); need_commit = true; } d_iov_set(&value, &connectable, sizeof(connectable)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_connectable, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_connectable, &value); if (rc) D_GOTO(out_free, rc); @@ -5978,11 +5884,11 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr */ if (connectable > 0) { connectable = 0; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_connectable, - &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_connectable, &value); if (rc) { - D_ERROR(DF_UUID": failed to set connectable of pool " - "%d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to set connectable of pool " + "%d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -5994,26 +5900,27 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val = DAOS_PROP_PO_DATA_THRESH_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_data_thresh, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_data_thresh, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade 'data threshold' " - "of pool, %d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade 'data threshold' " + "of pool, %d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; } d_iov_set(&value, &val, sizeof(val)); - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_redun_fac, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_redun_fac, &value); if (rc && rc != -DER_NONEXIST) { D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val = DAOS_PROP_PO_REDUN_FAC_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_redun_fac, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_redun_fac, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade redundancy factor of pool, " - "%d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade redundancy factor of pool, " + "%d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -6024,10 +5931,11 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val = DAOS_PROP_PO_EC_PDA_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_ec_pda, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_ec_pda, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade EC performance domain " - "affinity of pool, %d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade EC performance domain " + "affinity of pool, %d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -6038,10 +5946,11 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val = DAOS_PROP_PO_RP_PDA_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_rp_pda, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_rp_pda, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade RP performance domain " - "affinity of pool, %d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade RP performance domain " + "affinity of pool, %d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -6055,7 +5964,7 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr rc = rdb_get_ranks(svc->ps_rsvc.s_db, &replicas); if (rc != 0) { - D_ERROR(DF_UUID": failed to get service replica ranks: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to get service replica ranks: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); D_GOTO(out_free, rc); } @@ -6065,8 +5974,9 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr d_rank_list_free(replicas); rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_svc_redun_fac, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade service redundancy factor " - "of pool, %d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade service redundancy factor " + "of pool, %d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -6114,10 +6024,11 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST || val32 != DAOS_UPGRADE_STATUS_IN_PROGRESS) { val32 = DAOS_UPGRADE_STATUS_IN_PROGRESS; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_upgrade_status, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_upgrade_status, &value); if (rc) { - D_ERROR(DF_UUID": failed to upgrade 'upgrade status' " - "of pool, %d.\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to upgrade 'upgrade status' " + "of pool, %d.\n", + DP_UUID(pool_uuid), rc); D_GOTO(out_free, rc); } need_commit = true; @@ -6129,10 +6040,9 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val32 = DAOS_PROP_PO_PERF_DOMAIN_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, - &ds_pool_prop_perf_domain, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_perf_domain, &value); if (rc != 0) { - D_ERROR("failed to write pool performain domain prop, "DF_RC"\n", + D_ERROR("failed to write pool performain domain prop, " DF_RC "\n", DP_RC(rc)); D_GOTO(out_free, rc); } @@ -6145,25 +6055,23 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { val32 = DAOS_PROP_PO_REINT_MODE_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_reint_mode, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_reint_mode, &value); if (rc != 0) { - D_ERROR("failed to write pool reintegration mode prop, "DF_RC"\n", + D_ERROR("failed to write pool reintegration mode prop, " DF_RC "\n", DP_RC(rc)); D_GOTO(out_free, rc); } need_commit = true; } - rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, - &value); + rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, &value); if (rc && rc != -DER_NONEXIST) { D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST || val32 != DAOS_POOL_GLOBAL_VERSION) { val32 = DAOS_POOL_GLOBAL_VERSION; - rc = rdb_tx_update(tx, &svc->ps_root, - &ds_pool_prop_upgrade_global_version, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, &value); if (rc != 0) { - D_ERROR("failed to write upgrade global version prop, "DF_RC"\n", + D_ERROR("failed to write upgrade global version prop, " DF_RC "\n", DP_RC(rc)); D_GOTO(out_free, rc); } @@ -6240,7 +6148,7 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { svc_ops_age = DAOS_PROP_PO_SVC_OPS_ENTRY_AGE_DEFAULT; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_svc_ops_age, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_svc_ops_age, &value); if (rc != 0) { DL_ERROR(rc, "failed to write upgrade svc_ops_age"); D_GOTO(out_free, rc); @@ -6255,7 +6163,7 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr D_GOTO(out_free, rc); } else if (rc == -DER_NONEXIST) { svc_ops_max = PS_OPS_PER_SEC * svc_ops_age; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_svc_ops_max, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_svc_ops_max, &value); if (rc != 0) { DL_ERROR(rc, DF_UUID ": failed to write upgrade svc_ops_max", DP_UUID(pool_uuid)); @@ -6340,21 +6248,21 @@ pool_upgrade_props(struct rdb_tx *tx, struct pool_svc *svc, uuid_t pool_uuid, cr static int ds_pool_mark_connectable_internal(struct rdb_tx *tx, struct pool_svc *svc) { - d_iov_t value; - uint32_t connectable = 0; - int rc; + d_iov_t value; + uint32_t connectable = 0; + int rc; d_iov_set(&value, &connectable, sizeof(connectable)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_connectable, &value); if ((rc == 0 && connectable == 0) || rc == -DER_NONEXIST) { connectable = 1; - rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_connectable, &value); + rc = rdb_tx_update(tx, &svc->ps_root, &ds_pool_prop_connectable, &value); if (rc == 0) rc = 1; } if (rc < 0) - D_ERROR("Failed to mark connectable of pool "DF_UUIDF": "DF_RC"\n", + D_ERROR("Failed to mark connectable of pool " DF_UUIDF ": " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return rc; @@ -6363,13 +6271,13 @@ ds_pool_mark_connectable_internal(struct rdb_tx *tx, struct pool_svc *svc) static int __ds_pool_mark_upgrade_completed(uuid_t pool_uuid, struct pool_svc *svc, int rc) { - struct rdb_tx tx; - d_iov_t value; - uint32_t upgrade_status; - uint32_t global_version = DAOS_POOL_GLOBAL_VERSION; - uint32_t obj_version; - int rc1; - daos_prop_t *prop = NULL; + struct rdb_tx tx; + d_iov_t value; + uint32_t upgrade_status; + uint32_t global_version = DAOS_POOL_GLOBAL_VERSION; + uint32_t obj_version; + int rc1; + daos_prop_t *prop = NULL; rc1 = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc1 != 0) @@ -6382,8 +6290,7 @@ __ds_pool_mark_upgrade_completed(uuid_t pool_uuid, struct pool_svc *svc, int rc) upgrade_status = DAOS_UPGRADE_STATUS_FAILED; d_iov_set(&value, &upgrade_status, sizeof(upgrade_status)); - rc1 = rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_upgrade_status, - &value); + rc1 = rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_upgrade_status, &value); if (rc1) D_GOTO(out_tx, rc1); @@ -6393,8 +6300,8 @@ __ds_pool_mark_upgrade_completed(uuid_t pool_uuid, struct pool_svc *svc, int rc) * pool_upgrade_props has encountered an error. */ d_iov_set(&value, &global_version, sizeof(global_version)); - rc1 = rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, - &value); + rc1 = + rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, &value); if (rc1) { DL_ERROR(rc1, "failed to write upgrade global version prop"); D_GOTO(out_tx, rc1); @@ -6407,11 +6314,11 @@ __ds_pool_mark_upgrade_completed(uuid_t pool_uuid, struct pool_svc *svc, int rc) */ if (rc == 0) { d_iov_set(&value, &global_version, sizeof(global_version)); - rc1 = rdb_tx_update(&tx, &svc->ps_root, - &ds_pool_prop_global_version, &value); + rc1 = rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_global_version, &value); if (rc1) { - D_ERROR(DF_UUID": failed to upgrade global version " - "of pool, %d.\n", DP_UUID(pool_uuid), rc1); + D_ERROR(DF_UUID ": failed to upgrade global version " + "of pool, %d.\n", + DP_UUID(pool_uuid), rc1); D_GOTO(out_tx, rc1); } @@ -6424,18 +6331,19 @@ __ds_pool_mark_upgrade_completed(uuid_t pool_uuid, struct pool_svc *svc, int rc) } d_iov_set(&value, &obj_version, sizeof(obj_version)); - rc1 = rdb_tx_update(&tx, &svc->ps_root, - &ds_pool_prop_obj_version, &value); + rc1 = rdb_tx_update(&tx, &svc->ps_root, &ds_pool_prop_obj_version, &value); if (rc1) { - D_ERROR(DF_UUID": failed to upgrade global version " - "of pool, %d.\n", DP_UUID(pool_uuid), rc1); + D_ERROR(DF_UUID ": failed to upgrade global version " + "of pool, %d.\n", + DP_UUID(pool_uuid), rc1); D_GOTO(out_tx, rc1); } rc1 = ds_pool_mark_connectable_internal(&tx, svc); if (rc1 < 0) { - D_ERROR(DF_UUID": failed to set connectable of pool " - "%d.\n", DP_UUID(pool_uuid), rc1); + D_ERROR(DF_UUID ": failed to set connectable of pool " + "%d.\n", + DP_UUID(pool_uuid), rc1); D_GOTO(out_tx, rc1); } } @@ -6469,10 +6377,10 @@ static int pool_check_upgrade_object_layout(struct rdb_tx *tx, struct pool_svc *svc, bool *scheduled_layout_upgrade) { - daos_epoch_t upgrade_eph = d_hlc_get(); - d_iov_t value; - uint32_t current_layout_ver = 0; - int rc = 0; + daos_epoch_t upgrade_eph = d_hlc_get(); + d_iov_t value; + uint32_t current_layout_ver = 0; + int rc = 0; d_iov_set(&value, ¤t_layout_ver, sizeof(current_layout_ver)); rc = rdb_tx_lookup(tx, &svc->ps_root, &ds_pool_prop_obj_version, &value); @@ -6510,8 +6418,8 @@ ds_pool_mark_upgrade_completed_internal(struct pool_svc *svc, int ret) int ds_pool_mark_upgrade_completed(uuid_t pool_uuid, int ret) { - struct pool_svc *svc; - int rc; + struct pool_svc *svc; + int rc; /* XXX check if the whole upgrade progress is really completed */ rc = pool_svc_lookup_leader(pool_uuid, &svc, NULL); @@ -6529,14 +6437,14 @@ static int ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct pool_svc *svc, crt_rpc_t *rpc, uuid_t srv_pool_hdl, uuid_t srv_cont_hdl) { - struct rdb_tx tx; - d_iov_t value; - uint32_t upgrade_status; - uint32_t upgrade_global_ver; - int rc; - bool scheduled_layout_upgrade = false; - bool dmg_upgrade_cmd = false; - bool request_schedule_upgrade = false; + struct rdb_tx tx; + d_iov_t value; + uint32_t upgrade_status; + uint32_t upgrade_global_ver; + int rc; + bool scheduled_layout_upgrade = false; + bool dmg_upgrade_cmd = false; + bool request_schedule_upgrade = false; if (!svc) { rc = pool_svc_lookup_leader(pool_uuid, &svc, po_hint); @@ -6574,8 +6482,7 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po */ ABT_rwlock_wrlock(svc->ps_lock); d_iov_set(&value, &upgrade_global_ver, sizeof(upgrade_global_ver)); - rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, - &value); + rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_upgrade_global_version, &value); if (rc && rc != -DER_NONEXIST) { D_GOTO(out_tx, rc); } else if (rc == -DER_NONEXIST) { @@ -6584,13 +6491,12 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po D_GOTO(out_upgrade, rc); } else { d_iov_set(&value, &upgrade_status, sizeof(upgrade_status)); - rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_upgrade_status, - &value); + rc = rdb_tx_lookup(&tx, &svc->ps_root, &ds_pool_prop_upgrade_status, &value); if (rc) D_GOTO(out_tx, rc); if (upgrade_global_ver > DAOS_POOL_GLOBAL_VERSION) { - D_ERROR(DF_UUID": downgrading pool is unsupported: %u -> %u\n", + D_ERROR(DF_UUID ": downgrading pool is unsupported: %u -> %u\n", DP_UUID(svc->ps_uuid), upgrade_global_ver, DAOS_POOL_GLOBAL_VERSION); D_GOTO(out_tx, rc = -DER_INVAL); @@ -6616,8 +6522,8 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po break; case DAOS_UPGRADE_STATUS_FAILED: if (upgrade_global_ver < DAOS_POOL_GLOBAL_VERSION) { - D_ERROR(DF_UUID": upgrading pool %u -> %u\n is unsupported" - " because pool upgraded to %u last time failed\n", + D_ERROR(DF_UUID ": upgrading pool %u -> %u\n is unsupported" + " because pool upgraded to %u last time failed\n", DP_UUID(svc->ps_uuid), upgrade_global_ver, DAOS_POOL_GLOBAL_VERSION, upgrade_global_ver); D_GOTO(out_tx, rc = -DER_NOTSUPPORTED); @@ -6630,8 +6536,8 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po break; case DAOS_UPGRADE_STATUS_IN_PROGRESS: if (upgrade_global_ver < DAOS_POOL_GLOBAL_VERSION) { - D_ERROR(DF_UUID": upgrading pool %u -> %u\n is unsupported" - " because pool upgraded to %u not finished yet\n", + D_ERROR(DF_UUID ": upgrading pool %u -> %u\n is unsupported" + " because pool upgraded to %u not finished yet\n", DP_UUID(svc->ps_uuid), upgrade_global_ver, DAOS_POOL_GLOBAL_VERSION, upgrade_global_ver); D_GOTO(out_tx, rc = -DER_NOTSUPPORTED); @@ -6667,8 +6573,7 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po if (request_schedule_upgrade && !scheduled_layout_upgrade) { int rc1; - if (rc == 0 && dmg_upgrade_cmd && - DAOS_FAIL_CHECK(DAOS_POOL_UPGRADE_CONT_ABORT)) + if (rc == 0 && dmg_upgrade_cmd && DAOS_FAIL_CHECK(DAOS_POOL_UPGRADE_CONT_ABORT)) D_GOTO(out_put_leader, rc = -DER_AGAIN); rc1 = ds_pool_mark_upgrade_completed_internal(svc, rc); if (rc == 0 && rc1) @@ -6689,9 +6594,9 @@ ds_pool_upgrade_if_needed(uuid_t pool_uuid, struct rsvc_hint *po_hint, struct po void ds_pool_upgrade_handler(crt_rpc_t *rpc) { - struct pool_upgrade_in *in = crt_req_get(rpc); - struct pool_upgrade_out *out = crt_reply_get(rpc); - int rc; + struct pool_upgrade_in *in = crt_req_get(rpc); + struct pool_upgrade_out *out = crt_reply_get(rpc); + int rc; rc = ds_pool_upgrade_if_needed(in->poi_op.pi_uuid, &out->poo_op.po_hint, NULL, rpc, NULL, NULL); @@ -6708,8 +6613,8 @@ ds_pool_upgrade_handler(crt_rpc_t *rpc) static int merge_acl(struct daos_acl **acl, struct daos_acl *new_acl) { - struct daos_ace *new_ace; - int rc = 0; + struct daos_ace *new_ace; + int rc = 0; new_ace = daos_acl_get_next_ace(new_acl, NULL); while (new_ace != NULL) { @@ -6728,26 +6633,24 @@ merge_acl(struct daos_acl **acl, struct daos_acl *new_acl) void ds_pool_acl_update_handler(crt_rpc_t *rpc) { - struct pool_acl_update_in *in = crt_req_get(rpc); - struct pool_acl_update_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct rdb_tx tx; - int rc; - struct daos_acl *acl_in = NULL; - daos_prop_t *prop = NULL; - struct daos_prop_entry *entry = NULL; - bool dup_op = false; - struct ds_pool_svc_op_val op_val; - bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); - bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->pui_op.pi_uuid), rpc); + struct pool_acl_update_in *in = crt_req_get(rpc); + struct pool_acl_update_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct rdb_tx tx; + int rc; + struct daos_acl *acl_in = NULL; + daos_prop_t *prop = NULL; + struct daos_prop_entry *entry = NULL; + bool dup_op = false; + struct ds_pool_svc_op_val op_val; + bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); + bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); + + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->pui_op.pi_uuid), rpc); pool_acl_update_in_get_data(rpc, &acl_in); - rc = pool_svc_lookup_leader(in->pui_op.pi_uuid, &svc, - &out->puo_op.po_hint); + rc = pool_svc_lookup_leader(in->pui_op.pi_uuid, &svc, &out->puo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -6772,21 +6675,20 @@ ds_pool_acl_update_handler(crt_rpc_t *rpc) entry = daos_prop_entry_get(prop, DAOS_PROP_PO_ACL); if (entry == NULL) { - D_ERROR(DF_UUID": No ACL prop entry for pool\n", - DP_UUID(in->pui_op.pi_uuid)); + D_ERROR(DF_UUID ": No ACL prop entry for pool\n", DP_UUID(in->pui_op.pi_uuid)); D_GOTO(out_prop, rc); } rc = merge_acl((struct daos_acl **)&entry->dpe_val_ptr, acl_in); if (rc != 0) { - D_ERROR(DF_UUID": Unable to update pool with new ACL, rc=%d\n", + D_ERROR(DF_UUID ": Unable to update pool with new ACL, rc=%d\n", DP_UUID(in->pui_op.pi_uuid), rc); D_GOTO(out_prop, rc); } rc = pool_prop_write(&tx, &svc->ps_root, prop); if (rc != 0) { - D_ERROR(DF_UUID": failed to write updated ACL for pool: %d\n", + D_ERROR(DF_UUID ": failed to write updated ACL for pool: %d\n", DP_UUID(in->pui_op.pi_uuid), rc); D_GOTO(out_prop, rc); } @@ -6834,23 +6736,21 @@ ds_pool_acl_update_handler(crt_rpc_t *rpc) void ds_pool_acl_delete_handler(crt_rpc_t *rpc) { - struct pool_acl_delete_in *in = crt_req_get(rpc); - struct pool_acl_delete_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct rdb_tx tx; - int rc; - daos_prop_t *prop = NULL; - struct daos_prop_entry *entry; - bool dup_op = false; - struct ds_pool_svc_op_val op_val; - bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); - bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); + struct pool_acl_delete_in *in = crt_req_get(rpc); + struct pool_acl_delete_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct rdb_tx tx; + int rc; + daos_prop_t *prop = NULL; + struct daos_prop_entry *entry; + bool dup_op = false; + struct ds_pool_svc_op_val op_val; + bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); + bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->pdi_op.pi_uuid), rpc); + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->pdi_op.pi_uuid), rpc); - rc = pool_svc_lookup_leader(in->pdi_op.pi_uuid, &svc, - &out->pdo_op.po_hint); + rc = pool_svc_lookup_leader(in->pdi_op.pi_uuid, &svc, &out->pdo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -6875,22 +6775,22 @@ ds_pool_acl_delete_handler(crt_rpc_t *rpc) entry = daos_prop_entry_get(prop, DAOS_PROP_PO_ACL); if (entry == NULL) { - D_ERROR(DF_UUID": No ACL prop entry for pool\n", - DP_UUID(in->pdi_op.pi_uuid)); + D_ERROR(DF_UUID ": No ACL prop entry for pool\n", DP_UUID(in->pdi_op.pi_uuid)); D_GOTO(out_prop, rc); } - rc = daos_acl_remove_ace((struct daos_acl **)&entry->dpe_val_ptr, - in->pdi_type, in->pdi_principal); + rc = daos_acl_remove_ace((struct daos_acl **)&entry->dpe_val_ptr, in->pdi_type, + in->pdi_principal); if (rc != 0) { - D_ERROR(DF_UUID": Failed to remove requested principal, " - "rc=%d\n", DP_UUID(in->pdi_op.pi_uuid), rc); + D_ERROR(DF_UUID ": Failed to remove requested principal, " + "rc=%d\n", + DP_UUID(in->pdi_op.pi_uuid), rc); D_GOTO(out_prop, rc); } rc = pool_prop_write(&tx, &svc->ps_root, prop); if (rc != 0) { - D_ERROR(DF_UUID": failed to write updated ACL for pool: %d\n", + D_ERROR(DF_UUID ": failed to write updated ACL for pool: %d\n", DP_UUID(in->pdi_op.pi_uuid), rc); D_GOTO(out_prop, rc); } @@ -6933,9 +6833,9 @@ ds_pool_acl_delete_handler(crt_rpc_t *rpc) } struct pool_svc_reconf_arg { - struct pool_map *sca_map; - uint32_t sca_map_version_for; - bool sca_sync_remove; + struct pool_map *sca_map; + uint32_t sca_map_version_for; + bool sca_sync_remove; }; /* Must be used with pool_svc.ps_reconf_sched (see container_of below). */ @@ -6960,7 +6860,7 @@ pool_svc_reconf_ult(void *varg) else map = arg->sca_map; - D_DEBUG(DB_MD, DF_UUID": begin\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": begin\n", DP_UUID(svc->ps_uuid)); if (reconf->psc_canceled) { rc = -DER_OP_CANCELED; @@ -6978,7 +6878,7 @@ pool_svc_reconf_ult(void *varg) rc = rdb_get_ranks(svc->ps_rsvc.s_db, &pre); if (rc != 0) { - D_ERROR(DF_UUID": failed to get pool service replica ranks: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to get pool service replica ranks: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto out; } @@ -6998,7 +6898,7 @@ pool_svc_reconf_ult(void *varg) if (arg->sca_map == NULL) ABT_rwlock_unlock(svc->ps_pool->sp_lock); if (rc != 0) { - D_ERROR(DF_UUID": cannot plan pool service reconfigurations: "DF_RC"\n", + D_ERROR(DF_UUID ": cannot plan pool service reconfigurations: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto out_cur; } @@ -7041,13 +6941,13 @@ pool_svc_reconf_ult(void *varg) */ rc = d_rank_list_dup(&tmp, to_remove); if (rc != 0) { - D_ERROR(DF_UUID": failed to duplicate to_remove: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to duplicate to_remove: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); goto out_to_add_remove; } rc = ds_rsvc_remove_replicas_s(&svc->ps_rsvc, to_remove, false /* destroy */); if (rc != 0) - D_ERROR(DF_UUID": failed to remove replicas: "DF_RC"\n", + D_ERROR(DF_UUID ": failed to remove replicas: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); /* Delete from to_remove ranks that are not removed. */ d_rank_list_filter(tmp, to_remove, true /* exclude */); @@ -7062,12 +6962,12 @@ pool_svc_reconf_ult(void *varg) * Send RAS event to control-plane over dRPC to indicate * change in pool service replicas. */ - rc_tmp = ds_notify_pool_svc_update(&svc->ps_uuid, post, - svc->ps_rsvc.s_term); + rc_tmp = + ds_notify_pool_svc_update(&svc->ps_uuid, post, svc->ps_rsvc.s_term); if (rc_tmp == 0) svc->ps_force_notify = false; else - DL_ERROR(rc_tmp, DF_UUID": replica update notify failure", + DL_ERROR(rc_tmp, DF_UUID ": replica update notify failure", DP_UUID(svc->ps_uuid)); } @@ -7099,7 +6999,7 @@ pool_svc_reconf_ult(void *varg) reconf->psc_rc = rc; sched_end(reconf); ABT_cond_broadcast(reconf->psc_cv); - D_DEBUG(DB_MD, DF_UUID": end: "DF_RC"\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": end: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); } /* If returning 0, this function must have scheduled func(arg). */ @@ -7107,13 +7007,13 @@ static int pool_svc_schedule(struct pool_svc *svc, struct pool_svc_sched *sched, void (*func)(void *), void *arg) { - enum ds_rsvc_state state; - int rc; + enum ds_rsvc_state state; + int rc; - D_DEBUG(DB_MD, DF_UUID": begin\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": begin\n", DP_UUID(svc->ps_uuid)); if (ds_pool_restricted(svc->ps_pool, false)) { - D_DEBUG(DB_MD, DF_UUID": end: skip in check mode\n", DP_UUID(svc->ps_uuid)); + D_DEBUG(DB_MD, DF_UUID ": end: skip in check mode\n", DP_UUID(svc->ps_uuid)); return -DER_OP_CANCELED; } @@ -7141,13 +7041,13 @@ pool_svc_schedule(struct pool_svc *svc, struct pool_svc_sched *sched, void (*fun */ rc = dss_ult_create(func, sched, DSS_XS_SELF, 0, 0, NULL /* ult */); if (rc != 0) { - D_ERROR(DF_UUID": failed to create ULT: "DF_RC"\n", - DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": failed to create ULT: " DF_RC "\n", DP_UUID(svc->ps_uuid), + DP_RC(rc)); sched_end(sched); return rc; } - D_DEBUG(DB_MD, DF_UUID": end: "DF_RC"\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": end: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return 0; } @@ -7169,21 +7069,21 @@ ds_pool_svc_schedule_reconf(struct ds_pool_svc *svc) rc = pool_svc_schedule_reconf(s, NULL /* map */, 1 /* map_version_for */, true /* sync_remove */); if (rc != 0) - DL_ERROR(rc, DF_UUID": failed to schedule pool service reconfiguration", + DL_ERROR(rc, DF_UUID ": failed to schedule pool service reconfiguration", DP_UUID(s->ps_uuid)); return rc; } -static int pool_find_all_targets_by_addr(struct pool_map *map, - struct pool_target_addr_list *list, - struct pool_target_id_list *tgt_list, - struct pool_target_addr_list *inval); +static int +pool_find_all_targets_by_addr(struct pool_map *map, struct pool_target_addr_list *list, + struct pool_target_id_list *tgt_list, + struct pool_target_addr_list *inval); static int cont_rf_check_cb(uuid_t pool_uuid, uuid_t cont_uuid, struct rdb_tx *tx, void *arg) { struct pool_svc_sched *sched = arg; - int rc; + int rc; /* If anything happened during rf check, let's continue to check the next container * for the moment. @@ -7194,7 +7094,7 @@ cont_rf_check_cb(uuid_t pool_uuid, uuid_t cont_uuid, struct rdb_tx *tx, void *ar DP_CONT(pool_uuid, cont_uuid)); if (sched->psc_canceled) { - D_DEBUG(DB_MD, DF_CONT" is canceled.\n", DP_CONT(pool_uuid, cont_uuid)); + D_DEBUG(DB_MD, DF_CONT " is canceled.\n", DP_CONT(pool_uuid, cont_uuid)); return 1; } @@ -7224,14 +7124,13 @@ pool_svc_rfcheck_ult(void *arg) break; } - D_DEBUG(DB_MD, DF_UUID" check rf with %d and retry\n", - DP_UUID(svc->ps_uuid), rc); + D_DEBUG(DB_MD, DF_UUID " check rf with %d and retry\n", DP_UUID(svc->ps_uuid), rc); dss_sleep(1000 /* ms */); } while (1); sched_end(&svc->ps_rfcheck_sched); - D_INFO("RF check finished for "DF_UUID"\n", DP_UUID(svc->ps_uuid)); + D_INFO("RF check finished for " DF_UUID "\n", DP_UUID(svc->ps_uuid)); ABT_cond_broadcast(svc->ps_rfcheck_sched.psc_cv); } @@ -7243,9 +7142,9 @@ static int pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, uint32_t map_version_for, bool sync_remove) { - struct pool_svc_reconf_arg *reconf_arg; - uint32_t v; - int rc; + struct pool_svc_reconf_arg *reconf_arg; + uint32_t v; + int rc; if (map == NULL) v = map_version_for; @@ -7262,7 +7161,7 @@ pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, uint32_t ma else v_in_progress = pool_map_get_version(reconf_arg->sca_map); if (v_in_progress >= v) { - D_DEBUG(DB_MD, DF_UUID": stale request: v_in_progress=%u v=%u\n", + D_DEBUG(DB_MD, DF_UUID ": stale request: v_in_progress=%u v=%u\n", DP_UUID(svc->ps_uuid), v_in_progress, v); return -DER_OP_CANCELED; } @@ -7271,9 +7170,9 @@ pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, uint32_t ma D_ALLOC_PTR(reconf_arg); if (reconf_arg == NULL) return -DER_NOMEM; - reconf_arg->sca_map = map; + reconf_arg->sca_map = map; reconf_arg->sca_map_version_for = v; - reconf_arg->sca_sync_remove = sync_remove; + reconf_arg->sca_sync_remove = sync_remove; /* * If successful, this call passes the ownership of reconf_arg to @@ -7290,7 +7189,8 @@ pool_svc_schedule_reconf(struct pool_svc *svc, struct pool_map *map, uint32_t ma rc = svc->ps_reconf_sched.psc_rc; if (rc != 0) { - DL_ERROR(rc, DF_UUID": pool service reconfigurator", DP_UUID(svc->ps_uuid)); + DL_ERROR(rc, DF_UUID ": pool service reconfigurator", + DP_UUID(svc->ps_uuid)); return rc; } } @@ -7416,16 +7316,16 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud struct pool_target_addr_list *inval_tgt_addrs, enum map_update_source src, uint32_t flags) { - struct rdb_tx tx; - struct pool_map *map; - uint32_t map_version_before; - uint32_t map_version; - struct pool_buf *map_buf = NULL; - struct pool_domain *node; - bool updated = false; - int rc; + struct rdb_tx tx; + struct pool_map *map; + uint32_t map_version_before; + uint32_t map_version; + struct pool_buf *map_buf = NULL; + struct pool_domain *node; + bool updated = false; + int rc; - D_DEBUG(DB_MD, DF_UUID": opc=%u exclude_rank=%d ntgts=%d ntgt_addrs=%d\n", + D_DEBUG(DB_MD, DF_UUID ": opc=%u exclude_rank=%d ntgts=%d ntgt_addrs=%d\n", DP_UUID(svc->ps_uuid), opc, exclude_rank, tgts->pti_number, tgt_addrs == NULL ? 0 : tgt_addrs->pta_number); @@ -7489,7 +7389,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud /* Get a list of all the targets being added */ rc = pool_map_find_targets_on_ranks(map, extend_rank_list, tgts); if (rc <= 0) { - D_ERROR(DF_UUID" failed to find targets rc: "DF_RC"\n", + D_ERROR(DF_UUID " failed to find targets rc: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); D_GOTO(out_map, rc); } @@ -7502,8 +7402,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud D_ASSERT(tgts->pti_ids == NULL); D_ASSERT(tgt_addrs != NULL); D_ASSERT(inval_tgt_addrs != NULL); - rc = pool_find_all_targets_by_addr(map, tgt_addrs, tgts, - inval_tgt_addrs); + rc = pool_find_all_targets_by_addr(map, tgt_addrs, tgts, inval_tgt_addrs); if (rc != 0) goto out_map; if (src == MUS_DMG && inval_tgt_addrs->pta_number > 0) { @@ -7531,8 +7430,8 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud if (rc != 0) D_GOTO(out_map, rc); map_version = pool_map_get_version(map); - D_DEBUG(DB_MD, DF_UUID": version=%u->%u\n", - DP_UUID(svc->ps_uuid), map_version_before, map_version); + D_DEBUG(DB_MD, DF_UUID ": version=%u->%u\n", DP_UUID(svc->ps_uuid), map_version_before, + map_version); if (map_version == map_version_before) D_GOTO(out_map, rc = 0); @@ -7546,7 +7445,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud rc = rdb_get_ranks(svc->ps_rsvc.s_db, &replicas); if (replicas->rl_nr == 1) { - D_ERROR(DF_UUID": rejecting rank exclusion: self removal requested\n", + D_ERROR(DF_UUID ": rejecting rank exclusion: self removal requested\n", DP_UUID(svc->ps_uuid)); rc = -DER_INVAL; } else { @@ -7556,7 +7455,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud * requires the currently unavailable Raft leadership * transfer support. */ - D_INFO(DF_UUID": resigning PS leadership: self removal requested\n", + D_INFO(DF_UUID ": resigning PS leadership: self removal requested\n", DP_UUID(svc->ps_uuid)); rdb_resign(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term); rc = -DER_NOTLEADER; @@ -7579,7 +7478,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud rc = pool_map_update_failed_cnt(map); if (rc != 0) { - DL_ERROR(rc, DF_UUID": pool_map_update_failed_cnt failed.", + DL_ERROR(rc, DF_UUID ": pool_map_update_failed_cnt failed.", DP_UUID(svc->ps_uuid)); goto out_map; } @@ -7613,15 +7512,15 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud */ rc = pool_svc_schedule_reconf(svc, map, 0 /* map_version_for */, true /* sync_remove */); if (rc != 0) { - DL_ERROR(rc, DF_UUID": failed to remove undesired pool service replicas", + DL_ERROR(rc, DF_UUID ": failed to remove undesired pool service replicas", DP_UUID(svc->ps_uuid)); goto out_map; } rc = rdb_tx_commit(&tx); if (rc != 0) { - D_DEBUG(DB_MD, DF_UUID": failed to commit: "DF_RC"\n", - DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_DEBUG(DB_MD, DF_UUID ": failed to commit: " DF_RC "\n", DP_UUID(svc->ps_uuid), + DP_RC(rc)); goto out_map_buf; } @@ -7632,8 +7531,8 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud /* Update svc->ps_pool to match the new pool map. */ rc = ds_pool_tgt_map_update(svc->ps_pool, map_buf, map_version); if (rc != 0) { - D_ERROR(DF_UUID": failed to update pool map cache: %d\n", - DP_UUID(svc->ps_uuid), rc); + D_ERROR(DF_UUID ": failed to update pool map cache: %d\n", DP_UUID(svc->ps_uuid), + rc); /* * We must resign to avoid handling future requests with a * stale pool map cache. @@ -7650,7 +7549,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud rc = pool_svc_schedule_reconf(svc, NULL /* map */, map_version, false /* sync_remove */); if (rc != 0) { - DL_INFO(rc, DF_UUID": failed to schedule pool service reconfiguration", + DL_INFO(rc, DF_UUID ": failed to schedule pool service reconfiguration", DP_UUID(svc->ps_uuid)); rc = 0; } @@ -7658,7 +7557,7 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud if (opc == MAP_EXCLUDE) { rc = pool_svc_schedule(svc, &svc->ps_rfcheck_sched, pool_svc_rfcheck_ult, NULL); if (rc != 0) - DL_INFO(rc, DF_UUID": failed to schedule RF check", DP_UUID(svc->ps_uuid)); + DL_INFO(rc, DF_UUID ": failed to schedule RF check", DP_UUID(svc->ps_uuid)); } pool_svc_update_map_metrics(svc->ps_uuid, map, svc->ps_pool->sp_metrics[DAOS_POOL_MODULE]); @@ -7681,32 +7580,28 @@ pool_svc_update_map_internal(struct pool_svc *svc, unsigned int opc, bool exclud } static int -pool_find_all_targets_by_addr(struct pool_map *map, - struct pool_target_addr_list *list, - struct pool_target_id_list *tgt_list, +pool_find_all_targets_by_addr(struct pool_map *map, struct pool_target_addr_list *list, + struct pool_target_id_list *tgt_list, struct pool_target_addr_list *inval_list_out) { - int i; - int rc = 0; + int i; + int rc = 0; for (i = 0; i < list->pta_number; i++) { struct pool_target *tgt; - int tgt_nr; - int j; - int ret; + int tgt_nr; + int j; + int ret; - tgt_nr = pool_map_find_target_by_rank_idx(map, - list->pta_addrs[i].pta_rank, - list->pta_addrs[i].pta_target, &tgt); + tgt_nr = pool_map_find_target_by_rank_idx(map, list->pta_addrs[i].pta_rank, + list->pta_addrs[i].pta_target, &tgt); if (tgt_nr <= 0) { /* Can not locate the target in pool map, let's * add it to the output list */ D_DEBUG(DB_MD, "cannot find rank %u target %u\n", - list->pta_addrs[i].pta_rank, - list->pta_addrs[i].pta_target); - ret = pool_target_addr_list_append(inval_list_out, - &list->pta_addrs[i]); + list->pta_addrs[i].pta_rank, list->pta_addrs[i].pta_target); + ret = pool_target_addr_list_append(inval_list_out, &list->pta_addrs[i]); if (ret) { rc = ret; break; @@ -7717,7 +7612,7 @@ pool_find_all_targets_by_addr(struct pool_map *map, struct pool_target_id tid; tid.pti_id = tgt[j].ta_comp.co_id; - ret = pool_target_id_list_append(tgt_list, &tid); + ret = pool_target_id_list_append(tgt_list, &tid); if (ret) { rc = ret; break; @@ -7734,24 +7629,22 @@ struct redist_open_hdls_arg { */ struct pool_iv_conn **hdls; /** Pointer to the next write location within hdls */ - struct pool_iv_conn *next; + struct pool_iv_conn *next; /** Total current size of the hdls buffer, in bytes */ - size_t hdls_size; + size_t hdls_size; /** Total used space in hdls buffer, in bytes */ - size_t hdls_used; + size_t hdls_used; }; /* See pool_svc_update_map_internal documentation. */ static int pool_update_map_internal(uuid_t pool_uuid, unsigned int opc, bool exclude_rank, - struct pool_target_id_list *tgts, - struct pool_target_addr_list *tgt_addrs, - struct rsvc_hint *hint, bool *p_updated, - uint32_t *map_version_p, uint32_t *tgt_map_ver, - struct pool_target_addr_list *inval_tgt_addrs) + struct pool_target_id_list *tgts, struct pool_target_addr_list *tgt_addrs, + struct rsvc_hint *hint, bool *p_updated, uint32_t *map_version_p, + uint32_t *tgt_map_ver, struct pool_target_addr_list *inval_tgt_addrs) { - struct pool_svc *svc; - int rc; + struct pool_svc *svc; + int rc; rc = pool_svc_lookup_leader(pool_uuid, &svc, hint); if (rc != 0) @@ -7768,8 +7661,8 @@ pool_update_map_internal(uuid_t pool_uuid, unsigned int opc, bool exclude_rank, int ds_pool_tgt_exclude_out(uuid_t pool_uuid, struct pool_target_id_list *list) { - return pool_update_map_internal(pool_uuid, pool_opc_2map_opc(POOL_EXCLUDE_OUT), false, - list, NULL, NULL, NULL, NULL, NULL, NULL); + return pool_update_map_internal(pool_uuid, pool_opc_2map_opc(POOL_EXCLUDE_OUT), false, list, + NULL, NULL, NULL, NULL, NULL, NULL); } int @@ -7790,8 +7683,8 @@ ds_pool_tgt_finish_rebuild(uuid_t pool_uuid, struct pool_target_id_list *list, int ds_pool_tgt_revert_rebuild(uuid_t pool_uuid, struct pool_target_id_list *list) { - return pool_update_map_internal(pool_uuid, MAP_REVERT_REBUILD, false, list, - NULL, NULL, NULL, NULL, NULL, NULL); + return pool_update_map_internal(pool_uuid, MAP_REVERT_REBUILD, false, list, NULL, NULL, + NULL, NULL, NULL, NULL); } /* @@ -7858,7 +7751,7 @@ pool_svc_update_map(struct pool_svc *svc, crt_opcode_t opc, bool exclude_rank, d_agetenv_str(&env, REBUILD_ENV); if ((env && !strcasecmp(env, REBUILD_ENV_DISABLED)) || - daos_fail_check(DAOS_REBUILD_DISABLE)) { + daos_fail_check(DAOS_REBUILD_DISABLE)) { D_DEBUG(DB_REBUILD, DF_UUID ": Rebuild is disabled for all pools\n", DP_UUID(svc->ps_pool->sp_uuid)); d_freeenv_str(&env); @@ -7884,9 +7777,10 @@ pool_svc_update_map(struct pool_svc *svc, crt_opcode_t opc, bool exclude_rank, if (opc == MAP_EXCLUDE || opc == MAP_DRAIN) { rc = ds_pool_tgt_exclude_out(svc->ps_pool->sp_uuid, &target_list); if (rc) - D_INFO("mark failed target %d of "DF_UUID " as DOWNOUT: "DF_RC"\n", - target_list.pti_ids[0].pti_id, - DP_UUID(svc->ps_pool->sp_uuid), DP_RC(rc)); + D_INFO("mark failed target %d of " DF_UUID " as DOWNOUT: " DF_RC + "\n", + target_list.pti_ids[0].pti_id, + DP_UUID(svc->ps_pool->sp_uuid), DP_RC(rc)); } D_GOTO(out, rc); } @@ -7896,8 +7790,7 @@ pool_svc_update_map(struct pool_svc *svc, crt_opcode_t opc, bool exclude_rank, else if (daos_fail_check(DAOS_REBUILD_DELAY)) delay = 5; - D_DEBUG(DB_MD, "map ver %u/%u\n", map_version ? *map_version : -1, - tgt_map_ver); + D_DEBUG(DB_MD, "map ver %u/%u\n", map_version ? *map_version : -1, tgt_map_ver); if (tgt_map_ver != 0) { rc = ds_rebuild_schedule(svc->ps_pool, tgt_map_ver, rebuild_eph, 0, &target_list, @@ -7905,7 +7798,7 @@ pool_svc_update_map(struct pool_svc *svc, crt_opcode_t opc, bool exclude_rank, 0 /* retry_map_ver */, false /* stop_admin */, NULL /* cur_taskp */, delay); if (rc != 0) { - D_ERROR("rebuild fails rc: "DF_RC"\n", DP_RC(rc)); + D_ERROR("rebuild fails rc: " DF_RC "\n", DP_RC(rc)); D_GOTO(out, rc); } } @@ -7919,13 +7812,13 @@ static int pool_discard(crt_context_t ctx, struct pool_svc *svc, struct pool_target_addr_list *list, bool reint) { - struct pool_tgt_discard_in *ptdi_in; - struct pool_tgt_discard_out *ptdi_out; - crt_rpc_t *rpc; - d_rank_list_t *rank_list = NULL; - crt_opcode_t opc = POOL_TGT_DISCARD; - int i; - int rc; + struct pool_tgt_discard_in *ptdi_in; + struct pool_tgt_discard_out *ptdi_out; + crt_rpc_t *rpc; + d_rank_list_t *rank_list = NULL; + crt_opcode_t opc = POOL_TGT_DISCARD; + int i; + int rc; rc = ds_pool_encode_opc(&opc); if (rc) @@ -7946,24 +7839,23 @@ pool_discard(crt_context_t ctx, struct pool_svc *svc, struct pool_target_addr_li continue; rank_list->rl_ranks[rank_list->rl_nr++] = list->pta_addrs[i].pta_rank; - D_DEBUG(DB_MD, DF_UUID": discard rank %u\n", - DP_UUID(svc->ps_pool->sp_uuid), list->pta_addrs[i].pta_rank); + D_DEBUG(DB_MD, DF_UUID ": discard rank %u\n", DP_UUID(svc->ps_pool->sp_uuid), + list->pta_addrs[i].pta_rank); } if (rank_list->rl_nr == 0) { - D_DEBUG(DB_MD, DF_UUID" discard 0 rank.\n", DP_UUID(svc->ps_pool->sp_uuid)); + D_DEBUG(DB_MD, DF_UUID " discard 0 rank.\n", DP_UUID(svc->ps_pool->sp_uuid)); D_GOTO(out, rc = 0); } - rc = crt_corpc_req_create(ctx, NULL, rank_list, opc, NULL, - NULL, CRT_RPC_FLAG_FILTER_INVERT, + rc = crt_corpc_req_create(ctx, NULL, rank_list, opc, NULL, NULL, CRT_RPC_FLAG_FILTER_INVERT, crt_tree_topo(CRT_TREE_KNOMIAL, 32), &rpc); if (rc) D_GOTO(out, rc); - ptdi_in = crt_req_get(rpc); + ptdi_in = crt_req_get(rpc); ptdi_in->ptdi_addrs.ca_arrays = list->pta_addrs; - ptdi_in->ptdi_addrs.ca_count = list->pta_number; + ptdi_in->ptdi_addrs.ca_count = list->pta_number; uuid_copy(ptdi_in->ptdi_uuid, svc->ps_pool->sp_uuid); rc = dss_rpc_send(rpc); @@ -7971,8 +7863,8 @@ pool_discard(crt_context_t ctx, struct pool_svc *svc, struct pool_target_addr_li D_ASSERT(ptdi_out != NULL); rc = ptdi_out->ptdo_rc; if (rc != 0) - D_ERROR(DF_UUID": pool discard failed: rc: %d\n", - DP_UUID(svc->ps_pool->sp_uuid), rc); + D_ERROR(DF_UUID ": pool discard failed: rc: %d\n", DP_UUID(svc->ps_pool->sp_uuid), + rc); crt_req_decref(rpc); @@ -8156,13 +8048,13 @@ pool_recov_cont(crt_context_t ctx, struct pool_svc *svc, struct pool_target_addr static void pool_update_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_tgt_update_in *in = crt_req_get(rpc); - struct pool_tgt_update_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - struct pool_target_addr_list list = { 0 }; - struct pool_target_addr_list inval_list_out = { 0 }; - int rc; - uint32_t flags; + struct pool_tgt_update_in *in = crt_req_get(rpc); + struct pool_tgt_update_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + struct pool_target_addr_list list = {0}; + struct pool_target_addr_list inval_list_out = {0}; + int rc; + uint32_t flags; pool_tgt_update_in_get_data(rpc, &list.pta_addrs, &list.pta_number, &flags); @@ -8172,8 +8064,7 @@ pool_update_handler(crt_rpc_t *rpc, int handler_version) D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p ntargets=%zu\n", DP_UUID(in->pti_op.pi_uuid), rpc, (size_t)list.pta_number); - rc = pool_svc_lookup_leader(in->pti_op.pi_uuid, &svc, - &out->pto_op.po_hint); + rc = pool_svc_lookup_leader(in->pti_op.pi_uuid, &svc, &out->pto_op.po_hint); if (rc != 0) goto out; @@ -8195,7 +8086,7 @@ pool_update_handler(crt_rpc_t *rpc, int handler_version) goto out_svc; out->pto_addr_list.ca_arrays = inval_list_out.pta_addrs; - out->pto_addr_list.ca_count = inval_list_out.pta_number; + out->pto_addr_list.ca_count = inval_list_out.pta_number; out_svc: pool_svc_put_leader(svc); @@ -8216,14 +8107,14 @@ ds_pool_update_handler(crt_rpc_t *rpc) static int pool_svc_exclude_ranks(struct pool_svc *svc, struct pool_svc_event_set *event_set) { - struct pool_target_addr_list list; - struct pool_target_addr_list inval_list_out = { 0 }; - struct pool_target_addr *addrs; - d_rank_t self_rank = dss_self_rank(); - uint32_t map_version = 0; - int n = 0; - int i; - int rc; + struct pool_target_addr_list list; + struct pool_target_addr_list inval_list_out = {0}; + struct pool_target_addr *addrs; + d_rank_t self_rank = dss_self_rank(); + uint32_t map_version = 0; + int n = 0; + int i; + int rc; D_ALLOC_ARRAY(addrs, event_set->pss_len); if (addrs == NULL) @@ -8267,23 +8158,23 @@ pool_svc_exclude_ranks(struct pool_svc *svc, struct pool_svc_event_set *event_se } struct evict_iter_arg { - uuid_t *eia_hdl_uuids; - size_t eia_hdl_uuids_size; - int eia_n_hdl_uuids; - char *eia_machine; + uuid_t *eia_hdl_uuids; + size_t eia_hdl_uuids_size; + int eia_n_hdl_uuids; + char *eia_machine; struct pool_svc *eia_pool_svc; }; static int evict_iter_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) { - struct evict_iter_arg *arg = varg; + struct evict_iter_arg *arg = varg; D_ASSERT(arg->eia_hdl_uuids != NULL); D_ASSERT(arg->eia_hdl_uuids_size > sizeof(uuid_t)); if (key->iov_len != sizeof(uuid_t)) { - D_ERROR("invalid key size: "DF_U64"\n", key->iov_len); + D_ERROR("invalid key size: " DF_U64 "\n", key->iov_len); return -DER_IO; } if (val->iov_len == sizeof(struct pool_hdl_v0)) { @@ -8294,8 +8185,8 @@ evict_iter_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) if (arg->eia_machine) return 0; } else { - D_ERROR("invalid value size: "DF_U64" for pool version %u\n", val->iov_len, - arg->eia_pool_svc->ps_global_version); + D_ERROR("invalid value size: " DF_U64 " for pool version %u\n", + val->iov_len, arg->eia_pool_svc->ps_global_version); return -DER_IO; } } else { @@ -8303,19 +8194,20 @@ evict_iter_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) if (val->iov_len != sizeof(struct pool_hdl) + hdl->ph_cred_len || arg->eia_pool_svc->ps_global_version < DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED) { - D_ERROR("invalid value size: "DF_U64" for pool version %u, expected %zu\n", + D_ERROR("invalid value size: " DF_U64 + " for pool version %u, expected %zu\n", val->iov_len, arg->eia_pool_svc->ps_global_version, arg->eia_pool_svc->ps_global_version < - DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED ? - sizeof(struct pool_hdl_v0) : - sizeof(struct pool_hdl) + hdl->ph_cred_len); + DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED + ? sizeof(struct pool_hdl_v0) + : sizeof(struct pool_hdl) + hdl->ph_cred_len); return -DER_IO; } } /* If we specified a machine name as a filter check before we do the realloc */ if (arg->eia_machine) { - struct pool_hdl *hdl = val->iov_buf; + struct pool_hdl *hdl = val->iov_buf; if (strncmp(arg->eia_machine, hdl->ph_machine, sizeof(hdl->ph_machine)) != 0) { return 0; @@ -8326,19 +8218,17 @@ evict_iter_cb(daos_handle_t ih, d_iov_t *key, d_iov_t *val, void *varg) * Make sure arg->eia_hdl_uuids[arg->eia_hdl_uuids_size] have enough * space for this handle. */ - if (sizeof(uuid_t) * (arg->eia_n_hdl_uuids + 1) > - arg->eia_hdl_uuids_size) { + if (sizeof(uuid_t) * (arg->eia_n_hdl_uuids + 1) > arg->eia_hdl_uuids_size) { uuid_t *hdl_uuids_tmp; - size_t hdl_uuids_size_tmp; + size_t hdl_uuids_size_tmp; hdl_uuids_size_tmp = arg->eia_hdl_uuids_size * 2; D_ALLOC(hdl_uuids_tmp, hdl_uuids_size_tmp); if (hdl_uuids_tmp == NULL) return -DER_NOMEM; - memcpy(hdl_uuids_tmp, arg->eia_hdl_uuids, - arg->eia_hdl_uuids_size); + memcpy(hdl_uuids_tmp, arg->eia_hdl_uuids, arg->eia_hdl_uuids_size); D_FREE(arg->eia_hdl_uuids); - arg->eia_hdl_uuids = hdl_uuids_tmp; + arg->eia_hdl_uuids = hdl_uuids_tmp; arg->eia_hdl_uuids_size = hdl_uuids_size_tmp; } @@ -8354,8 +8244,8 @@ static int find_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, uuid_t **hdl_uuids, size_t *hdl_uuids_size, int *n_hdl_uuids, char *machine) { - struct evict_iter_arg arg = {0}; - int rc; + struct evict_iter_arg arg = {0}; + int rc; arg.eia_hdl_uuids_size = sizeof(uuid_t) * 4; D_ALLOC(arg.eia_hdl_uuids, arg.eia_hdl_uuids_size); @@ -8366,16 +8256,15 @@ find_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, uuid_t **hdl_uuids, arg.eia_machine = machine; arg.eia_pool_svc = svc; - rc = rdb_tx_iterate(tx, &svc->ps_handles, false /* backward */, - evict_iter_cb, &arg); + rc = rdb_tx_iterate(tx, &svc->ps_handles, false /* backward */, evict_iter_cb, &arg); if (rc != 0) { D_FREE(arg.eia_hdl_uuids); return rc; } - *hdl_uuids = arg.eia_hdl_uuids; + *hdl_uuids = arg.eia_hdl_uuids; *hdl_uuids_size = arg.eia_hdl_uuids_size; - *n_hdl_uuids = arg.eia_n_hdl_uuids; + *n_hdl_uuids = arg.eia_n_hdl_uuids; return 0; } @@ -8383,15 +8272,15 @@ find_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, uuid_t **hdl_uuids, * Callers are responsible for freeing *hdl_uuids if this function returns zero. */ static int -validate_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, - uuid_t **hdl_uuids, int *n_hdl_uuids, uuid_t *hdl_list, - int n_hdl_list) { - uuid_t *valid_list; - int n_valid_list = 0; - int i; - int rc = 0; - d_iov_t key; - d_iov_t value; +validate_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, uuid_t **hdl_uuids, + int *n_hdl_uuids, uuid_t *hdl_list, int n_hdl_list) +{ + uuid_t *valid_list; + int n_valid_list = 0; + int i; + int rc = 0; + d_iov_t key; + d_iov_t value; if (hdl_list == NULL || n_hdl_list == 0) { return -DER_INVAL; @@ -8422,7 +8311,7 @@ validate_hdls_to_evict(struct rdb_tx *tx, struct pool_svc *svc, } } - *hdl_uuids = valid_list; + *hdl_uuids = valid_list; *n_hdl_uuids = n_valid_list; out: @@ -8445,11 +8334,9 @@ ds_pool_evict_handler(crt_rpc_t *rpc) bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); int rc; - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->pvi_op.pi_uuid), rpc); + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->pvi_op.pi_uuid), rpc); - rc = pool_svc_lookup_leader(in->pvi_op.pi_uuid, &svc, - &out->pvo_op.po_hint); + rc = pool_svc_lookup_leader(in->pvi_op.pi_uuid, &svc, &out->pvo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -8474,11 +8361,10 @@ ds_pool_evict_handler(crt_rpc_t *rpc) */ if (in->pvi_hdls.ca_arrays) { rc = validate_hdls_to_evict(&tx, svc, &hdl_uuids, &n_hdl_uuids, - in->pvi_hdls.ca_arrays, - in->pvi_hdls.ca_count); + in->pvi_hdls.ca_arrays, in->pvi_hdls.ca_count); } else { - rc = find_hdls_to_evict(&tx, svc, &hdl_uuids, &hdl_uuids_size, - &n_hdl_uuids, in->pvi_machine); + rc = find_hdls_to_evict(&tx, svc, &hdl_uuids, &hdl_uuids_size, &n_hdl_uuids, + in->pvi_machine); } if (rc != 0) @@ -8489,7 +8375,7 @@ ds_pool_evict_handler(crt_rpc_t *rpc) /* If pool destroy but not forcibly, error: the pool is busy */ if (in->pvi_pool_destroy && !in->pvi_pool_destroy_force) { - D_DEBUG(DB_MD, DF_UUID": busy, %u open handles\n", + D_DEBUG(DB_MD, DF_UUID ": busy, %u open handles\n", DP_UUID(in->pvi_op.pi_uuid), n_hdl_uuids); D_GOTO(out_free, rc = -DER_BUSY); } else { @@ -8498,7 +8384,7 @@ ds_pool_evict_handler(crt_rpc_t *rpc) rc = 0; /* unrealistic */ else rc = pool_disconnect_hdls(&tx, svc, hdl_uuids, n_hdl_uuids, - rpc->cr_ctx); + dss_get_module_info()->dmi_ctx); if (rc != 0) { goto out_free; } else { @@ -8513,8 +8399,8 @@ ds_pool_evict_handler(crt_rpc_t *rpc) /* If pool destroy and not error case, disable new connections */ if (in->pvi_pool_destroy) { - uint32_t connectable = 0; - d_iov_t value; + uint32_t connectable = 0; + d_iov_t value; d_iov_set(&value, &connectable, sizeof(connectable)); rc = rdb_tx_update_critical(&tx, &svc->ps_root, &ds_pool_prop_connectable, &value); @@ -8523,8 +8409,10 @@ ds_pool_evict_handler(crt_rpc_t *rpc) ds_pool_iv_srv_hdl_invalidate(svc->ps_pool); ds_iv_ns_leader_stop(svc->ps_pool->sp_iv_ns); - D_DEBUG(DB_MD, DF_UUID": pool destroy/evict: mark pool for " - "no new connections\n", DP_UUID(in->pvi_op.pi_uuid)); + D_DEBUG(DB_MD, + DF_UUID ": pool destroy/evict: mark pool for " + "no new connections\n", + DP_UUID(in->pvi_op.pi_uuid)); } out_free: @@ -8566,7 +8454,7 @@ ds_pool_evict_handler(crt_rpc_t *rpc) DP_UUID(in->pvi_op.pi_uuid)); } - out->pvo_op.po_rc = rc; + out->pvo_op.po_rc = rc; out->pvo_n_hdls_evicted = n_hdl_uuids; D_DEBUG(DB_MD, DF_UUID ": replying rpc: %p " DF_RC "\n", DP_UUID(in->pvi_op.pi_uuid), rpc, DP_RC(rc)); @@ -8580,19 +8468,19 @@ ds_pool_evict_handler(crt_rpc_t *rpc) * for another RPC request. */ static int -transfer_ranks_buf(d_rank_t *ranks_buf, size_t nranks, - struct pool_svc *svc, crt_rpc_t *rpc, crt_bulk_t remote_bulk) -{ - size_t ranks_buf_size; - daos_size_t remote_bulk_size; - d_iov_t ranks_iov; - d_sg_list_t ranks_sgl; - crt_bulk_t bulk = CRT_BULK_NULL; - struct crt_bulk_desc bulk_desc; - crt_bulk_opid_t bulk_opid; - ABT_eventual eventual; - int *status; - int rc; +transfer_ranks_buf(d_rank_t *ranks_buf, size_t nranks, struct pool_svc *svc, crt_rpc_t *rpc, + crt_bulk_t remote_bulk) +{ + size_t ranks_buf_size; + daos_size_t remote_bulk_size; + d_iov_t ranks_iov; + d_sg_list_t ranks_sgl; + crt_bulk_t bulk = CRT_BULK_NULL; + struct crt_bulk_desc bulk_desc; + crt_bulk_opid_t bulk_opid; + ABT_eventual eventual; + int *status; + int rc; D_ASSERT(nranks > 0); ranks_buf_size = nranks * sizeof(d_rank_t); @@ -8603,28 +8491,28 @@ transfer_ranks_buf(d_rank_t *ranks_buf, size_t nranks, D_GOTO(out, rc); if (remote_bulk_size < ranks_buf_size) { D_ERROR(DF_UUID ": remote ranks buffer(" DF_U64 ")" - " < required (%lu)\n", DP_UUID(svc->ps_uuid), - remote_bulk_size, ranks_buf_size); + " < required (%lu)\n", + DP_UUID(svc->ps_uuid), remote_bulk_size, ranks_buf_size); D_GOTO(out, rc = -DER_TRUNC); } d_iov_set(&ranks_iov, ranks_buf, ranks_buf_size); - ranks_sgl.sg_nr = 1; + ranks_sgl.sg_nr = 1; ranks_sgl.sg_nr_out = 0; - ranks_sgl.sg_iovs = &ranks_iov; + ranks_sgl.sg_iovs = &ranks_iov; rc = crt_bulk_create(rpc->cr_ctx, &ranks_sgl, CRT_BULK_RO, &bulk); if (rc != 0) D_GOTO(out, rc); /* Prepare for crt_bulk_transfer(). */ - bulk_desc.bd_rpc = rpc; - bulk_desc.bd_bulk_op = CRT_BULK_PUT; + bulk_desc.bd_rpc = rpc; + bulk_desc.bd_bulk_op = CRT_BULK_PUT; bulk_desc.bd_remote_hdl = remote_bulk; bulk_desc.bd_remote_off = 0; - bulk_desc.bd_local_hdl = bulk; - bulk_desc.bd_local_off = 0; - bulk_desc.bd_len = ranks_iov.iov_len; + bulk_desc.bd_local_hdl = bulk; + bulk_desc.bd_local_off = 0; + bulk_desc.bd_len = ranks_iov.iov_len; rc = ABT_eventual_create(sizeof(*status), &eventual); if (rc != ABT_SUCCESS) @@ -8655,17 +8543,16 @@ transfer_ranks_buf(d_rank_t *ranks_buf, size_t nranks, void ds_pool_ranks_get_handler(crt_rpc_t *rpc) { - struct pool_ranks_get_in *in = crt_req_get(rpc); - struct pool_ranks_get_out *out = crt_reply_get(rpc); - uint32_t nranks = 0; - d_rank_list_t out_ranks = {0}; - struct pool_svc *svc; - int rc; + struct pool_ranks_get_in *in = crt_req_get(rpc); + struct pool_ranks_get_out *out = crt_reply_get(rpc); + uint32_t nranks = 0; + d_rank_list_t out_ranks = {0}; + struct pool_svc *svc; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p\n", DP_UUID(in->prgi_op.pi_uuid), rpc); - rc = pool_svc_lookup_leader(in->prgi_op.pi_uuid, &svc, - &out->prgo_op.po_hint); + rc = pool_svc_lookup_leader(in->prgi_op.pi_uuid, &svc, &out->prgo_op.po_hint); if (rc != 0) D_GOTO(out, rc); @@ -8676,22 +8563,19 @@ ds_pool_ranks_get_handler(crt_rpc_t *rpc) /* Get available ranks */ rc = ds_pool_get_ranks(in->prgi_op.pi_uuid, DC_POOL_GROUP_MAP_STATES, &out_ranks); if (rc != 0) { - D_ERROR(DF_UUID ": get ranks failed, " DF_RC "\n", - DP_UUID(in->prgi_op.pi_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": get ranks failed, " DF_RC "\n", DP_UUID(in->prgi_op.pi_uuid), + DP_RC(rc)); D_GOTO(out_svc, rc); - } else if ((in->prgi_nranks > 0) && - (out_ranks.rl_nr > in->prgi_nranks)) { + } else if ((in->prgi_nranks > 0) && (out_ranks.rl_nr > in->prgi_nranks)) { D_DEBUG(DB_MD, DF_UUID ": %u ranks (more than client: %u)\n", - DP_UUID(in->prgi_op.pi_uuid), out_ranks.rl_nr, - in->prgi_nranks); + DP_UUID(in->prgi_op.pi_uuid), out_ranks.rl_nr, in->prgi_nranks); D_GOTO(out_free, rc = -DER_TRUNC); } else { - D_DEBUG(DB_MD, DF_UUID ": %u ranks\n", - DP_UUID(in->prgi_op.pi_uuid), out_ranks.rl_nr); + D_DEBUG(DB_MD, DF_UUID ": %u ranks\n", DP_UUID(in->prgi_op.pi_uuid), + out_ranks.rl_nr); if ((out_ranks.rl_nr > 0) && (in->prgi_nranks > 0) && (in->prgi_ranks_bulk != CRT_BULK_NULL)) - rc = transfer_ranks_buf(out_ranks.rl_ranks, - out_ranks.rl_nr, svc, rpc, + rc = transfer_ranks_buf(out_ranks.rl_ranks, out_ranks.rl_nr, svc, rpc, in->prgi_ranks_bulk); } @@ -8704,7 +8588,7 @@ ds_pool_ranks_get_handler(crt_rpc_t *rpc) pool_svc_put_leader(svc); out: out->prgo_op.po_rc = rc; - out->prgo_nranks = nranks; + out->prgo_nranks = nranks; D_DEBUG(DB_MD, DF_UUID ": replying rpc: %p " DF_RC "\n", DP_UUID(in->prgi_op.pi_uuid), rpc, DP_RC(rc)); crt_reply_send(rpc); @@ -8714,13 +8598,12 @@ ds_pool_ranks_get_handler(crt_rpc_t *rpc) static void pool_svc_stop_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_svc_stop_in *in = crt_req_get(rpc); - struct pool_svc_stop_out *out = crt_reply_get(rpc); - d_iov_t id; - int rc; + struct pool_svc_stop_in *in = crt_req_get(rpc); + struct pool_svc_stop_out *out = crt_reply_get(rpc); + d_iov_t id; + int rc; - D_DEBUG(DB_MD, DF_UUID": processing rpc %p\n", - DP_UUID(in->psi_op.pi_uuid), rpc); + D_DEBUG(DB_MD, DF_UUID ": processing rpc %p\n", DP_UUID(in->psi_op.pi_uuid), rpc); d_iov_set(&id, in->psi_op.pi_uuid, sizeof(uuid_t)); rc = ds_rsvc_stop_leader(DS_RSVC_CLASS_POOL, &id, &out->pso_op.po_hint); @@ -8818,10 +8701,10 @@ ds_pool_rebuild_start(uuid_t pool_uuid, struct rsvc_hint *hint) int ds_pool_map_buf_get(uuid_t uuid, d_iov_t *iov, uint32_t *map_version) { - struct pool_svc *svc; - struct rdb_tx tx; - struct pool_buf *map_buf; - int rc; + struct pool_svc *svc; + struct rdb_tx tx; + struct pool_buf *map_buf; + int rc; rc = pool_svc_lookup_leader(uuid, &svc, NULL /* hint */); if (rc != 0) @@ -8834,13 +8717,13 @@ ds_pool_map_buf_get(uuid_t uuid, d_iov_t *iov, uint32_t *map_version) ABT_rwlock_rdlock(svc->ps_lock); rc = read_map_buf(&tx, &svc->ps_root, &map_buf, map_version); if (rc != 0) { - D_ERROR(DF_UUID": failed to read pool map: "DF_RC"\n", - DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_ERROR(DF_UUID ": failed to read pool map: " DF_RC "\n", DP_UUID(svc->ps_uuid), + DP_RC(rc)); D_GOTO(out_lock, rc); } D_ASSERT(map_buf != NULL); - iov->iov_buf = map_buf; - iov->iov_len = pool_buf_size(map_buf->pb_nr); + iov->iov_buf = map_buf; + iov->iov_len = pool_buf_size(map_buf->pb_nr); iov->iov_buf_len = pool_buf_size(map_buf->pb_nr); out_lock: ABT_rwlock_unlock(svc->ps_lock); @@ -8852,8 +8735,7 @@ ds_pool_map_buf_get(uuid_t uuid, d_iov_t *iov, uint32_t *map_version) } void -ds_pool_iv_ns_update(struct ds_pool *pool, unsigned int master_rank, - uint64_t term) +ds_pool_iv_ns_update(struct ds_pool *pool, unsigned int master_rank, uint64_t term) { ds_iv_ns_update(pool->sp_iv_ns, master_rank, term); } @@ -8861,8 +8743,8 @@ ds_pool_iv_ns_update(struct ds_pool *pool, unsigned int master_rank, int ds_pool_svc_query_map_dist(uuid_t uuid, uint32_t *version, bool *idle) { - struct pool_svc *svc; - int rc; + struct pool_svc *svc; + int rc; rc = pool_svc_lookup_leader(uuid, &svc, NULL /* hint */); if (rc != 0) @@ -8877,8 +8759,8 @@ ds_pool_svc_query_map_dist(uuid_t uuid, uint32_t *version, bool *idle) int ds_pool_svc_term_get(uuid_t uuid, uint64_t *term) { - struct pool_svc *svc; - int rc; + struct pool_svc *svc; + int rc; rc = pool_svc_lookup_leader(uuid, &svc, NULL /* hint */); if (rc != 0) @@ -8893,17 +8775,17 @@ ds_pool_svc_term_get(uuid_t uuid, uint64_t *term) static void pool_attr_set_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_attr_set_in *in = crt_req_get(rpc); - struct pool_op_out *out = crt_reply_get(rpc); - struct pool_svc *svc; + struct pool_attr_set_in *in = crt_req_get(rpc); + struct pool_op_out *out = crt_reply_get(rpc); + struct pool_svc *svc; uint64_t count; crt_bulk_t bulk; - struct rdb_tx tx; + struct rdb_tx tx; bool dup_op = false; struct ds_pool_svc_op_val op_val; bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - int rc; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pasi_op.pi_uuid), rpc, DP_UUID(in->pasi_op.pi_hdl)); @@ -8975,17 +8857,17 @@ ds_pool_attr_set_handler(crt_rpc_t *rpc) static void pool_attr_del_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_attr_del_in *in = crt_req_get(rpc); - struct pool_op_out *out = crt_reply_get(rpc); - struct pool_svc *svc; + struct pool_attr_del_in *in = crt_req_get(rpc); + struct pool_op_out *out = crt_reply_get(rpc); + struct pool_svc *svc; uint64_t count; crt_bulk_t bulk; - struct rdb_tx tx; + struct rdb_tx tx; bool dup_op = false; struct ds_pool_svc_op_val op_val; bool fi_pass_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_PASS_NOREPLY); bool fi_fail_noreply = DAOS_FAIL_CHECK(DAOS_MD_OP_FAIL_NOREPLY); - int rc; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->padi_op.pi_uuid), rpc, DP_UUID(in->padi_op.pi_hdl)); @@ -9056,14 +8938,14 @@ ds_pool_attr_del_handler(crt_rpc_t *rpc) static void pool_attr_get_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_attr_get_in *in = crt_req_get(rpc); - struct pool_op_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - uint64_t count; - uint64_t key_length; - crt_bulk_t bulk; - struct rdb_tx tx; - int rc; + struct pool_attr_get_in *in = crt_req_get(rpc); + struct pool_op_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + uint64_t count; + uint64_t key_length; + crt_bulk_t bulk; + struct rdb_tx tx; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pagi_op.pi_uuid), rpc, DP_UUID(in->pagi_op.pi_hdl)); @@ -9101,18 +8983,17 @@ ds_pool_attr_get_handler(crt_rpc_t *rpc) static void pool_attr_list_handler(crt_rpc_t *rpc, int handler_version) { - struct pool_attr_list_in *in = crt_req_get(rpc); - struct pool_attr_list_out *out = crt_reply_get(rpc); - struct pool_svc *svc; - crt_bulk_t bulk; - struct rdb_tx tx; - int rc; + struct pool_attr_list_in *in = crt_req_get(rpc); + struct pool_attr_list_out *out = crt_reply_get(rpc); + struct pool_svc *svc; + crt_bulk_t bulk; + struct rdb_tx tx; + int rc; D_DEBUG(DB_MD, DF_UUID ": processing rpc: %p hdl=" DF_UUID "\n", DP_UUID(in->pali_op.pi_uuid), rpc, DP_UUID(in->pali_op.pi_hdl)); - rc = pool_svc_lookup_leader(in->pali_op.pi_uuid, &svc, - &out->palo_op.po_hint); + rc = pool_svc_lookup_leader(in->pali_op.pi_uuid, &svc, &out->palo_op.po_hint); if (rc != 0) goto out; @@ -9145,11 +9026,11 @@ ds_pool_attr_list_handler(crt_rpc_t *rpc) void ds_pool_replicas_update_handler(crt_rpc_t *rpc) { - struct pool_membership_in *in = crt_req_get(rpc); - struct pool_membership_out *out = crt_reply_get(rpc); - d_rank_list_t *ranks; - d_iov_t id; - int rc; + struct pool_membership_in *in = crt_req_get(rpc); + struct pool_membership_out *out = crt_reply_get(rpc); + d_rank_list_t *ranks; + d_iov_t id; + int rc; rc = daos_rank_list_dup(&ranks, in->pmi_targets); if (rc != 0) @@ -9187,10 +9068,10 @@ ds_pool_replicas_update_handler(crt_rpc_t *rpc) int ds_pool_child_map_refresh_sync(struct ds_pool_child *dpc) { - struct pool_map_refresh_ult_arg arg; - ABT_eventual eventual; - int *status; - int rc; + struct pool_map_refresh_ult_arg arg; + ABT_eventual eventual; + int *status; + int rc; rc = ABT_eventual_create(sizeof(*status), &eventual); if (rc != ABT_SUCCESS) @@ -9200,8 +9081,7 @@ ds_pool_child_map_refresh_sync(struct ds_pool_child *dpc) uuid_copy(arg.iua_pool_uuid, dpc->spc_uuid); arg.iua_eventual = eventual; - rc = dss_ult_create(ds_pool_map_refresh_ult, &arg, DSS_XS_SYS, - 0, 0, NULL); + rc = dss_ult_create(ds_pool_map_refresh_ult, &arg, DSS_XS_SYS, 0, 0, NULL); if (rc) D_GOTO(out_eventual, rc); @@ -9219,8 +9099,8 @@ ds_pool_child_map_refresh_sync(struct ds_pool_child *dpc) int ds_pool_child_map_refresh_async(struct ds_pool_child *dpc) { - struct pool_map_refresh_ult_arg *arg; - int rc; + struct pool_map_refresh_ult_arg *arg; + int rc; D_ALLOC_PTR(arg); if (arg == NULL) @@ -9228,17 +9108,16 @@ ds_pool_child_map_refresh_async(struct ds_pool_child *dpc) arg->iua_pool_version = dpc->spc_map_version; uuid_copy(arg->iua_pool_uuid, dpc->spc_uuid); - rc = dss_ult_create(ds_pool_map_refresh_ult, arg, DSS_XS_SYS, - 0, 0, NULL); + rc = dss_ult_create(ds_pool_map_refresh_ult, arg, DSS_XS_SYS, 0, 0, NULL); return rc; } -int ds_pool_prop_fetch(struct ds_pool *pool, unsigned int bits, - daos_prop_t **prop_out) +int +ds_pool_prop_fetch(struct ds_pool *pool, unsigned int bits, daos_prop_t **prop_out) { - struct pool_svc *svc; - struct rdb_tx tx; - int rc; + struct pool_svc *svc; + struct rdb_tx tx; + int rc; rc = pool_svc_lookup_leader(pool->sp_uuid, &svc, NULL); if (rc != 0) @@ -9274,8 +9153,8 @@ int ds_pool_prop_fetch(struct ds_pool *pool, unsigned int bits, int ds_pool_hdl_is_from_srv(struct ds_pool *pool, uuid_t hdl) { - uuid_t srv_hdl; - int rc; + uuid_t srv_hdl; + int rc; /* * Use the cached value if available. (Not sure if this cache could be @@ -9294,20 +9173,19 @@ ds_pool_hdl_is_from_srv(struct ds_pool *pool, uuid_t hdl) static bool is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid) { - struct ds_pool *pool; - int rc; + struct ds_pool *pool; + int rc; rc = ds_pool_lookup(pool_uuid, &pool); if (rc) { - D_ERROR(DF_UUID": failed to get ds_pool: %d\n", - DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID ": failed to get ds_pool: %d\n", DP_UUID(pool_uuid), rc); return false; } rc = ds_pool_hdl_is_from_srv(pool, poh_uuid); ds_pool_put(pool); if (rc < 0) { - D_ERROR(DF_UUID" fetch srv hdl: %d\n", DP_UUID(pool_uuid), rc); + D_ERROR(DF_UUID " fetch srv hdl: %d\n", DP_UUID(pool_uuid), rc); return false; } @@ -9319,7 +9197,7 @@ int ds_pool_target_status(struct ds_pool *pool, uint32_t id) { struct pool_target *target; - int rc; + int rc; ABT_rwlock_rdlock(pool->sp_lock); rc = pool_map_find_target(pool->sp_map, id, &target); @@ -9336,7 +9214,7 @@ ds_pool_target_status_check(struct ds_pool *pool, uint32_t id, uint8_t matched_s struct pool_target **p_tgt) { struct pool_target *target; - int rc; + int rc; ABT_rwlock_rdlock(pool->sp_lock); rc = pool_map_find_target(pool->sp_map, id, &target); @@ -9359,20 +9237,20 @@ ds_pool_target_status_check(struct ds_pool *pool, uint32_t id, uint8_t matched_s int ds_pool_lookup_hdl_cred(struct rdb_tx *tx, uuid_t pool_uuid, uuid_t pool_hdl_uuid, d_iov_t *cred) { - struct pool_svc *svc; - d_iov_t key; - d_iov_t value; - struct pool_hdl *hdl; - void *buf; - int rc; + struct pool_svc *svc; + d_iov_t key; + d_iov_t value; + struct pool_hdl *hdl; + void *buf; + int rc; rc = pool_svc_lookup_leader(pool_uuid, &svc, NULL /* hint */); if (rc != 0) goto out; if (svc->ps_global_version < DAOS_POOL_GLOBAL_VERSION_WITH_HDL_CRED) { - D_ERROR(DF_UUID": no credential in pool global version %u\n", DP_UUID(svc->ps_uuid), - svc->ps_global_version); + D_ERROR(DF_UUID ": no credential in pool global version %u\n", + DP_UUID(svc->ps_uuid), svc->ps_global_version); rc = -DER_NOTSUPPORTED; goto out_svc; } @@ -9391,8 +9269,8 @@ ds_pool_lookup_hdl_cred(struct rdb_tx *tx, uuid_t pool_uuid, uuid_t pool_hdl_uui } memcpy(buf, hdl->ph_cred, hdl->ph_cred_len); - cred->iov_buf = buf; - cred->iov_len = hdl->ph_cred_len; + cred->iov_buf = buf; + cred->iov_len = hdl->ph_cred_len; cred->iov_buf_len = hdl->ph_cred_len; out_svc: @@ -9404,9 +9282,9 @@ ds_pool_lookup_hdl_cred(struct rdb_tx *tx, uuid_t pool_uuid, uuid_t pool_hdl_uui int ds_pool_mark_connectable(struct ds_pool_svc *ds_svc) { - struct pool_svc *svc = pool_ds2svc(ds_svc); - struct rdb_tx tx; - int rc; + struct pool_svc *svc = pool_ds2svc(ds_svc); + struct rdb_tx tx; + int rc; rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc == 0) { @@ -9424,9 +9302,9 @@ ds_pool_mark_connectable(struct ds_pool_svc *ds_svc) int ds_pool_svc_load_map(struct ds_pool_svc *ds_svc, struct pool_map **map) { - struct pool_svc *svc = pool_ds2svc(ds_svc); - struct rdb_tx tx = { 0 }; - int rc; + struct pool_svc *svc = pool_ds2svc(ds_svc); + struct rdb_tx tx = {0}; + int rc; rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc == 0) { @@ -9437,7 +9315,7 @@ ds_pool_svc_load_map(struct ds_pool_svc *ds_svc, struct pool_map **map) } if (rc != 0) - D_ERROR("Failed to load pool map for pool "DF_UUIDF": "DF_RC"\n", + D_ERROR("Failed to load pool map for pool " DF_UUIDF ": " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); return rc; @@ -9446,18 +9324,19 @@ ds_pool_svc_load_map(struct ds_pool_svc *ds_svc, struct pool_map **map) int ds_pool_svc_flush_map(struct ds_pool_svc *ds_svc, struct pool_map *map) { - struct pool_svc *svc = pool_ds2svc(ds_svc); - struct pool_buf *buf = NULL; - struct rdb_tx tx = { 0 }; - uint32_t version; - int rc = 0; - bool locked = false; + struct pool_svc *svc = pool_ds2svc(ds_svc); + struct pool_buf *buf = NULL; + struct rdb_tx tx = {0}; + uint32_t version; + int rc = 0; + bool locked = false; version = pool_map_get_version(map); - rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); + rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc != 0) { - D_ERROR("Failed to begin TX for flush pool "DF_UUIDF" map with version %u: " - DF_RC"\n", DP_UUID(svc->ps_uuid), version, DP_RC(rc)); + D_ERROR("Failed to begin TX for flush pool " DF_UUIDF " map with version %u: " DF_RC + "\n", + DP_UUID(svc->ps_uuid), version, DP_RC(rc)); goto out; } @@ -9466,30 +9345,34 @@ ds_pool_svc_flush_map(struct ds_pool_svc *ds_svc, struct pool_map *map) rc = pool_buf_extract(map, &buf); if (rc != 0) { - D_ERROR("Failed to extract buf for flush pool "DF_UUIDF" map with version %u: " - DF_RC"\n", DP_UUID(svc->ps_uuid), version, DP_RC(rc)); + D_ERROR("Failed to extract buf for flush pool " DF_UUIDF + " map with version %u: " DF_RC "\n", + DP_UUID(svc->ps_uuid), version, DP_RC(rc)); goto out_lock; } rc = write_map_buf(&tx, &svc->ps_root, buf, version); if (rc != 0) { - D_ERROR("Failed to write buf for flush pool "DF_UUIDF" map with version %u: " - DF_RC"\n", DP_UUID(svc->ps_uuid), version, DP_RC(rc)); + D_ERROR("Failed to write buf for flush pool " DF_UUIDF + " map with version %u: " DF_RC "\n", + DP_UUID(svc->ps_uuid), version, DP_RC(rc)); goto out_buf; } rc = rdb_tx_commit(&tx); if (rc != 0) { - D_ERROR("Failed to commit TX for flush pool "DF_UUIDF" map with version %u: " - DF_RC"\n", DP_UUID(svc->ps_uuid), version, DP_RC(rc)); + D_ERROR("Failed to commit TX for flush pool " DF_UUIDF + " map with version %u: " DF_RC "\n", + DP_UUID(svc->ps_uuid), version, DP_RC(rc)); goto out_buf; } /* Update svc->ps_pool to match the new pool map. */ rc = ds_pool_tgt_map_update(svc->ps_pool, buf, version); if (rc != 0) { - D_ERROR("Failed to refresh local pool "DF_UUIDF" map with version %u: " - DF_RC"\n", DP_UUID(svc->ps_uuid), version, DP_RC(rc)); + D_ERROR("Failed to refresh local pool " DF_UUIDF " map with version %u: " DF_RC + "\n", + DP_UUID(svc->ps_uuid), version, DP_RC(rc)); /* * Have to resign to avoid handling future requests with stale pool map cache. * Continue to distribute the new pool map to other pool shards since the RDB @@ -9516,10 +9399,10 @@ ds_pool_svc_flush_map(struct ds_pool_svc *ds_svc, struct pool_map *map) int ds_pool_svc_update_label(struct ds_pool_svc *ds_svc, const char *label) { - struct pool_svc *svc = pool_ds2svc(ds_svc); - daos_prop_t *prop = NULL; - struct rdb_tx tx = { 0 }; - int rc = 0; + struct pool_svc *svc = pool_ds2svc(ds_svc); + daos_prop_t *prop = NULL; + struct rdb_tx tx = {0}; + int rc = 0; prop = daos_prop_alloc(1); if (prop == NULL) @@ -9532,12 +9415,12 @@ ds_pool_svc_update_label(struct ds_pool_svc *ds_svc, const char *label) D_GOTO(out, rc = -DER_NOMEM); } else { prop->dpp_entries[0].dpe_flags = DAOS_PROP_ENTRY_NOT_SET; - prop->dpp_entries[0].dpe_str = NULL; + prop->dpp_entries[0].dpe_str = NULL; } rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc != 0) { - D_ERROR("Failed to begin TX for updating pool "DF_UUIDF" label %s: "DF_RC"\n", + D_ERROR("Failed to begin TX for updating pool " DF_UUIDF " label %s: " DF_RC "\n", DP_UUID(svc->ps_uuid), label != NULL ? label : "(null)", DP_RC(rc)); D_GOTO(out, rc); } @@ -9546,14 +9429,14 @@ ds_pool_svc_update_label(struct ds_pool_svc *ds_svc, const char *label) rc = pool_prop_write(&tx, &svc->ps_root, prop); if (rc != 0) { - D_ERROR("Failed to updating pool "DF_UUIDF" label %s: "DF_RC"\n", + D_ERROR("Failed to updating pool " DF_UUIDF " label %s: " DF_RC "\n", DP_UUID(svc->ps_uuid), label != NULL ? label : "(null)", DP_RC(rc)); D_GOTO(out_lock, rc); } rc = rdb_tx_commit(&tx); if (rc != 0) - D_ERROR("Failed to commit TX for updating pool "DF_UUIDF" label %s: "DF_RC"\n", + D_ERROR("Failed to commit TX for updating pool " DF_UUIDF " label %s: " DF_RC "\n", DP_UUID(svc->ps_uuid), label != NULL ? label : "(null)", DP_RC(rc)); out_lock: @@ -9567,17 +9450,17 @@ ds_pool_svc_update_label(struct ds_pool_svc *ds_svc, const char *label) int ds_pool_svc_evict_all(struct ds_pool_svc *ds_svc) { - struct pool_svc *svc = pool_ds2svc(ds_svc); - struct pool_metrics *metrics; - uuid_t *hdl_uuids = NULL; - struct rdb_tx tx = { 0 }; - size_t hdl_uuids_size = 0; - int n_hdl_uuids = 0; - int rc = 0; + struct pool_svc *svc = pool_ds2svc(ds_svc); + struct pool_metrics *metrics; + uuid_t *hdl_uuids = NULL; + struct rdb_tx tx = {0}; + size_t hdl_uuids_size = 0; + int n_hdl_uuids = 0; + int rc = 0; rc = rdb_tx_begin(svc->ps_rsvc.s_db, svc->ps_rsvc.s_term, &tx); if (rc != 0) { - D_ERROR("Failed to begin TX for evict pool "DF_UUIDF" connections: "DF_RC"\n", + D_ERROR("Failed to begin TX for evict pool " DF_UUIDF " connections: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); D_GOTO(out, rc); } @@ -9586,7 +9469,7 @@ ds_pool_svc_evict_all(struct ds_pool_svc *ds_svc) rc = find_hdls_to_evict(&tx, svc, &hdl_uuids, &hdl_uuids_size, &n_hdl_uuids, NULL); if (rc != 0) { - D_ERROR("Failed to find hdls for evict pool "DF_UUIDF" connections: "DF_RC"\n", + D_ERROR("Failed to find hdls for evict pool " DF_UUIDF " connections: " DF_RC "\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); D_GOTO(out_lock, rc); } @@ -9601,8 +9484,9 @@ ds_pool_svc_evict_all(struct ds_pool_svc *ds_svc) d_tm_inc_counter(metrics->evict_total, n_hdl_uuids); rc = rdb_tx_commit(&tx); if (rc != 0) - D_ERROR("Failed to commit TX for evict pool "DF_UUIDF" connections: " - DF_RC"\n", DP_UUID(svc->ps_uuid), DP_RC(rc)); + D_ERROR("Failed to commit TX for evict pool " DF_UUIDF + " connections: " DF_RC "\n", + DP_UUID(svc->ps_uuid), DP_RC(rc)); } out_lock: diff --git a/src/tests/ftest/cart/SConscript b/src/tests/ftest/cart/SConscript index 35336add865..3f5e461082d 100644 --- a/src/tests/ftest/cart/SConscript +++ b/src/tests/ftest/cart/SConscript @@ -8,6 +8,7 @@ import os SIMPLE_TEST_SRC = ['threaded_client.c', 'dual_iface_server.c', + 'dual_provider_server.c', 'dual_provider_client.c', 'no_pmix_multi_ctx.c', 'threaded_server.c', 'test_corpc_prefwd.c', 'test_corpc_exclusive.c', 'dump_errnos.c', diff --git a/src/tests/ftest/cart/dual_provider_client.c b/src/tests/ftest/cart/dual_provider_client.c new file mode 100644 index 00000000000..9b8a20b3338 --- /dev/null +++ b/src/tests/ftest/cart/dual_provider_client.c @@ -0,0 +1,308 @@ +/* + * (C) Copyright 2018-2022 Intel Corporation. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + */ +/** + * Dual-provider client + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "crt_utils.h" +#include "dual_provider_common.h" + +static int +g_do_shutdown; + +static void * +progress_function(void *data) +{ + crt_context_t *p_ctx = (crt_context_t *)data; + + while (g_do_shutdown == 0) + crt_progress(*p_ctx, 1000); + + crt_context_destroy(*p_ctx, 1); + + return NULL; +} + +static void +rpc_handle_reply(const struct crt_cb_info *info) +{ + sem_t *sem; + + D_ASSERTF(info->cci_rc == 0, "rpc response failed. rc: %d\n", + info->cci_rc); + + sem = (sem_t *)info->cci_arg; + sem_post(sem); +} + +int main(int argc, char **argv) +{ + crt_context_t crt_ctx; + crt_group_t *grp; + int rc; + sem_t sem; + pthread_t progress_thread; + crt_rpc_t *rpc = NULL; + struct RPC_PING_in *input; + crt_endpoint_t server_ep; + int i; + d_rank_list_t *rank_list; + d_rank_t rank; + int tag; + uint32_t grp_size; + char c; + char *arg_interface = NULL; + char *arg_domain = NULL; + char *arg_provider = NULL; + char *arg_num_ctx = NULL; + int num_remote_tags; + bool use_primary = true; + + while ((c = getopt(argc, argv, "i:p:d:c:s")) != -1) { + switch (c) { + case 'i': + arg_interface = optarg; + break; + case 'd': + arg_domain = optarg; + break; + case 'p': + arg_provider = optarg; + break; + case 'c': + arg_num_ctx = optarg; + break; + case 's': + use_primary = false; + break; + default: + printf("Error: unknown option %c\n", c); + return -1; + } + } + + if (use_primary) + unsetenv("CRT_SECONDARY_PROVIDER"); + else + setenv("CRT_SECONDARY_PROVIDER", "1", 1); + + rc = d_log_init(); + assert(rc == 0); + /* rank, num_attach_retries, is_server, assert_on_error */ + crtu_test_init(0, 20, false, true); + + DBG_PRINT("Client starting up\n"); + + rc = sem_init(&sem, 0, 0); + if (rc != 0) { + D_ERROR("sem_init() failed; rc=%d\n", rc); + assert(0); + } + + num_remote_tags = 1; + if (arg_num_ctx != NULL) + num_remote_tags = atoi(arg_num_ctx); + + DBG_PRINT("------------------------------------\n"); + DBG_PRINT("Provider: '%s' Interface: '%s' Domain: '%s'\n", + arg_provider, arg_interface, arg_domain); + DBG_PRINT("Number of remote tags: %d\n", num_remote_tags); + DBG_PRINT("Primary_provider: %d\n", use_primary); + DBG_PRINT("------------------------------------\n"); + crt_init_options_t init_opts = {0}; + + init_opts.cio_provider = arg_provider; + init_opts.cio_interface = arg_interface; + init_opts.cio_domain = arg_domain; + + rc = crt_init_opt(NULL, 0, &init_opts); + if (rc != 0) { + D_ERROR("crt_init() failed; rc=%d\n", rc); + assert(0); + } + + rc = crt_proto_register(&my_proto_fmt); + if (rc != 0) { + D_ERROR("crt_proto_register() failed; rc=%d\n", rc); + assert(0); + } + + rc = crt_context_create(&crt_ctx); + if (rc != 0) { + D_ERROR("crt_context_create() failed; rc=%d\n", rc); + assert(0); + } + + rc = pthread_create(&progress_thread, 0, + progress_function, &crt_ctx); + assert(rc == 0); + + int num_servers; + + rc = crt_group_view_create(SERVER_GROUP_NAME, &grp); + if (rc != 0) { + error_exit(); + } + + num_servers = 2; + + /* Parse /tmp/ files for uris. servers generate those */ + { + FILE *f; + char *filename; + char pri_uri0[255]; + char sec_uri0[255]; + int serv_rank; + + + for (serv_rank = 0; serv_rank < num_servers; serv_rank++) { + D_ASPRINTF(filename, "/tmp/%s_rank_%d_uris.cart", + SERVER_GROUP_NAME, serv_rank); + if (filename == NULL) + error_exit(); + + f = fopen(filename, "r"); + if (f == NULL) { + perror("failed: "); + error_exit(); + } + + rc = fscanf(f, "%254s", pri_uri0); + if (rc == EOF) + error_exit(); + + rc = fscanf(f, "%254s", sec_uri0); + if (rc == EOF) + error_exit(); + + printf("server_rank=%d\n", serv_rank); + printf("pri_uri=%s\n", pri_uri0); + printf("sec_uri=%s\n", sec_uri0); + + printf("Using %s URIs for ranks\n", + (use_primary) ? "primary" : "secondary"); + rc = crt_group_primary_rank_add(crt_ctx, grp, serv_rank, + (use_primary) ? pri_uri0 : sec_uri0); + fclose(f); + D_FREE(filename); + } + } + + /* Load group */ + rc = crt_group_size(grp, &grp_size); + if (rc != 0) { + D_ERROR("crt_group_size() failed; rc=%d\n", rc); + assert(0); + } + + rc = crt_group_ranks_get(grp, &rank_list); + if (rc != 0) { + D_ERROR("crt_group_ranks_get() failed; rc=%d\n", rc); + assert(0); + } + + DBG_PRINT("Group loaded, group size=%d\n", grp_size); + if (rank_list->rl_nr != grp_size) { + D_ERROR("rank_list differs in size. expected %d got %d\n", + grp_size, rank_list->rl_nr); + assert(0); + } + + + /* Cycle through all ranks and 8 tags and send rpc to each */ + for (i = 0; i < rank_list->rl_nr; i++) { + + rank = rank_list->rl_ranks[i]; + + for (tag = 0; tag < num_remote_tags; tag++) { + DBG_PRINT("Sending ping to %d:%d\n", rank, tag); + + server_ep.ep_rank = rank; + server_ep.ep_tag = tag; + server_ep.ep_grp = grp; + + rc = crt_req_create(crt_ctx, &server_ep, + RPC_PING, &rpc); + if (rc != 0) { + D_ERROR("crt_req_create() failed; rc=%d\n", + rc); + assert(0); + } + + input = crt_req_get(rpc); + + input->size1 = 1024; + input->size2 = 10; + rc = crt_req_send(rpc, rpc_handle_reply, &sem); + crtu_sem_timedwait(&sem, 10, __LINE__); + DBG_PRINT("Ping response from %d:%d\n", rank, tag); + } + } + + + /* Send shutdown RPC to each server */ + bool send_shutdown = false; + + + if (send_shutdown) { + for (i = 0; i < rank_list->rl_nr; i++) { + + rank = rank_list->rl_ranks[i]; + DBG_PRINT("Sending shutdown to rank=%d\n", rank); + + server_ep.ep_rank = rank; + server_ep.ep_tag = 0; + server_ep.ep_grp = grp; + + rc = crt_req_create(crt_ctx, &server_ep, RPC_SHUTDOWN, &rpc); + if (rc != 0) { + D_ERROR("crt_req_create() failed; rc=%d\n", rc); + assert(0); + } + + rc = crt_req_send(rpc, rpc_handle_reply, &sem); + crtu_sem_timedwait(&sem, 10, __LINE__); + DBG_PRINT("RPC response received from rank=%d\n", rank); + } + } + + D_FREE(rank_list->rl_ranks); + D_FREE(rank_list); + + rc = crt_group_view_destroy(grp); + if (rc != 0) { + D_ERROR("crt_group_view_destroy() failed; rc=%d\n", rc); + assert(0); + } + + g_do_shutdown = true; + pthread_join(progress_thread, NULL); + + sem_destroy(&sem); + + rc = crt_finalize(); + if (rc != 0) { + D_ERROR("crt_finalize() failed with rc=%d\n", rc); + assert(0); + } + + DBG_PRINT("Client successfully finished\n"); + d_log_fini(); + + return 0; +} diff --git a/src/tests/ftest/cart/dual_provider_common.h b/src/tests/ftest/cart/dual_provider_common.h new file mode 100644 index 00000000000..6d0d80680f0 --- /dev/null +++ b/src/tests/ftest/cart/dual_provider_common.h @@ -0,0 +1,212 @@ +/* + * (C) Copyright 2019-2022 Intel Corporation. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + */ +#ifndef __DUAL_PROVIDER_COMMON_H__ +#define __DUAL_PROVIDER_COMMON_H__ +static int do_shutdown; +static int g_my_rank; + + +static void +exit_on_line(int line) +{ + printf("Failed on line %d\n", line); + exit(0); +} + +#define error_exit() exit_on_line(__LINE__) + + +#define MY_BASE 0x010000000 +#define MY_VER 0 + +#define NUM_PRIMARY_CTX_MAX 8 +#define NUM_SECONDARY_CTX_MAX 8 + +#define SERVER_GROUP_NAME "dual_provider_group" + +#define RPC_DECLARE(name) \ + CRT_RPC_DECLARE(name, CRT_ISEQ_##name, CRT_OSEQ_##name) \ + CRT_RPC_DEFINE(name, CRT_ISEQ_##name, CRT_OSEQ_##name) + +enum { + RPC_PING = CRT_PROTO_OPC(MY_BASE, MY_VER, 0), + RPC_SHUTDOWN +} rpc_id_t; + +#define CRT_ISEQ_RPC_PING /* input fields */ \ + ((crt_bulk_t) (bulk_hdl1) CRT_VAR) \ + ((crt_bulk_t) (bulk_hdl2) CRT_VAR) \ + ((uint32_t) (size1) CRT_VAR) \ + ((uint32_t) (size2) CRT_VAR) + +#define CRT_OSEQ_RPC_PING /* output fields */ \ + ((crt_bulk_t) (ret_bulk) CRT_VAR) \ + ((int32_t) (rc) CRT_VAR) + +#define CRT_ISEQ_RPC_SHUTDOWN /* input fields */ \ + ((uint32_t) (field) CRT_VAR) + +#define CRT_OSEQ_RPC_SHUTDOWN /* output fields */ \ + ((uint32_t) (field) CRT_VAR) + + +static int handler_ping(crt_rpc_t *rpc); +static int handler_shutdown(crt_rpc_t *rpc); + +RPC_DECLARE(RPC_PING); +RPC_DECLARE(RPC_SHUTDOWN); + +struct crt_proto_rpc_format my_proto_rpc_fmt[] = { + { + .prf_flags = 0, + .prf_req_fmt = &CQF_RPC_PING, + .prf_hdlr = (void *)handler_ping, + .prf_co_ops = NULL, + }, { + .prf_flags = 0, + .prf_req_fmt = &CQF_RPC_SHUTDOWN, + .prf_hdlr = (void *)handler_shutdown, + .prf_co_ops = NULL, + } +}; + +struct crt_proto_format my_proto_fmt = { + .cpf_name = "my-proto", + .cpf_ver = MY_VER, + .cpf_count = ARRAY_SIZE(my_proto_rpc_fmt), + .cpf_prf = &my_proto_rpc_fmt[0], + .cpf_base = MY_BASE, +}; + +static int +bulk_transfer_done_cb(const struct crt_bulk_cb_info *info) +{ + void *buff; + int rc; + + DBG_PRINT("Bulk transfer failed with rc=%d\n", info->bci_rc); + if (info->bci_rc != 0) { + error_exit(); + } + + DBG_PRINT("Bulk transfer done\n"); + + rc = crt_reply_send(info->bci_bulk_desc->bd_rpc); + if (rc != 0) { + D_ERROR("Failed to send response\n"); + error_exit(); + } + + crt_bulk_free(info->bci_bulk_desc->bd_local_hdl); + + buff = info->bci_arg; + D_FREE(buff); + + RPC_PUB_DECREF(info->bci_bulk_desc->bd_rpc); + + return 0; +} + +static int +handler_ping(crt_rpc_t *rpc) +{ + struct RPC_PING_in *input; + struct RPC_PING_out *output; + crt_context_t *ctx; + int rc = 0; + bool primary_origin = false; + int my_tag; + uint32_t hdr_dst_tag; + + input = crt_req_get(rpc); + output = crt_reply_get(rpc); + + output->rc = 0; + DBG_PRINT("Sizes: %d %d\n", input->size1, input->size2); + + ctx = rpc->cr_ctx; + + rc = crt_req_src_provider_is_primary(rpc, &primary_origin); + + if (rc != 0) { + D_ERROR("crt_req_src_provider_is_primary() failed. rc=%d\n", rc); + error_exit(); + } + + rc = crt_req_dst_tag_get(rpc, &hdr_dst_tag); + if (rc != 0) { + D_ERROR("crt_req_dst_tag_get() failed; rc=%d\n", rc); + error_exit(); + } + + rc = crt_context_idx(rpc->cr_ctx, &my_tag); + if (rc != 0) { + D_ERROR("crt_context_idx() failed; rc=%d\n", rc); + error_exit(); + } + + DBG_PRINT("RPC arrived on a %s context (idx=%d intended_tag=%d); origin was %s\n", + crt_context_is_primary(ctx) ? "primary" : "secondary", + my_tag, hdr_dst_tag, + primary_origin ? "primary" : "secondary"); + + /* TODO: Change this to rank == 2 when bulk support is added */ + if (g_my_rank == 100002) { + struct crt_bulk_desc bulk_desc; + crt_bulk_t dst_bulk; + char *dst; + d_sg_list_t sgl; + + DBG_PRINT("Initiating transfer\n"); + + D_ALLOC_ARRAY(dst, input->size2); + + rc = d_sgl_init(&sgl, 1); + if (rc != 0) + error_exit(); + + sgl.sg_iovs[0].iov_buf = dst; + sgl.sg_iovs[0].iov_buf_len = input->size2; + sgl.sg_iovs[0].iov_len = input->size2; + + rc = crt_bulk_create(rpc->cr_ctx, &sgl, CRT_BULK_RW, &dst_bulk); + if (rc != 0) + error_exit(); + + RPC_PUB_ADDREF(rpc); + bulk_desc.bd_rpc = rpc; + bulk_desc.bd_bulk_op = CRT_BULK_GET; + bulk_desc.bd_remote_hdl = input->bulk_hdl2; + bulk_desc.bd_remote_off = 0; + bulk_desc.bd_local_hdl = dst_bulk; + bulk_desc.bd_local_off = 0; + bulk_desc.bd_len = input->size2; + rc = crt_bulk_bind_transfer(&bulk_desc, bulk_transfer_done_cb, + dst, NULL); + if (rc != 0) { + D_ERROR("transfer failed; rc=%d\n", rc); + error_exit(); + } + } + + rc = crt_reply_send(rpc); + if (rc) + D_ERROR("Failed with rc=%d\n", rc); + + return 0; +} + + +static int +handler_shutdown(crt_rpc_t *rpc) +{ + crt_reply_send(rpc); + + do_shutdown = 1; + return 0; +} + +#endif /* __DUAL_PROVIDER_COMMON_H__ */ diff --git a/src/tests/ftest/cart/dual_provider_server.c b/src/tests/ftest/cart/dual_provider_server.c new file mode 100644 index 00000000000..c938e975481 --- /dev/null +++ b/src/tests/ftest/cart/dual_provider_server.c @@ -0,0 +1,403 @@ +/* + * (C) Copyright 2018-2022 Intel Corporation. + * + * SPDX-License-Identifier: BSD-2-Clause-Patent + */ +/** + * Dual-provider server + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "crt_utils.h" + +#include "dual_provider_common.h" + + + +static void +print_usage(const char *msg) +{ + printf("Error: %s\n", msg); + printf("Usage: ./dual_provider_server -i 'iface0,iface1' "); + printf("-d 'domain0,domain1' -p 'provider0,provider1' [-c 'num1,num2] "); + printf("[-f 'file_to_transfer']\n"); + printf("\nLaunches server in dual provider mode based on provided args"); + printf("NOTE: Same argument values can be specified for both "); + printf("servers, e.g. -i 'eth0,eth0'\n"); + printf("\nArguments:\n"); + printf("-i 'iface0,iface1' : Specify two network interfaces to use; "); + printf("e.g. 'eth0,eth1'\n"); + printf("-d 'domain0,domain1': Specify two domains to use; "); + printf("e.g. 'eth0,eth1'\n"); + printf("-p 'provider0,provider1\n' : Specify providers to use; "); + printf("e.g. 'ofi+tcp,ofi+verbs'\n"); + printf("-c 'num1,num2' : Specify number of contexts to allocate on each\n"); + printf("NOTE: first provider will be considered a primary one\n"); + printf("-f [filename] : If set will transfer contents "); + printf("of the specified file via bulk/rdma as part of 'PING' rpc\n"); +} + +void * +progress_fn(void *data) +{ + crt_context_t *p_ctx = (crt_context_t *)data; + int rc; + + while (do_shutdown == 0) + crt_progress(*p_ctx, 1000); + + sleep(1); + rc = crt_context_destroy(*p_ctx, 1); + if (rc != 0) + D_ERROR("ctx destroy failed\n"); + pthread_exit(NULL); +} + +static void +__split_arg(char *arg_to_split, char **first_arg, char **second_arg) +{ + char *save_ptr; + + if (!arg_to_split) + return; + + if (first_arg == NULL || second_arg == NULL) { + print_usage("Fatal error, arguments NULL\n"); + exit(-1); + } + + *first_arg = strtok_r(arg_to_split, ",", &save_ptr); + if (*first_arg == NULL) { + print_usage("Failed to parse first arg"); + exit(-1); + } + + *second_arg = save_ptr; + if (*second_arg == NULL) { + print_usage("Failed to parse second arg"); + exit(-1); + } +} + + +int main(int argc, char **argv) +{ + int num_primary_ctx; + int num_secondary_ctx; + crt_context_t primary_ctx[NUM_PRIMARY_CTX_MAX]; + pthread_t primary_progress_thread[NUM_PRIMARY_CTX_MAX]; + + crt_context_t secondary_ctx[NUM_SECONDARY_CTX_MAX]; + pthread_t secondary_progress_thread[NUM_SECONDARY_CTX_MAX]; + + int rc; + int i; + char c; + char *arg_interface = NULL; + char *arg_domain = NULL; + char *arg_provider = NULL; + char *arg_mmap_file = NULL; + char *arg_num_ctx = NULL; + char default_iface0[] = "ib0"; + char default_iface1[] = "ib1"; + char default_domain0[] = "mlx5_0"; + char default_domain1[] = "mlx5_1"; + char default_provider0[] = "ofi+verbs;ofi_rxm\0"; + char default_provider1[] = "ofi+tcp;ofi+rxm\0"; + + char *iface0, *iface1; + char *domain0, *domain1; + char *provider0, *provider1; + char *num_ctx0, *num_ctx1; + char *env_self_rank; + char *env_group_cfg; + char *my_uri; + uint32_t grp_size; + crt_group_t *grp; + char *uri; + char *saved_provider; + char *saved_iface; + char *saved_domain; + + + /* Get self rank and a group config file from envs set by crt_launch */ + env_self_rank = getenv("CRT_L_RANK"); + env_group_cfg = getenv("CRT_L_GRP_CFG"); + + if (env_self_rank == NULL || env_group_cfg == NULL) { + printf("Error: This application is intended to be launched via crt_launch\n"); + return 0; + } + + g_my_rank = atoi(env_self_rank); + crtu_test_init(g_my_rank, 20, true, true); + + iface0 = default_iface0; + iface1 = default_iface1; + domain0 = default_domain0; + domain1 = default_domain1; + provider0 = default_provider0; + provider1 = default_provider1; + + num_primary_ctx = NUM_PRIMARY_CTX_MAX; + num_secondary_ctx = NUM_SECONDARY_CTX_MAX; + + while ((c = getopt(argc, argv, "i:p:d:f:c:")) != -1) { + switch (c) { + case 'i': + arg_interface = optarg; + break; + case 'd': + arg_domain = optarg; + break; + case 'p': + arg_provider = optarg; + break; + case 'f': + arg_mmap_file = optarg; + break; + case 'c': + arg_num_ctx = optarg; + break; + default: + print_usage("invalid argument\n"); + return -1; + } + } + + saved_provider = strdup(arg_provider); + saved_domain = strdup(arg_domain); + saved_iface = strdup(arg_interface); + + __split_arg(arg_interface, &iface0, &iface1); + __split_arg(arg_domain, &domain0, &domain1); + __split_arg(arg_provider, &provider0, &provider1); + + if (arg_num_ctx) { + __split_arg(arg_num_ctx, &num_ctx0, &num_ctx1); + num_primary_ctx = atoi(num_ctx0); + num_secondary_ctx = atoi(num_ctx1); + } + + if (num_primary_ctx > NUM_PRIMARY_CTX_MAX) { + printf("Error: Exceeded max allowed %d for primary ctx\n", + NUM_PRIMARY_CTX_MAX); + return -1; + } + + if (num_secondary_ctx > NUM_SECONDARY_CTX_MAX) { + printf("Error: Exceeded max allowed %d for secondary ctx\n", + NUM_SECONDARY_CTX_MAX); + return -1; + } + + printf("----------------------------------------\n"); + printf("My_rank: %d\n", g_my_rank); + printf("Provider0: '%s' Interface0: '%s' Domain0: '%s' #ctx: %d\n", + provider0, iface0, domain0, num_primary_ctx); + printf("Provider1: '%s' Interface1: '%s' Domain1: '%s' #ctx: %d\n", + provider1, iface1, domain1, num_secondary_ctx); + printf("File to transfer: '%s'\n", + arg_mmap_file ? arg_mmap_file : "none"); + printf("----------------------------------------\n\n"); + + /* Done with parsing, now start the server up */ + rc = d_log_init(); + if (rc != 0) { + D_ERROR("d_log_init() failed; rc=%d\n", rc); + error_exit(); + } + + crt_init_options_t init_opts = {0}; + + init_opts.cio_provider = saved_provider; + init_opts.cio_interface = saved_iface; + init_opts.cio_domain = saved_domain; + + rc = crt_init_opt(SERVER_GROUP_NAME, + CRT_FLAG_BIT_SERVER | CRT_FLAG_BIT_AUTO_SWIM_DISABLE, + &init_opts); + if (rc != 0) { + D_ERROR("crt_init() failed; rc=%d\n", rc); + error_exit(); + } + + for (i = 0; i < num_primary_ctx; i++) { + rc = crt_context_create(&primary_ctx[i]); + if (rc != 0) { + D_ERROR("Context %d creation failed; rc=%d\n", i, rc); + error_exit(); + } + + rc = crt_context_uri_get(primary_ctx[i], &uri); + if (rc != 0) { + D_ERROR("crt_context_uri_get(%d) failed; rc=%d\n", i, rc); + error_exit(); + } + printf("Primary context[%d] uri=%s\n", i, uri); + + rc = pthread_create(&primary_progress_thread[i], 0, progress_fn, &primary_ctx[i]); + if (rc != 0) + error_exit(); + } + + for (i = 0; i < num_secondary_ctx; i++) { + rc = crt_context_create_secondary(&secondary_ctx[i], 0); + if (rc != 0) { + D_ERROR("Context %d creation failed; rc=%d\n", i, rc); + error_exit(); + } + + rc = crt_context_uri_get(secondary_ctx[i], &uri); + if (rc != 0) { + D_ERROR("crt_context_uri_get(%d) failed; rc=%d\n", i, rc); + error_exit(); + } + + printf("Secondary context[%d] uri=%s\n", i, uri); + D_FREE(uri); + + rc = pthread_create(&secondary_progress_thread[i], 0, + progress_fn, &secondary_ctx[i]); + if (rc != 0) { + error_exit(); + } + } + + rc = crt_self_uri_get_secondary(0, &uri); + if (rc != 0) + error_exit(); + + printf("Secondary uri for context0 = %s\n", uri); + + D_FREE(uri); + + rc = crt_proto_register(&my_proto_fmt); + if (rc != 0) { + D_ERROR("crt_proto_register() failed; rc=%d\n", rc); + error_exit(); + } + + grp = crt_group_lookup(NULL); + if (!grp) + error_exit(); + + rc = crt_rank_self_set(g_my_rank, 1 /* group_version_min */); + if (rc != 0) + error_exit(); + + { + FILE *f; + int parsed_rank; + char parsed_addr[256]; + + f = fopen(env_group_cfg, "r"); + if (!f) { + D_ERROR("Failed to open %s\n", env_group_cfg); + error_exit(); + } + + while (1) { + rc = fscanf(f, "%8d %254s", &parsed_rank, parsed_addr); + if (rc == EOF) { + rc = 0; + break; + } + + if (parsed_rank == g_my_rank) + continue; + + + DBG_PRINT("Rank=%d uri='%s'\n", parsed_rank, parsed_addr); + rc = crt_group_primary_rank_add(primary_ctx[0], grp, + parsed_rank, parsed_addr); + + if (rc != 0) { + D_ERROR("Failed to add %d %s; rc=%d\n", + parsed_rank, parsed_addr, rc); + break; + } + } + } + + rc = crt_rank_uri_get(grp, g_my_rank, 0, &my_uri); + if (rc) + error_exit(); + + + rc = crt_group_size(NULL, &grp_size); + if (rc) + error_exit(); + + DBG_PRINT("self_rank=%d uri=%s file=%s group_size=%d\n", + g_my_rank, my_uri, env_group_cfg, grp_size); + + D_FREE(my_uri); + + + if (g_my_rank == 0) { + DBG_PRINT("Saving group config info\n"); + rc = crt_group_config_save(NULL, true); + if (rc) + error_exit(); + } + + { + FILE *f; + char *filename; + char *pri_uri0; + char *sec_uri0; + + D_ASPRINTF(filename, "/tmp/%s_rank_%d_uris.cart", SERVER_GROUP_NAME, g_my_rank); + if (filename == NULL) + error_exit(); + + f = fopen(filename, "w"); + if (f == NULL) + error_exit(); + + + rc = crt_context_uri_get(primary_ctx[0], &pri_uri0); + if (rc) + error_exit(); + + rc = crt_context_uri_get(secondary_ctx[0], &sec_uri0); + if (rc) + error_exit(); + + fprintf(f, "%s\n", pri_uri0); + fprintf(f, "%s\n", sec_uri0); + + fclose(f); + D_FREE(filename); + } + + for (i = 0; i < num_primary_ctx; i++) + pthread_join(primary_progress_thread[i], NULL); + + for (i = 0; i < num_secondary_ctx; i++) + pthread_join(secondary_progress_thread[i], NULL); + + + rc = crt_finalize(); + if (rc != 0) + error_exit(); + + d_log_fini(); + + free(saved_provider); + free(saved_domain); + free(saved_iface); + return 0; +} + diff --git a/src/tests/ftest/cart/no_pmix_launcher_server.c b/src/tests/ftest/cart/no_pmix_launcher_server.c index e19ce0810cc..83bdf1def56 100644 --- a/src/tests/ftest/cart/no_pmix_launcher_server.c +++ b/src/tests/ftest/cart/no_pmix_launcher_server.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2018-2021 Intel Corporation. + * (C) Copyright 2018-2022 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ diff --git a/utils/config/daos_agent.yml b/utils/config/daos_agent.yml index 0bae768c53f..527306f69f9 100644 --- a/utils/config/daos_agent.yml +++ b/utils/config/daos_agent.yml @@ -159,10 +159,10 @@ # #include_fabric_ifaces: ["eth0"] -# Manually define the fabric interfaces and domains to be used by the agent, -# organized by NUMA node. -# If not defined, the agent will automatically detect all fabric interfaces and -# select appropriate ones based on the server preferences. +## Manually define the fabric interfaces and domains to be used by the agent, +## organized by NUMA node. +## If not defined, the agent will automatically detect all fabric interfaces and +## select appropriate ones based on the server preferences. # #fabric_ifaces: #- @@ -183,3 +183,15 @@ # - # iface: ib3 # domain: mlx5_3 + +## Select the fabric provider to be used by all clients, if the server is configured with +## multiple providers. +## The provider index is 0-based and based on the order of fabric providers listed in the +## "provider" field of the corresponding daos_server configuration. An administrator can +## see the list of configured server providers and their indices by using the "dmg system +## query" command. +## Index 0 corresponds to the primary provider. Any index > 0 is a secondary provider. +# +## default: 0 +# +#provider_idx: 1 diff --git a/utils/config/daos_server.yml b/utils/config/daos_server.yml index b712a600f56..e9ac0c068bb 100644 --- a/utils/config/daos_server.yml +++ b/utils/config/daos_server.yml @@ -268,6 +268,17 @@ #system_ram_reserved: 5 # # +## Number of network endpoints per secondary provider +# +## Specifies the number of secondary network endpoints each engine will create +## for each additional fabric provider after the first. This only applies when +## running in multi-provider mode. +# +## default: 1 +# +#secondary_provider_endpoints: [2] +# +# ## Set specific debug mask for daos_server (control plane). ## The mask specifies minimum level of message significance to pass to logger. ## Currently supported values are DISABLED, TRACE, DEBUG, INFO, NOTICE and ERROR.