From 9b7547e8c577878e170dca2f1d7f5db894dc4011 Mon Sep 17 00:00:00 2001 From: Li Wei Date: Thu, 8 Feb 2024 02:57:50 +0900 Subject: [PATCH] DAOS-14730 pool: Clean up map update logging (#13709) This patch cleans up the pool map update logging on the client side and the engine side. A few notable changes: - In dc_pool_map_update, if the incoming map is of the same version as the one we already have, do not perform the update. Signed-off-by: Li Wei --- src/pool/cli.c | 31 ++++++++++++------------------- src/pool/srv_target.c | 41 ++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/pool/cli.c b/src/pool/cli.c index 4258ce9084e..d92e2e3caaa 100644 --- a/src/pool/cli.c +++ b/src/pool/cli.c @@ -471,32 +471,23 @@ int dc_pool_map_update(struct dc_pool *pool, struct pool_map *map, bool connect) { unsigned int map_version; + unsigned int map_version_before = 0; int rc; D_ASSERT(map != NULL); map_version = pool_map_get_version(map); - if (pool->dp_map == NULL) { - rc = pl_map_update(pool->dp_pool, map, connect, DEFAULT_PL_TYPE); - if (rc != 0) - D_GOTO(out, rc); - - D_DEBUG(DB_MD, DF_UUID": init pool map: %u\n", - DP_UUID(pool->dp_pool), pool_map_get_version(map)); - D_GOTO(out_update, rc = 0); - } + if (pool->dp_map != NULL) + map_version_before = pool_map_get_version(pool->dp_map); - if (map_version < pool_map_get_version(pool->dp_map)) { - D_DEBUG(DB_MD, DF_UUID": got older pool map: %u -> %u %p\n", - DP_UUID(pool->dp_pool), - pool_map_get_version(pool->dp_map), map_version, pool); + if (map_version <= map_version_before) { + D_DEBUG(DB_MD, DF_UUID ": ignored pool map update: version=%u->%u pool=%p\n", + DP_UUID(pool->dp_pool), map_version_before, map_version, pool); D_GOTO(out, rc = 0); } - D_DEBUG(DB_MD, DF_UUID": updating pool map: %u -> %u\n", - DP_UUID(pool->dp_pool), - pool->dp_map == NULL ? - 0 : pool_map_get_version(pool->dp_map), map_version); + D_DEBUG(DB_MD, DF_UUID ": updating pool map: version=%u->%u\n", DP_UUID(pool->dp_pool), + map_version_before, map_version); rc = pl_map_update(pool->dp_pool, map, connect, DEFAULT_PL_TYPE); if (rc != 0) { @@ -505,12 +496,14 @@ dc_pool_map_update(struct dc_pool *pool, struct pool_map *map, bool connect) D_GOTO(out, rc); } - pool_map_decref(pool->dp_map); -out_update: + if (pool->dp_map != NULL) + pool_map_decref(pool->dp_map); pool_map_addref(map); pool->dp_map = map; if (pool->dp_map_version_known < map_version) pool->dp_map_version_known = map_version; + D_INFO(DF_UUID ": updated pool map: version=%u->%u\n", DP_UUID(pool->dp_pool), + map_version_before, map_version); out: return rc; } diff --git a/src/pool/srv_target.c b/src/pool/srv_target.c index a0b8d98acd8..696f32c8b58 100644 --- a/src/pool/srv_target.c +++ b/src/pool/srv_target.c @@ -1642,7 +1642,7 @@ ds_pool_tgt_map_update(struct ds_pool *pool, struct pool_buf *buf, unsigned int map_version) { struct pool_map *map = NULL; - bool update_map = false; + bool map_updated = false; int rc = 0; if (buf != NULL) { @@ -1661,11 +1661,10 @@ ds_pool_tgt_map_update(struct ds_pool *pool, struct pool_buf *buf, pool_map_get_version(pool->sp_map) < map_version)) { struct pool_map *tmp = pool->sp_map; - D_DEBUG(DB_MD, DF_UUID - ": update pool_map version: %p/%d -> %p/%d\n", - DP_UUID(pool->sp_uuid), pool->sp_map, - pool->sp_map ? pool_map_get_version(pool->sp_map) : -1, - map, pool_map_get_version(map)); + D_DEBUG(DB_MD, DF_UUID ": updating pool map: version=%u->%u pointer=%p->%p\n", + DP_UUID(pool->sp_uuid), + pool->sp_map == NULL ? 0 : pool_map_get_version(pool->sp_map), + pool_map_get_version(map), pool->sp_map, map); rc = update_pool_group(pool, map); if (rc != 0) { @@ -1690,26 +1689,33 @@ ds_pool_tgt_map_update(struct ds_pool *pool, struct pool_buf *buf, D_GOTO(out, rc); } - update_map = true; - /* drop the stale map */ + /* Swap pool->sp_map and map. */ pool->sp_map = map; map = tmp; + + map_updated = true; + D_INFO(DF_UUID ": updated pool map: version=%u->%u pointer=%p->%p\n", + DP_UUID(pool->sp_uuid), map == NULL ? 0 : pool_map_get_version(map), + pool_map_get_version(pool->sp_map), map, pool->sp_map); } /* Check if the pool map on each xstream needs to update */ if (pool->sp_map_version < map_version) { - D_DEBUG(DB_MD, DF_UUID - ": changed cached map version: %u -> %u\n", - DP_UUID(pool->sp_uuid), pool->sp_map_version, - map_version); + unsigned int map_version_before = pool->sp_map_version; + + D_DEBUG(DB_MD, DF_UUID ": updating cached pool map version: %u->%u\n", + DP_UUID(pool->sp_uuid), map_version_before, map_version); pool->sp_map_version = map_version; rc = dss_task_collective(update_child_map, pool, 0); D_ASSERT(rc == 0); - update_map = true; + + map_updated = true; + D_INFO(DF_UUID ": updated cached pool map version: %u->%u\n", + DP_UUID(pool->sp_uuid), map_version_before, map_version); } - if (update_map) { + if (map_updated) { struct dtx_scan_args *arg; int ret; @@ -1729,9 +1735,10 @@ ds_pool_tgt_map_update(struct ds_pool *pool, struct pool_buf *buf, D_FREE(arg); } } else { - D_WARN("Ignore update pool "DF_UUID" %d -> %d\n", - DP_UUID(pool->sp_uuid), pool->sp_map_version, - map_version); + /* This should be a D_DEBUG eventually. */ + D_INFO(DF_UUID ": ignored pool map update: version=%u->%u cached_version=%u\n", + DP_UUID(pool->sp_uuid), pool_map_get_version(pool->sp_map), map_version, + pool->sp_map_version); } out: ABT_rwlock_unlock(pool->sp_lock);