Skip to content

Commit

Permalink
DAOS-14730 pool: Clean up map update logging (#13709)
Browse files Browse the repository at this point in the history
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 <wei.g.li@intel.com>
  • Loading branch information
liw authored and jolivier23 committed May 28, 2024
1 parent ef5e51c commit 9b7547e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
31 changes: 12 additions & 19 deletions src/pool/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down
41 changes: 24 additions & 17 deletions src/pool/srv_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 9b7547e

Please sign in to comment.