diff options
author | Jakub Kicinski <kuba@kernel.org> | 2023-01-05 07:05:29 +0300 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2023-01-06 09:13:39 +0300 |
commit | e4d5015bc11bcc5123ec8805d8c7f1e28a77a8a9 (patch) | |
tree | ce3c7144723b61a592a2bb70ea4058574c20cee3 | |
parent | c9666bac537e0f98ce15ea57c5fb25fc0a9a29b1 (diff) | |
download | linux-e4d5015bc11bcc5123ec8805d8c7f1e28a77a8a9.tar.xz |
devlink: uniformly take the devlink instance lock in the dump loop
Move the lock taking out of devlink_nl_cmd_region_get_devlink_dumpit().
This way all dumps will take the instance lock in the main iteration
loop directly, making refactoring and reading the code 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>
-rw-r--r-- | net/devlink/leftover.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 091f8814185d..4c91143d0792 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -6050,9 +6050,8 @@ static int devlink_nl_cmd_region_get_devlink_dumpit(struct sk_buff *msg, struct devlink_region *region; struct devlink_port *port; unsigned long port_index; - int err = 0; + int err; - devl_lock(devlink); list_for_each_entry(region, &devlink->region_list, list) { if (*idx < start) { (*idx)++; @@ -6064,7 +6063,7 @@ static int devlink_nl_cmd_region_get_devlink_dumpit(struct sk_buff *msg, cb->nlh->nlmsg_seq, NLM_F_MULTI, region); if (err) - goto out; + return err; (*idx)++; } @@ -6072,12 +6071,10 @@ static int devlink_nl_cmd_region_get_devlink_dumpit(struct sk_buff *msg, err = devlink_nl_cmd_region_get_port_dumpit(msg, cb, port, idx, start); if (err) - goto out; + return err; } -out: - devl_unlock(devlink); - return err; + return 0; } static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg, @@ -6090,8 +6087,10 @@ static int devlink_nl_cmd_region_get_dumpit(struct sk_buff *msg, devlink_dump_for_each_instance_get(msg, state, devlink) { int idx = 0; + devl_lock(devlink); err = devlink_nl_cmd_region_get_devlink_dumpit(msg, cb, devlink, &idx, state->idx); + devl_unlock(devlink); devlink_put(devlink); if (err) { state->idx = idx; |