liveupdate: Add internal APIs for file preservation
Subsystems (3)
v3 cover liveupdate: Add internal APIs for file preservation
Note: Sending v3 of this as it was requested to document some of the discussion we had on the email.
Live update orchestrator file handlers depend on the preservation of other files. To make sure that the dependency is preserved, the file handlers needs to fetch the preservation token of the preserved dependency. Similarly during restore, a file handler wants to fetch the restored file of the dependency.
There are two known usecases of this,
- VFIO-Cdev preservation requires the preservation of iommufd. This is required by the IOMMU preservation series:
https://lore.kernel.org/all/[email protected]/
- guest_memfd preservation requires the preservation of kvmfd. This is required by the guest_memfd preservation series:
https://lore.kernel.org/all/20ae20f9d1a198b289444ebb4c824314cbba1bcf.1780676742.git.tarunsahu@google.com/
This patch was being sent as part of the IOMMU preservation series, but now it is being sent separately.
v3:
- Add File Handler dependency documentation.
v2:
- rebased on liveupdate/next to resolve conflicts
- Added a note about resolution of dependencies based on offline discussion with Pasha and David.
Pasha Tatashin (1):
liveupdate: luo_file: Add internal APIs for file preservation
include/linux/liveupdate.h | 22 +++++++++ kernel/liveupdate/luo_file.c | 84 ++++++++++++++++++++++++++++++++ kernel/liveupdate/luo_internal.h | 17 +++++++ 3 files changed, 123 insertions(+)
base-commit: 3a0b8fa2eb36afc88b62a95f33f0c77c71fa5ded
Signature · 1 line
2.55.0.766.g2966f0265a-goog
PATCH v3 1/1 liveupdate: luo_file: Add internal APIs for file preservation
From: Pasha Tatashin <[email protected]>
Live update orchestrator file handlers depend on the preservation of other files. To make sure that the dependency is preserved, the file handlers needs to fetch the preservation token of the preserved dependency. Similarly during restore, a file handler wants to fetch the restored file of the dependency.
Add APIs that allows fetching token of dependency during preservation, and fetching the restored file dependency during restore.
--- include/linux/liveupdate.h | 22 +++++++++ kernel/liveupdate/luo_file.c | 84 ++++++++++++++++++++++++++++++++ kernel/liveupdate/luo_internal.h | 17 +++++++ 3 files changed, 123 insertions(+)
include/linux/liveupdate.h +22 -0
@@ -25,6 +25,7 @@ struct file;/** * struct liveupdate_file_op_args - Arguments for file operation callbacks. * @handler: The file handler being called. +* @session: The session this file belongs to. * @retrieve_status: The retrieve status for the 'can_finish / finish' * operation. A value of 0 means the retrieve has not been * attempted, a positive value means the retrieve was
@@ -45,6 +46,7 @@ struct file;*/ struct liveupdate_file_op_args {struct liveupdate_file_handler *handler; +struct liveupdate_session *session;int retrieve_status;struct file *file;u64 serialized_data;
@@ -247,6 +249,14 @@ void liveupdate_flb_put_incoming(struct liveupdate_flb *flb);int liveupdate_flb_get_outgoing (struct liveupdate_flb *flb,void **objp);void liveupdate_flb_put_outgoing (struct liveupdate_flb *flb); +/* kernel can internally retrieve files */ +int liveupdate_get_file_incoming (struct liveupdate_session *s,u64 token, +struct file **filep); + +/* Get a token for an outgoing file, or -ENOENT if file is not preserved */ +int liveupdate_get_token_outgoing (struct liveupdate_session *s, +struct file *file,u64 *tokenp); +#else /* CONFIG_LIVEUPDATE */ static inline bool liveupdate_enabled (void )
@@ -299,5 +309,17 @@ static inline void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb) { } +static inline int liveupdate_get_file_incoming (struct liveupdate_session *s, +u64 token,struct file **filep) +{ +return -EOPNOTSUPP ; +} + +static inline int liveupdate_get_token_outgoing (struct liveupdate_session *s, +struct file *file,u64 *tokenp) +{ +return -EOPNOTSUPP ; +} +#endif /* CONFIG_LIVEUPDATE */ #endif /* _LINUX_LIVEUPDATE_H */
kernel/liveupdate/luo_file.c +84 -0
135 lines not on this page · raw message
kernel/liveupdate/luo_internal.h +17 -0
@@ -77,6 +77,23 @@ struct luo_session {extern struct rw_semaphore luo_register_rwlock; +static inline struct liveupdate_session *luo_session_from_file_set (struct luo_file_set *file_set) +{ +struct luo_session *session; + + session = container_of(file_set, struct luo_session, file_set); + +return (struct liveupdate_session *)session; +} + +static inline struct luo_file_set *luo_file_set_from_session_locked (struct liveupdate_session *s) +{ +struct luo_session *session = (struct luo_session *)s; + +lockdep_assert_held (&session->mutex); +return &session->file_set; +} +int luo_session_create (const char *name,struct file **filep);int luo_session_retrieve (const char *name,struct file **filep);void __init luo_session_setup_outgoing (u64 *sessions_pa);
Signature · 1 line
2.55.0.766.g2966f0265a-goog