From 4be34bef1609880d24de8a5c13fe98f943ca4bb4 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Mon, 10 Jun 2024 16:58:33 +0900 Subject: [PATCH] DAOS-14679 pool: Debug ds_pool refs Use d_ref_tracker on ds_pool. Signed-off-by: Li Wei Required-githooks: true --- src/container/container_iv.c | 8 +++---- src/container/srv_container.c | 4 ++-- src/container/srv_target.c | 12 +++++----- src/dtx/dtx_resync.c | 4 ++-- src/include/daos_srv/pool.h | 43 +++++++++++++++++++++++++++++++++++ src/object/srv_obj_migrate.c | 8 +++---- src/pool/srv_internal.h | 9 ++++++++ src/pool/srv_iv.c | 22 +++++++++--------- src/pool/srv_pool.c | 10 ++++---- src/pool/srv_target.c | 41 +++++++++++++++++---------------- src/pool/srv_util.c | 8 +++---- src/rebuild/srv.c | 20 ++++++++-------- 12 files changed, 122 insertions(+), 67 deletions(-) diff --git a/src/container/container_iv.c b/src/container/container_iv.c index 58703176ed5..032a9a065c2 100644 --- a/src/container/container_iv.c +++ b/src/container/container_iv.c @@ -967,7 +967,7 @@ cont_iv_capa_refresh_ult(void *data) D_ASSERT(dss_get_module_info()->dmi_xs_id == 0); - rc = ds_pool_lookup(arg->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(arg->pool_uuid, &pool); if (rc) D_GOTO(out, rc); @@ -989,7 +989,7 @@ cont_iv_capa_refresh_ult(void *data) uuid_copy(arg->cont_uuid, iv_entry.cont_uuid); out: if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); ABT_eventual_set(arg->eventual, (void *)&rc, sizeof(rc)); } @@ -1471,7 +1471,7 @@ cont_iv_prop_fetch_ult(void *data) D_ASSERT(dss_get_module_info()->dmi_xs_id == 0); - rc = ds_pool_lookup(arg->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(arg->pool_uuid, &pool); if (rc) D_GOTO(out, rc); @@ -1503,7 +1503,7 @@ cont_iv_prop_fetch_ult(void *data) out: if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); D_FREE(iv_entry); if (prop_fetch != NULL) daos_prop_free(prop_fetch); diff --git a/src/container/srv_container.c b/src/container/srv_container.c index 372da43afe4..eafb733da84 100644 --- a/src/container/srv_container.c +++ b/src/container/srv_container.c @@ -194,7 +194,7 @@ ds_cont_svc_step_up(struct cont_svc *svc) int rc; D_ASSERT(svc->cs_pool == NULL); - rc = ds_pool_lookup(svc->cs_pool_uuid, &svc->cs_pool); + rc = DS_POOL_LOOKUP(svc->cs_pool_uuid, &svc->cs_pool); if (rc != 0) { D_ERROR(DF_UUID": pool lookup failed: "DF_RC"\n", DP_UUID(svc->cs_pool_uuid), DP_RC(rc)); @@ -215,7 +215,7 @@ ds_cont_svc_step_down(struct cont_svc *svc) { cont_svc_ec_agg_leader_stop(svc); D_ASSERT(svc->cs_pool != NULL); - ds_pool_put(svc->cs_pool); + DS_POOL_PUT(&svc->cs_pool); svc->cs_pool = NULL; } diff --git a/src/container/srv_target.c b/src/container/srv_target.c index 1ee4d556e91..af8fa0704f6 100644 --- a/src/container/srv_target.c +++ b/src/container/srv_target.c @@ -1310,7 +1310,7 @@ ds_cont_tgt_destroy(uuid_t pool_uuid, uuid_t cont_uuid) struct cont_tgt_destroy_in in; int rc; - rc = ds_pool_lookup(pool_uuid, &pool); + rc = DS_POOL_LOOKUP(pool_uuid, &pool); if (rc != 0) { D_DEBUG(DB_MD, DF_UUID" lookup pool failed: %d\n", DP_UUID(pool_uuid), rc); @@ -1321,7 +1321,7 @@ ds_cont_tgt_destroy(uuid_t pool_uuid, uuid_t cont_uuid) uuid_copy(in.tdi_uuid, cont_uuid); cont_iv_entry_delete(pool->sp_iv_ns, pool_uuid, cont_uuid); - ds_pool_put(pool); + DS_POOL_PUT(&pool); rc = ds_pool_thread_collective(pool_uuid, PO_COMP_ST_NEW | PO_COMP_ST_DOWN | PO_COMP_ST_DOWNOUT, cont_child_destroy_one, &in, 0); @@ -1721,7 +1721,7 @@ ds_cont_tgt_open(uuid_t pool_uuid, uuid_t cont_hdl_uuid, int rc; /* Only for debugging purpose to compare srv_cont_hdl with cont_hdl_uuid */ - rc = ds_pool_lookup(pool_uuid, &pool); + rc = DS_POOL_LOOKUP(pool_uuid, &pool); if (rc != 0) { D_DEBUG(DB_MD, DF_UUID" lookup pool failed: "DF_RC"\n", DP_UUID(pool_uuid), DP_RC(rc)); @@ -1732,7 +1732,7 @@ ds_cont_tgt_open(uuid_t pool_uuid, uuid_t cont_hdl_uuid, if (uuid_compare(pool->sp_srv_cont_hdl, cont_hdl_uuid) == 0 && sec_capas == 0) D_WARN("srv hdl "DF_UUID" capas is "DF_X64"\n", DP_UUID(cont_hdl_uuid), sec_capas); - ds_pool_put(pool); + DS_POOL_PUT(&pool); uuid_copy(arg.pool_uuid, pool_uuid); uuid_copy(arg.cont_hdl_uuid, cont_hdl_uuid); @@ -2064,7 +2064,7 @@ cont_snapshots_refresh_ult(void *data) struct ds_pool *pool; int rc; - rc = ds_pool_lookup(args->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(args->pool_uuid, &pool); if (rc != 0) { D_DEBUG(DB_MD, DF_UUID" lookup pool failed: "DF_RC"\n", DP_UUID(args->pool_uuid), DP_RC(rc)); @@ -2072,7 +2072,7 @@ cont_snapshots_refresh_ult(void *data) goto out; } rc = cont_iv_snapshots_refresh(pool->sp_iv_ns, args->cont_uuid); - ds_pool_put(pool); + DS_POOL_PUT(&pool); out: if (rc != 0) D_DEBUG(DB_TRACE, DF_UUID": failed to refresh snapshots IV: " diff --git a/src/dtx/dtx_resync.c b/src/dtx/dtx_resync.c index c7898e51d48..829817b67ee 100644 --- a/src/dtx/dtx_resync.c +++ b/src/dtx/dtx_resync.c @@ -789,7 +789,7 @@ dtx_resync_ult(void *data) struct ds_pool *pool = NULL; int rc; - rc = ds_pool_lookup(arg->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(arg->pool_uuid, &pool); if (rc != 0) { D_WARN("Cannot find the pool "DF_UUID" for DTX resync: "DF_RC"\n", DP_UUID(arg->pool_uuid), DP_RC(rc)); @@ -824,6 +824,6 @@ dtx_resync_ult(void *data) out: if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); D_FREE(arg); } diff --git a/src/include/daos_srv/pool.h b/src/include/daos_srv/pool.h index 853a6fb6a77..6cecd8c5abb 100644 --- a/src/include/daos_srv/pool.h +++ b/src/include/daos_srv/pool.h @@ -45,6 +45,7 @@ struct ds_pool_svc; */ struct ds_pool { struct daos_llink sp_entry; + struct d_ref_tracker sp_ref_tracker; uuid_t sp_uuid; /* pool UUID */ d_list_t sp_hdls; ABT_rwlock sp_lock; @@ -116,6 +117,48 @@ struct ds_pool { uint32_t sp_reint_mode; }; +/** + * Look up the ds_pool object with \a uuid and assign a reference to *\a pool. + * Upon errors, *\a pool is set to NULL. + * + * \param[in] uuid pool UUID (uuid_t) + * \param[out] pool pool (struct ds_pool **) + * + * \return error code + */ +#define DS_POOL_LOOKUP(uuid, pool) \ + ({ \ + int ds_pool_lookup_rc = ds_pool_lookup(uuid, pool); \ + if (ds_pool_lookup_rc == 0) \ + D_REF_TRACKER_TRACK(&(*pool)->sp_ref_tracker, pool); \ + ds_pool_lookup_rc; \ + }) + +/** + * Put the ds_pool reference and assign NULL to *\a pool. + * + * \param[in] pool pool (struct ds_pool **) + */ +#define DS_POOL_PUT(pool) \ + do { \ + D_REF_TRACKER_UNTRACK(&(*pool)->sp_ref_tracker, pool); \ + ds_pool_put(*pool); \ + *pool = NULL; \ + } while (0) + +/** + * Get a new ds_pool reference from \a from and store it in *\a to. + * + * \param[out] to pool (struct ds_pool **) + * \param[in] from pool (struct ds_pool *) + */ +#define DS_POOL_GET(to, from) \ + do { \ + ds_pool_get(from); \ + *to = from; \ + D_REF_TRACKER_TRACK(&(from)->sp_ref_tracker, to); \ + } while (0) + int ds_pool_lookup(const uuid_t uuid, struct ds_pool **pool); void ds_pool_put(struct ds_pool *pool); void ds_pool_get(struct ds_pool *pool); diff --git a/src/object/srv_obj_migrate.c b/src/object/srv_obj_migrate.c index b1544a221d8..6a16bd0350c 100644 --- a/src/object/srv_obj_migrate.c +++ b/src/object/srv_obj_migrate.c @@ -3490,7 +3490,7 @@ migrate_cont_iter_cb(daos_handle_t ih, d_iov_t *key_iov, D_DEBUG(DB_REBUILD, "iter cont "DF_UUID"/%"PRIx64" %"PRIx64" start\n", DP_UUID(cont_uuid), ih.cookie, root->root_hdl.cookie); - rc = ds_pool_lookup(tls->mpt_pool_uuid, &dp); + rc = DS_POOL_LOOKUP(tls->mpt_pool_uuid, &dp); if (rc) { D_ERROR(DF_UUID" ds_pool_lookup failed: "DF_RC"\n", DP_UUID(tls->mpt_pool_uuid), DP_RC(rc)); @@ -3574,7 +3574,7 @@ migrate_cont_iter_cb(daos_handle_t ih, d_iov_t *key_iov, if (tls->mpt_status == 0 && rc < 0) tls->mpt_status = rc; if (dp != NULL) - ds_pool_put(dp); + DS_POOL_PUT(&dp); return rc; } @@ -3806,7 +3806,7 @@ ds_obj_migrate_handler(crt_rpc_t *rpc) uuid_copy(po_uuid, migrate_in->om_pool_uuid); uuid_copy(po_hdl_uuid, migrate_in->om_poh_uuid); - rc = ds_pool_lookup(po_uuid, &pool); + rc = DS_POOL_LOOKUP(po_uuid, &pool); if (rc != 0) { if (rc == -DER_SHUTDOWN) { D_DEBUG(DB_REBUILD, DF_UUID" pool service is stopping.\n", @@ -3834,7 +3834,7 @@ ds_obj_migrate_handler(crt_rpc_t *rpc) migrate_in->om_tgt_idx, migrate_in->om_new_layout_ver); out: if (pool) - ds_pool_put(pool); + DS_POOL_PUT(&pool); migrate_out = crt_reply_get(rpc); migrate_out->om_status = rc; diff --git a/src/pool/srv_internal.h b/src/pool/srv_internal.h index 8f864c8c11a..5532a679b9f 100644 --- a/src/pool/srv_internal.h +++ b/src/pool/srv_internal.h @@ -217,6 +217,15 @@ void ds_pool_upgrade_handler(crt_rpc_t *rpc); int ds_pool_cache_init(void); void ds_pool_cache_fini(void); int ds_pool_lookup_internal(const uuid_t uuid, struct ds_pool **pool); +#define DS_POOL_LOOKUP_INTERNAL(uuid, pool) \ + ({ \ + int ds_pool_lookup_internal_rc; \ + \ + ds_pool_lookup_internal_rc = ds_pool_lookup_internal(uuid, pool); \ + if (ds_pool_lookup_internal_rc == 0) \ + D_REF_TRACKER_TRACK(&(*pool)->sp_ref_tracker, pool); \ + ds_pool_lookup_internal_rc; \ + }) int ds_pool_hdl_hash_init(void); void ds_pool_hdl_hash_fini(void); void ds_pool_tgt_disconnect_handler(crt_rpc_t *rpc); diff --git a/src/pool/srv_iv.c b/src/pool/srv_iv.c index 7e72d30f66e..05b1dae3b34 100644 --- a/src/pool/srv_iv.c +++ b/src/pool/srv_iv.c @@ -846,7 +846,7 @@ pool_iv_ent_update(struct ds_iv_entry *entry, struct ds_iv_key *key, d_rank_t rank; int rc; - rc = ds_pool_lookup(entry->ns->iv_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(entry->ns->iv_pool_uuid, &pool); if (rc) { D_WARN("No pool "DF_UUID": %d\n", DP_UUID(entry->ns->iv_pool_uuid), rc); if (rc == -DER_NONEXIST) @@ -936,7 +936,7 @@ pool_iv_ent_update(struct ds_iv_entry *entry, struct ds_iv_key *key, D_DEBUG(DB_MD, DF_UUID": key %u rc %d\n", DP_UUID(entry->ns->iv_pool_uuid), key->class_id, rc); if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); return rc; } @@ -950,7 +950,7 @@ pool_iv_ent_invalid(struct ds_iv_entry *entry, struct ds_iv_key *key) if (entry->iv_class->iv_class_id == IV_POOL_HDL) { if (!uuid_is_null(iv_entry->piv_hdl.pih_cont_hdl)) { entry->iv_valid = false; - rc = ds_pool_lookup(entry->ns->iv_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(entry->ns->iv_pool_uuid, &pool); if (rc) { if (rc == -DER_NONEXIST) rc = 0; @@ -961,7 +961,7 @@ pool_iv_ent_invalid(struct ds_iv_entry *entry, struct ds_iv_key *key) uuid_clear(pool->sp_srv_cont_hdl); uuid_clear(pool->sp_srv_pool_hdl); uuid_clear(iv_entry->piv_hdl.pih_cont_hdl); - ds_pool_put(pool); + DS_POOL_PUT(&pool); return 0; } } else if (entry->iv_class->iv_class_id == IV_POOL_CONN) { @@ -986,9 +986,9 @@ pool_iv_ent_refresh(struct ds_iv_entry *entry, struct ds_iv_key *key, int rc; if (src == NULL) - rc = ds_pool_lookup_internal(entry->ns->iv_pool_uuid, &pool); + rc = DS_POOL_LOOKUP_INTERNAL(entry->ns->iv_pool_uuid, &pool); else - rc = ds_pool_lookup(entry->ns->iv_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(entry->ns->iv_pool_uuid, &pool); if (rc) { D_WARN("No pool "DF_UUID": %d\n", DP_UUID(entry->ns->iv_pool_uuid), rc); if (rc == -DER_NONEXIST) @@ -1078,7 +1078,7 @@ pool_iv_ent_refresh(struct ds_iv_entry *entry, struct ds_iv_key *key, D_DEBUG(DB_MD, DF_UUID": key %u rc %d\n", DP_UUID(entry->ns->iv_pool_uuid), key->class_id, rc); if (pool) - ds_pool_put(pool); + DS_POOL_PUT(&pool); return rc; } @@ -1104,7 +1104,7 @@ pool_iv_pre_sync(struct ds_iv_entry *entry, struct ds_iv_key *key, if (entry->iv_class->iv_class_id != IV_POOL_MAP) return 0; - rc = ds_pool_lookup(entry->ns->iv_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(entry->ns->iv_pool_uuid, &pool); if (rc != 0) { D_DEBUG(DB_TRACE, DF_UUID": pool not found: %d\n", DP_UUID(entry->ns->iv_pool_uuid), rc); @@ -1128,7 +1128,7 @@ pool_iv_pre_sync(struct ds_iv_entry *entry, struct ds_iv_key *key, ABT_cond_signal(pool->sp_fetch_hdls_cond); ABT_mutex_unlock(pool->sp_mutex); - ds_pool_put(pool); + DS_POOL_PUT(&pool); return rc; } @@ -1387,7 +1387,7 @@ ds_pool_map_refresh_ult(void *arg) /* Pool IV fetch should only be done in xstream 0 */ D_ASSERT(dss_get_module_info()->dmi_xs_id == 0); - rc = ds_pool_lookup(iv_arg->iua_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(iv_arg->iua_pool_uuid, &pool); if (rc != 0) { D_WARN(DF_UUID" refresh pool map: %d\n", DP_UUID(iv_arg->iua_pool_uuid), rc); goto out; @@ -1430,7 +1430,7 @@ ds_pool_map_refresh_ult(void *arg) ABT_mutex_unlock(pool->sp_mutex); out: if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); if (iv_arg->iua_eventual) ABT_eventual_set(iv_arg->iua_eventual, (void *)&rc, sizeof(rc)); D_FREE(iv_arg); diff --git a/src/pool/srv_pool.c b/src/pool/srv_pool.c index 667e4bc6ed6..43239a62c71 100644 --- a/src/pool/srv_pool.c +++ b/src/pool/srv_pool.c @@ -1187,7 +1187,7 @@ pool_svc_alloc_cb(d_iov_t *id, struct ds_rsvc **rsvc) svc->ps_svc_rf = -1; svc->ps_force_notify = false; - rc = ds_pool_lookup(svc->ps_uuid, &svc->ps_pool); + rc = DS_POOL_LOOKUP(svc->ps_uuid, &svc->ps_pool); if (rc != 0) { DL_INFO(rc, DF_UUID ": look up pool", DP_UUID(svc->ps_uuid)); goto err_svc; @@ -1274,7 +1274,7 @@ pool_svc_alloc_cb(d_iov_t *id, struct ds_rsvc **rsvc) err_lock: ABT_rwlock_free(&svc->ps_lock); err_pool: - ds_pool_put(svc->ps_pool); + DS_POOL_PUT(&svc->ps_pool); err_svc: D_FREE(svc); err: @@ -1541,7 +1541,7 @@ pool_svc_free_cb(struct ds_rsvc *rsvc) rdb_path_fini(&svc->ps_handles); rdb_path_fini(&svc->ps_root); ABT_rwlock_free(&svc->ps_lock); - ds_pool_put(svc->ps_pool); + DS_POOL_PUT(&svc->ps_pool); D_FREE(svc); } @@ -8179,7 +8179,7 @@ is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid) struct ds_pool *pool; int rc; - rc = ds_pool_lookup(pool_uuid, &pool); + 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); @@ -8187,7 +8187,7 @@ is_pool_from_srv(uuid_t pool_uuid, uuid_t poh_uuid) } rc = ds_pool_hdl_is_from_srv(pool, poh_uuid); - ds_pool_put(pool); + DS_POOL_PUT(&pool); if (rc < 0) { D_ERROR(DF_UUID" fetch srv hdl: %d\n", DP_UUID(pool_uuid), rc); return false; diff --git a/src/pool/srv_target.c b/src/pool/srv_target.c index c5b547559d8..a1426a1b4bb 100644 --- a/src/pool/srv_target.c +++ b/src/pool/srv_target.c @@ -833,6 +833,7 @@ pool_alloc_ref(void *key, unsigned int ksize, void *varg, if (rc != ABT_SUCCESS) D_GOTO(err_cond, rc = dss_abterr2der(rc)); + d_ref_tracker_init(&pool->sp_ref_tracker); D_INIT_LIST_HEAD(&pool->sp_ec_ephs_list); uuid_copy(pool->sp_uuid, key); D_INIT_LIST_HEAD(&pool->sp_hdls); @@ -917,6 +918,7 @@ pool_free_ref(struct daos_llink *llink) /** release metrics */ ds_pool_metrics_stop(pool); + d_ref_tracker_fini(&pool->sp_ref_tracker); ABT_cond_free(&pool->sp_fetch_hdls_cond); ABT_cond_free(&pool->sp_fetch_hdls_done_cond); ABT_mutex_free(&pool->sp_mutex); @@ -1264,10 +1266,11 @@ ds_pool_stop(uuid_t uuid) { struct ds_pool *pool; int rc; + DSS_REF_TRACKER_DECLARE_DUMPER(dumper); ds_pool_failed_remove(uuid); - ds_pool_lookup_internal(uuid, &pool); + DS_POOL_LOOKUP_INTERNAL(uuid, &pool); if (pool == NULL) { D_INFO(DF_UUID ": not found\n", DP_UUID(uuid)); return 0; @@ -1275,7 +1278,7 @@ ds_pool_stop(uuid_t uuid) if (pool->sp_stopping) { rc = -DER_AGAIN; DL_INFO(rc, DF_UUID ": already stopping", DP_UUID(uuid)); - ds_pool_put(pool); + DS_POOL_PUT(&pool); return rc; } pool->sp_stopping = 1; @@ -1297,13 +1300,15 @@ ds_pool_stop(uuid_t uuid) ds_pool_put(pool); /* held by ds_pool_start */ + DSS_REF_TRACKER_INIT_DUMPER(dumper, pool->sp_ref_tracker); while (!daos_lru_is_last_user(&pool->sp_entry)) dss_sleep(1000 /* ms */); + DSS_REF_TRACKER_FINI_DUMPER(dumper); D_INFO(DF_UUID ": completed reference wait\n", DP_UUID(uuid)); pool_child_delete_all(pool); - ds_pool_put(pool); + DS_POOL_PUT(&pool); D_INFO(DF_UUID ": stopped\n", DP_UUID(uuid)); return 0; } @@ -1372,7 +1377,7 @@ pool_hdl_rec_free(struct d_hash_table *htable, d_list_t *rlink) D_ASSERT(d_list_empty(&hdl->sph_pool_entry)); D_ASSERTF(hdl->sph_ref == 0, "%d\n", hdl->sph_ref); daos_iov_free(&hdl->sph_cred); - ds_pool_put(hdl->sph_pool); + DS_POOL_PUT(&hdl->sph_pool); D_FREE(hdl); } @@ -1650,21 +1655,20 @@ ds_pool_tgt_connect(struct ds_pool *pool, struct pool_iv_conn *pic) hdl->sph_sec_capas = pic->pic_capas; hdl->sph_global_ver = pic->pic_global_ver; hdl->sph_obj_ver = pic->pic_obj_ver; - ds_pool_get(pool); - hdl->sph_pool = pool; + DS_POOL_GET(&hdl->sph_pool, pool); cred_iov.iov_len = pic->pic_cred_size; cred_iov.iov_buf_len = pic->pic_cred_size; cred_iov.iov_buf = &pic->pic_creds[0]; rc = daos_iov_copy(&hdl->sph_cred, &cred_iov); if (rc != 0) { - ds_pool_put(pool); + DS_POOL_PUT(&hdl->sph_pool); D_GOTO(out, rc); } if (pool->sp_stopping) { daos_iov_free(&hdl->sph_cred); - ds_pool_put(pool); + DS_POOL_PUT(&hdl->sph_pool); rc = -DER_SHUTDOWN; goto out; } @@ -1675,7 +1679,7 @@ ds_pool_tgt_connect(struct ds_pool *pool, struct pool_iv_conn *pic) if (rc != 0) { d_list_del_init(&hdl->sph_pool_entry); daos_iov_free(&hdl->sph_cred); - ds_pool_put(pool); + DS_POOL_PUT(&hdl->sph_pool); D_GOTO(out, rc); } @@ -1938,7 +1942,7 @@ ds_pool_tgt_query_handler(crt_rpc_t *rpc) } /* Aggregate query over all targets on the node */ - rc = ds_pool_lookup(in->tqi_op.pi_uuid, &pool); + rc = DS_POOL_LOOKUP(in->tqi_op.pi_uuid, &pool); if (rc) { D_ERROR("Failed to find pool "DF_UUID": %d\n", DP_UUID(in->tqi_op.pi_uuid), rc); @@ -1948,7 +1952,7 @@ ds_pool_tgt_query_handler(crt_rpc_t *rpc) rc = pool_tgt_query(pool, &out->tqo_space); if (rc != 0) rc = 1; /* For query aggregator */ - ds_pool_put(pool); + DS_POOL_PUT(&pool); out: out->tqo_rc = rc; crt_reply_send(rpc); @@ -2106,15 +2110,14 @@ ds_pool_tgt_query_map_handler(crt_rpc_t *rpc) rc = -DER_NO_HDL; goto out; } - ds_pool_get(hdl->sph_pool); - pool = hdl->sph_pool; + DS_POOL_GET(&pool, hdl->sph_pool); ds_pool_hdl_put(hdl); } else { /* * See the comment on validating the pool handle in * ds_pool_query_handler. */ - rc = ds_pool_lookup(in->tmi_op.pi_uuid, &pool); + rc = DS_POOL_LOOKUP(in->tmi_op.pi_uuid, &pool); if (rc) { D_ERROR(DF_UUID": failed to look up pool: %d\n", DP_UUID(in->tmi_op.pi_uuid), rc); @@ -2157,7 +2160,7 @@ ds_pool_tgt_query_map_handler(crt_rpc_t *rpc) out_version: out->tmo_op.po_map_version = version; out_pool: - ds_pool_put(pool); + DS_POOL_PUT(&pool); out: out->tmo_op.po_rc = rc; D_DEBUG(DB_TRACE, DF_UUID ": replying rpc: %p " DF_RC "\n", DP_UUID(in->tmi_op.pi_uuid), @@ -2484,7 +2487,7 @@ ds_pool_tgt_discard_ult(void *data) * still succeed, though it might leave some garbage on the reintegration * target, the future scrub tool might fix it. XXX */ - rc = ds_pool_lookup(arg->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(arg->pool_uuid, &pool); if (pool == NULL) { D_INFO(DF_UUID" can not be found: %d\n", DP_UUID(arg->pool_uuid), rc); D_GOTO(free, rc = 0); @@ -2497,7 +2500,7 @@ ds_pool_tgt_discard_ult(void *data) pool->sp_need_discard = 0; pool->sp_discard_status = rc; - ds_pool_put(pool); + DS_POOL_PUT(&pool); free: tgt_discard_arg_free(arg); } @@ -2524,7 +2527,7 @@ ds_pool_tgt_discard_handler(crt_rpc_t *rpc) */ uuid_copy(arg->pool_uuid, in->ptdi_uuid); arg->epoch = DAOS_EPOCH_MAX; - rc = ds_pool_lookup(arg->pool_uuid, &pool); + rc = DS_POOL_LOOKUP(arg->pool_uuid, &pool); if (rc) { D_INFO(DF_UUID" can not be found: %d\n", DP_UUID(arg->pool_uuid), rc); D_GOTO(out, rc = 0); @@ -2534,7 +2537,7 @@ ds_pool_tgt_discard_handler(crt_rpc_t *rpc) pool->sp_discard_status = 0; rc = dss_ult_create(ds_pool_tgt_discard_ult, arg, DSS_XS_SYS, 0, 0, NULL); - ds_pool_put(pool); + DS_POOL_PUT(&pool); out: out->ptdo_rc = rc; D_DEBUG(DB_MD, DF_UUID": replying rpc "DF_RC"\n", DP_UUID(in->ptdi_uuid), diff --git a/src/pool/srv_util.c b/src/pool/srv_util.c index bb075412166..ee2d0c4b455 100644 --- a/src/pool/srv_util.c +++ b/src/pool/srv_util.c @@ -1366,7 +1366,7 @@ int ds_pool_get_ranks(const uuid_t pool_uuid, int status, struct ds_pool *pool; int rc; - rc = ds_pool_lookup(pool_uuid, &pool); + rc = DS_POOL_LOOKUP(pool_uuid, &pool); if (rc != 0) { D_DEBUG(DB_MD, "Lookup "DF_UUID": %d\n", DP_UUID(pool_uuid), rc); return 0; @@ -1388,7 +1388,7 @@ int ds_pool_get_ranks(const uuid_t pool_uuid, int status, D_ERROR(DF_UUID": failed to create rank list: %d\n", DP_UUID(pool->sp_uuid), rc); - ds_pool_put(pool); + DS_POOL_PUT(&pool); return rc; } @@ -1402,7 +1402,7 @@ int ds_pool_get_tgt_idx_by_state(const uuid_t pool_uuid, unsigned int status, in int rc; *tgts_cnt = 0; - rc = ds_pool_lookup(pool_uuid, &pool); + rc = DS_POOL_LOOKUP(pool_uuid, &pool); if (pool == NULL || pool->sp_map == NULL) { D_DEBUG(DB_MD, "pool look "DF_UUID": %d\n", DP_UUID(pool_uuid), rc); D_GOTO(output, rc = 0); @@ -1434,7 +1434,7 @@ int ds_pool_get_tgt_idx_by_state(const uuid_t pool_uuid, unsigned int status, in output: if (pool) - ds_pool_put(pool); + DS_POOL_PUT(&pool); if (pool_tgts) D_FREE(pool_tgts); return rc; diff --git a/src/rebuild/srv.c b/src/rebuild/srv.c index 42025d59aa5..5c3bf7ac4e8 100644 --- a/src/rebuild/srv.c +++ b/src/rebuild/srv.c @@ -508,7 +508,7 @@ ds_rebuild_query(uuid_t pool_uuid, struct daos_rebuild_status *status) * rebuild/exclude process, so let's check pool_map_version * for now. */ - rc = ds_pool_lookup(pool_uuid, &pool); + rc = DS_POOL_LOOKUP(pool_uuid, &pool); if (pool == NULL || pool->sp_map_version < 2) { status->rs_state = DRS_NOT_STARTED; } else { @@ -516,7 +516,7 @@ ds_rebuild_query(uuid_t pool_uuid, struct daos_rebuild_status *status) status->rs_version = ds_pool_get_version(pool); } if (pool != NULL) - ds_pool_put(pool); + DS_POOL_PUT(&pool); rc = 0; } } else { @@ -1025,7 +1025,7 @@ rpt_destroy(struct rebuild_tgt_pool_tracker *rpt) uuid_clear(rpt->rt_pool_uuid); if (rpt->rt_pool != NULL) - ds_pool_put(rpt->rt_pool); + DS_POOL_PUT(&rpt->rt_pool); if (rpt->rt_svc_list) d_rank_list_free(rpt->rt_svc_list); @@ -1083,7 +1083,7 @@ rpt_put(struct rebuild_tgt_pool_tracker *rpt) rpt_destroy(rpt); } else { /* Possibly triggered by VOS target XS by obj_inflight_io_check() -> - * ds_rebuild_running_query(), but rpt_destroy() -> ds_pool_put() can only + * ds_rebuild_running_query(), but rpt_destroy() -> DS_POOL_PUT() can only * be called in system XS. * If dss_ult_execute failed that due to fatal system error (no memory * or ABT failure), throw an ERR log. @@ -1514,7 +1514,7 @@ rebuild_task_ult(void *arg) dss_sleep((task->dst_schedule_time - cur_ts) * 1000); } - rc = ds_pool_lookup(task->dst_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(task->dst_pool_uuid, &pool); if (pool == NULL) { D_ERROR(DF_UUID": failed to look up pool: %d\n", DP_UUID(task->dst_pool_uuid), rc); @@ -1661,7 +1661,7 @@ rebuild_task_ult(void *arg) DP_UUID(task->dst_pool_uuid)); out_pool: - ds_pool_put(pool); + DS_POOL_PUT(&pool); if (rgt) { ABT_mutex_lock(rgt->rgt_lock); ABT_cond_signal(rgt->rgt_done_cond); @@ -2474,7 +2474,7 @@ rebuild_tgt_prepare(crt_rpc_t *rpc, struct rebuild_tgt_pool_tracker **p_rpt) D_DEBUG(DB_REBUILD, DF_RB " prepare rebuild\n", DP_RB_RSI(rsi)); - rc = ds_pool_lookup(rsi->rsi_pool_uuid, &pool); + rc = DS_POOL_LOOKUP(rsi->rsi_pool_uuid, &pool); if (rc) { DL_ERROR(rc, DF_RB " cannot find pool", DP_RB_RSI(rsi)); return rc; @@ -2550,7 +2550,7 @@ rebuild_tgt_prepare(crt_rpc_t *rpc, struct rebuild_tgt_pool_tracker **p_rpt) } ABT_mutex_lock(rpt->rt_lock); - rpt->rt_pool = pool; /* pin it */ + D_REF_TRACKER_MOVE(&pool->sp_ref_tracker, &rpt->rt_pool, &pool); ABT_mutex_unlock(rpt->rt_lock); *p_rpt = rpt; @@ -2563,10 +2563,10 @@ rebuild_tgt_prepare(crt_rpc_t *rpc, struct rebuild_tgt_pool_tracker **p_rpt) } rpt_put(rpt); } - ds_pool_put(pool); } daos_prop_fini(&prop); - + if (pool != NULL) + DS_POOL_PUT(&pool); return rc; }