sock: Delay asking a socket about it's placement_id until after it is

added to a group

The process of adding a socket to a group may, in some scenarios, change
the placement id.

Change-Id: I879d9641099d86978ede5d5e2be1a72eda65a79b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7207
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2021-03-29 15:19:22 -07:00 committed by Jim Harris
parent 141a95aa36
commit 4bcafd5b15

View File

@ -554,14 +554,6 @@ spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
return -1;
}
placement_id = sock_get_placement_id(sock);
if (placement_id != -1) {
rc = sock_map_insert(placement_id, group, 0);
if (rc < 0) {
return -1;
}
}
STAILQ_FOREACH_FROM(group_impl, &group->group_impls, link) {
if (sock->net_impl == group_impl->net_impl) {
break;
@ -574,14 +566,25 @@ spdk_sock_group_add_sock(struct spdk_sock_group *group, struct spdk_sock *sock,
}
rc = group_impl->net_impl->group_impl_add_sock(group_impl, sock);
if (rc == 0) {
TAILQ_INSERT_TAIL(&group_impl->socks, sock, link);
sock->group_impl = group_impl;
sock->cb_fn = cb_fn;
sock->cb_arg = cb_arg;
if (rc != 0) {
return rc;
}
return rc;
TAILQ_INSERT_TAIL(&group_impl->socks, sock, link);
sock->group_impl = group_impl;
sock->cb_fn = cb_fn;
sock->cb_arg = cb_arg;
placement_id = sock_get_placement_id(sock);
if (placement_id != -1) {
rc = sock_map_insert(placement_id, group, 0);
if (rc != 0) {
SPDK_ERRLOG("Failed to insert sock group into map: %d", rc);
/* Do not treat this as an error. The system will continue running. */
}
}
return 0;
}
int