devlink: health: combine loops in dump
authorJakub Kicinski <kuba@kernel.org>
Thu, 5 Jan 2023 04:05:25 +0000 (20:05 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 6 Jan 2023 06:13:39 +0000 (22:13 -0800)
Walk devlink instances only once. Dump the instance reporters
and port reporters before moving to the next instance.
User space should not depend on ordering of messages.

This will make improving stability of the walk easier.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/devlink/leftover.c

index d88461b..83cd7bd 100644 (file)
@@ -7940,10 +7940,7 @@ devlink_nl_cmd_health_reporter_get_dumpit(struct sk_buff *msg,
                        idx++;
                }
                mutex_unlock(&devlink->reporters_lock);
-               devlink_put(devlink);
-       }
 
-       devlinks_xa_for_each_registered_get(sock_net(msg->sk), index, devlink) {
                devl_lock(devlink);
                xa_for_each(&devlink->ports, port_index, port) {
                        mutex_lock(&port->reporters_lock);