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()
173 struct devlink_snapshot *snapshot, in devlink_nl_region_notify_build() argument
207 if (snapshot) { in devlink_nl_region_notify_build()
209 snapshot->id); in devlink_nl_region_notify_build()
230 struct devlink_snapshot *snapshot, in devlink_nl_region_notify() argument
241 msg = devlink_nl_region_notify_build(region, snapshot, cmd, 0, 0); in devlink_nl_region_notify()
267 * @id: the snapshot id
269 * Track when a new snapshot begins using an id. Load the count for the
270 * given id from the snapshot xarray, increment it, and store it back.
272 * Called when a new snapshot is created with the given id.
310 * @id: the snapshot id
312 * Track when a snapshot is deleted and stops using an id. Load the count
313 * for the given id from the snapshot xarray, decrement it, and store it
319 * Called when a snapshot using the given id is deleted, and when the
350 * __devlink_snapshot_id_insert - Insert a specific snapshot ID
352 * @id: the snapshot id
354 * Mark the given snapshot id as used by inserting a zero value into the
355 * snapshot xarray.
362 * Returns zero on success, or an error code if the snapshot id could not
381 * __devlink_region_snapshot_id_get - get snapshot ID
383 * @id: storage to return snapshot id
385 * Allocates a new snapshot id. Returns zero on success, or a negative
389 * Snapshot IDs are tracked using an xarray which stores the number of
390 * users of the snapshot id.
394 * snapshot by using devlink_region_snapshot_id_put.
403 * __devlink_region_snapshot_create - create a new snapshot
404 * This will add a new snapshot of a region. The snapshot
410 * Must be called only while holding the region snapshot lock.
412 * @region: devlink region of the snapshot
413 * @data: snapshot data
414 * @snapshot_id: snapshot id to be created
421 struct devlink_snapshot *snapshot; in __devlink_region_snapshot_create() local
426 /* check if region can hold one more snapshot */ in __devlink_region_snapshot_create()
433 snapshot = kzalloc(sizeof(*snapshot), GFP_KERNEL); in __devlink_region_snapshot_create()
434 if (!snapshot) in __devlink_region_snapshot_create()
441 snapshot->id = snapshot_id; in __devlink_region_snapshot_create()
442 snapshot->region = region; in __devlink_region_snapshot_create()
443 snapshot->data = data; in __devlink_region_snapshot_create()
445 list_add_tail(&snapshot->list, &region->snapshot_list); in __devlink_region_snapshot_create()
449 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_NEW); in __devlink_region_snapshot_create()
453 kfree(snapshot); in __devlink_region_snapshot_create()
458 struct devlink_snapshot *snapshot) in devlink_region_snapshot_del() argument
464 devlink_nl_region_notify(region, snapshot, DEVLINK_CMD_REGION_DEL); in devlink_region_snapshot_del()
466 list_del(&snapshot->list); in devlink_region_snapshot_del()
467 region->ops->destructor(snapshot->data); in devlink_region_snapshot_del()
468 __devlink_snapshot_id_decrement(devlink, snapshot->id); in devlink_region_snapshot_del()
469 kfree(snapshot); in devlink_region_snapshot_del()
594 struct devlink_snapshot *snapshot; in devlink_nl_region_del_doit() local
625 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_del_doit()
626 if (!snapshot) { in devlink_nl_region_del_doit()
631 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_del_doit()
639 struct devlink_snapshot *snapshot; in devlink_nl_region_new_doit() local
674 if (!region->ops->snapshot) { in devlink_nl_region_new_doit()
675 …NL_SET_ERR_MSG(info->extack, "The requested region does not support taking an immediate snapshot"); in devlink_nl_region_new_doit()
692 NL_SET_ERR_MSG(info->extack, "The requested snapshot id is already in use"); in devlink_nl_region_new_doit()
703 NL_SET_ERR_MSG(info->extack, "Failed to allocate a new snapshot id"); in devlink_nl_region_new_doit()
709 err = region->port_ops->snapshot(port, region->port_ops, in devlink_nl_region_new_doit()
712 err = region->ops->snapshot(devlink, region->ops, in devlink_nl_region_new_doit()
724 snapshot = devlink_region_snapshot_get_by_id(region, in devlink_nl_region_new_doit()
726 if (WARN_ON(!snapshot)) { in devlink_nl_region_new_doit()
731 msg = devlink_nl_region_notify_build(region, snapshot, in devlink_nl_region_new_doit()
755 devlink_region_snapshot_del(region, snapshot); in devlink_nl_region_new_doit()
839 struct devlink_snapshot *snapshot = cb_priv; in devlink_region_snapshot_fill() local
841 memcpy(chunk, &snapshot->data[curr_offset], chunk_size); in devlink_region_snapshot_fill()
924 NL_SET_ERR_MSG(cb->extack, "No snapshot id provided"); in devlink_nl_region_read_dumpit()
941 struct devlink_snapshot *snapshot; in devlink_nl_region_read_dumpit() local
945 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Direct region read does not use snapshot"); in devlink_nl_region_read_dumpit()
951 snapshot = devlink_region_snapshot_get_by_id(region, snapshot_id); in devlink_nl_region_read_dumpit()
952 if (!snapshot) { in devlink_nl_region_read_dumpit()
953 NL_SET_ERR_MSG_ATTR(cb->extack, snapshot_attr, "Requested snapshot does not exist"); in devlink_nl_region_read_dumpit()
958 region_cb_priv = snapshot; in devlink_nl_region_read_dumpit()
1167 struct devlink_snapshot *snapshot, *ts; in devl_region_destroy() local
1173 list_for_each_entry_safe(snapshot, ts, &region->snapshot_list, list) in devl_region_destroy()
1174 devlink_region_snapshot_del(region, snapshot); in devl_region_destroy()
1203 * devlink_region_snapshot_id_get - get snapshot ID
1205 * This callback should be called when adding a new snapshot,
1224 * devlink_region_snapshot_id_put - put snapshot ID reference
1240 * devlink_region_snapshot_create - create a new snapshot
1241 * This will add a new snapshot of a region. The snapshot
1247 * @region: devlink region of the snapshot
1248 * @data: snapshot data
1249 * @snapshot_id: snapshot id to be created