Commit 92b49822 authored by Jiri Pirko's avatar Jiri Pirko Committed by Jakub Kicinski

devlink: send notifications for deleted snapshots on region destroy

Currently the notifications for deleted snapshots are sent only in case
user deletes a snapshot manually. Send the notifications in case region
is destroyed too.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent 53f6f391
...@@ -370,14 +370,6 @@ devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id) ...@@ -370,14 +370,6 @@ devlink_region_snapshot_get_by_id(struct devlink_region *region, u32 id)
return NULL; return NULL;
} }
static void devlink_region_snapshot_del(struct devlink_snapshot *snapshot)
{
snapshot->region->cur_snapshots--;
list_del(&snapshot->list);
(*snapshot->data_destructor)(snapshot->data);
kfree(snapshot);
}
#define DEVLINK_NL_FLAG_NEED_DEVLINK BIT(0) #define DEVLINK_NL_FLAG_NEED_DEVLINK BIT(0)
#define DEVLINK_NL_FLAG_NEED_PORT BIT(1) #define DEVLINK_NL_FLAG_NEED_PORT BIT(1)
#define DEVLINK_NL_FLAG_NEED_SB BIT(2) #define DEVLINK_NL_FLAG_NEED_SB BIT(2)
...@@ -3595,6 +3587,16 @@ static void devlink_nl_region_notify(struct devlink_region *region, ...@@ -3595,6 +3587,16 @@ static void devlink_nl_region_notify(struct devlink_region *region,
nlmsg_free(msg); nlmsg_free(msg);
} }
static void devlink_region_snapshot_del(struct devlink_region *region,
struct devlink_snapshot *snapshot)
{
devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL);
region->cur_snapshots--;
list_del(&snapshot->list);
(*snapshot->data_destructor)(snapshot->data);
kfree(snapshot);
}
static int devlink_nl_cmd_region_get_doit(struct sk_buff *skb, static int devlink_nl_cmd_region_get_doit(struct sk_buff *skb,
struct genl_info *info) struct genl_info *info)
{ {
...@@ -3690,8 +3692,7 @@ static int devlink_nl_cmd_region_del(struct sk_buff *skb, ...@@ -3690,8 +3692,7 @@ static int devlink_nl_cmd_region_del(struct sk_buff *skb,
if (!snapshot) if (!snapshot)
return -EINVAL; return -EINVAL;
devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL); devlink_region_snapshot_del(region, snapshot);
devlink_region_snapshot_del(snapshot);
return 0; return 0;
} }
...@@ -6743,7 +6744,7 @@ void devlink_region_destroy(struct devlink_region *region) ...@@ -6743,7 +6744,7 @@ void devlink_region_destroy(struct devlink_region *region)
/* Free all snapshots of region */ /* Free all snapshots of region */
list_for_each_entry_safe(snapshot, ts, &region->snapshot_list, list) list_for_each_entry_safe(snapshot, ts, &region->snapshot_list, list)
devlink_region_snapshot_del(snapshot); devlink_region_snapshot_del(region, snapshot);
list_del(&region->list); list_del(&region->list);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment