Lines Matching full:snapshot

62 	struct devlink_snapshot *snapshot;  in devlink_region_snapshot_get_by_id()  local
64 list_for_each_entry(snapshot, &region->snapshot_list, list) in devlink_region_snapshot_get_by_id()
65 if (snapshot->id == id) in devlink_region_snapshot_get_by_id()
66 return snapshot; in devlink_region_snapshot_get_by_id()
73 struct devlink_snapshot *snapshot) in devlink_nl_region_snapshot_id_put() argument
82 err = nla_put_u32(msg, DEVLINK_ATTR_REGION_SNAPSHOT_ID, snapshot->id); in devlink_nl_region_snapshot_id_put()
98 struct devlink_snapshot *snapshot; in devlink_nl_region_snapshots_id_put() local
107 list_for_each_entry(snapshot, &region->snapshot_list, list) { in devlink_nl_region_snapshots_id_put()
108 err = devlink_nl_region_snapshot_id_put(msg, devlink, snapshot); in devlink_nl_region_snapshots_id_put()
171 struct devlink_snapshot *snapshot, in devlink_nl_region_notify_build() argument
205 if (snapshot) { in devlink_nl_region_notify_build()
207 snapshot->id); in devlink_nl_region_notify_build()
228 struct devlink_snapshot *snapshot, in devlink_nl_region_notify() argument
239 msg = devlink_nl_region_notify_build(region, snapshot, cmd, 0, 0); in devlink_nl_region_notify()
265 * @id: the snapshot id
267 * Track when a new snapshot begins using an id. Load the count for the
268 * given id from the snapshot xarray, increment it, and store it back.
270 * Called when a new snapshot is created with the given id.
308 * @id: the snapshot id
310 * Track when a snapshot is deleted and stops using an id. Load the count
311 * for the given id from the snapshot xarray, decrement it, and store it
317 * Called when a snapshot using the given id is deleted, and when the
348 * __devlink_snapshot_id_insert - Insert a specific snapshot ID
350 * @id: the snapshot id
352 * Mark the given snapshot id as used by inserting a zero value into the
353 * snapshot xarray.
360 * Returns zero on success, or an error code if the snapshot id could not
379 * __devlink_region_snapshot_id_get - get snapshot ID
381 * @id: storage to return snapshot id
383 * Allocates a new snapshot id. Returns zero on success, or a negative
387 * Snapshot IDs are tracked using an xarray which stores the number of
388 * users of the snapshot id.
392 * snapshot by using devlink_region_snapshot_id_put.
401 * __devlink_region_snapshot_create - create a new snapshot
402 * This will add a new snapshot of a region. The snapshot
408 * Must be called only while holding the region snapshot lock.
410 * @region: devlink region of the snapshot
411 * @data: snapshot data
412 * @snapshot_id: snapshot id to be created
419 struct devlink_snapshot *snapshot; in __devlink_region_snapshot_create() local
424 /* check if region can hold one more snapshot */ in __devlink_region_snapshot_create()
431 snapshot = kzalloc(sizeof(*snapshot), GFP_KERNEL); in __devlink_region_snapshot_create()
432 if (!snapshot) in __devlink_region_snapshot_create()
439 snapshot->id = snapshot_id; in __devlink_region_snapshot_create()
440 snapshot->region = region; in __devlink_region_snapshot_create()
441 snapshot->data = data; in __devlink_region_snapshot_create()
443 list_add_tail(&snapshot->list, &region->snapshot_list); in __devlink_region_snapshot_create()
447 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_NEW); in __devlink_region_snapshot_create()
451 kfree(snapshot); in __devlink_region_snapshot_create()
456 struct devlink_snapshot *snapshot) in devlink_region_snapshot_del() argument
462 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL); in devlink_region_snapshot_del()
464 list_del(&snapshot->list); in devlink_region_snapshot_del()
465 region->ops->destructor(snapshot->data); in devlink_region_snapshot_del()
466 __devlink_snapshot_id_decrement(devlink, snapshot->id); in devlink_region_snapshot_del()
467 kfree(snapshot); in devlink_region_snapshot_del()
592 struct devlink_snapshot *snapshot; in devlink_nl_region_del_doit() local
623 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_del_doit()
624 if (!snapshot) { in devlink_nl_region_del_doit()
629 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_del_doit()
637 struct devlink_snapshot *snapshot; in devlink_nl_region_new_doit() local
672 if (!region->ops->snapshot) { in devlink_nl_region_new_doit()
673 …NL_SET_ERR_MSG(info->extack, "The requested region does not support taking an immediate snapshot"); in devlink_nl_region_new_doit()
690 NL_SET_ERR_MSG(info->extack, "The requested snapshot id is already in use"); in devlink_nl_region_new_doit()
701 NL_SET_ERR_MSG(info->extack, "Failed to allocate a new snapshot id"); in devlink_nl_region_new_doit()
707 err = region->port_ops->snapshot(port, region->port_ops, in devlink_nl_region_new_doit()
710 err = region->ops->snapshot(devlink, region->ops, in devlink_nl_region_new_doit()
722 snapshot = devlink_region_snapshot_get_by_id(region, in devlink_nl_region_new_doit()
724 if (WARN_ON(!snapshot)) { in devlink_nl_region_new_doit()
729 msg = devlink_nl_region_notify_build(region, snapshot, in devlink_nl_region_new_doit()
753 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_new_doit()
836 struct devlink_snapshot *snapshot = cb_priv; in devlink_region_snapshot_fill() local
838 memcpy(chunk, &snapshot->data[curr_offset], chunk_size); in devlink_region_snapshot_fill()
921 NL_SET_ERR_MSG(cb->extack, "No snapshot id provided"); in devlink_nl_region_read_dumpit()
938 struct devlink_snapshot *snapshot; in devlink_nl_region_read_dumpit() local
942 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Direct region read does not use snapshot"); in devlink_nl_region_read_dumpit()
948 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_read_dumpit()
949 if (!snapshot) { in devlink_nl_region_read_dumpit()
950 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Requested snapshot does not exist"); in devlink_nl_region_read_dumpit()
955 region_cb_priv = snapshot; in devlink_nl_region_read_dumpit()
1164 struct devlink_snapshot *snapshot, *ts; in devl_region_destroy() local
1170 list_for_each_entry_safe(snapshot, ts, &region->snapshot_list, list) in devl_region_destroy()
1171 devlink_region_snapshot_del(region, snapshot); in devl_region_destroy()
1200 * devlink_region_snapshot_id_get - get snapshot ID
1202 * This callback should be called when adding a new snapshot,
1221 * devlink_region_snapshot_id_put - put snapshot ID reference
1237 * devlink_region_snapshot_create - create a new snapshot
1238 * This will add a new snapshot of a region. The snapshot
1244 * @region: devlink region of the snapshot
1245 * @data: snapshot data
1246 * @snapshot_id: snapshot id to be created