From 77fe236fbbd453d63a97b92bf07fc6068421ea88 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Fri, 24 Jan 2025 10:06:50 -0500 Subject: [PATCH] LU-18621 lnet: fix wrong stats for lnet_net_show_dump For the function lnet_get_ni_stats() the im_idx assumes the idx is relative to all NIs. With lnet_net_show_dump() the idx we use is realtive to our own NI list so it doesn't always match the idx lnet_get_ni_stats() expects. This can lead to the wrong stats being collected when a net_id is set. The only reason we need an idx for lnet_get_ni_stats() is so the NI can be located but we already know the NI. Just call lnet_usr_translate_stats() directly instead of using lnet_get_ni_stats() to figure out the NI to call lnet_user_translate_stats() internally with. Test-Parameters: trivial testlist=sanity-lnet Fixes: 8f8f6e2f36e ("LU-10003 lnet: use Netlink to support old and new NI APIs.") Change-Id: Ie39e65146c21d976f9a7655eead8c46e9293ee27 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57885 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Chris Horn Reviewed-by: Cyril Bordage Reviewed-by: Oleg Drokin --- lnet/lnet/api-ni.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lnet/lnet/api-ni.c b/lnet/lnet/api-ni.c index 1b47621..d7bf960 100644 --- a/lnet/lnet/api-ni.c +++ b/lnet/lnet/api-ni.c @@ -5746,15 +5746,7 @@ skip_udsp: if (gnlh->version < 2) goto skip_msg_stats; - msg_stats.im_idx = idx - 1; - rc = lnet_get_ni_stats(&msg_stats); - if (rc < 0) { - NL_SET_ERR_MSG(extack, - "failed to get msg stats"); - genlmsg_cancel(msg, hdr); - GOTO(net_unlock, rc = -ENOMEM); - } - + lnet_usr_translate_stats(&msg_stats, &ni->ni_stats); send_stats = nla_nest_start(msg, LNET_NET_LOCAL_NI_ATTR_SEND_STATS); send_attr = nla_nest_start(msg, 0); nla_put_u32(msg, LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT, -- 1.8.3.1