[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250515182322.117840-10-pasha.tatashin@soleen.com>
Date: Thu, 15 May 2025 18:23:13 +0000
From: Pasha Tatashin <pasha.tatashin@...een.com>
To: pratyush@...nel.org,
jasonmiu@...gle.com,
graf@...zon.com,
changyuanl@...gle.com,
pasha.tatashin@...een.com,
rppt@...nel.org,
dmatlack@...gle.com,
rientjes@...gle.com,
corbet@....net,
rdunlap@...radead.org,
ilpo.jarvinen@...ux.intel.com,
kanie@...ux.alibaba.com,
ojeda@...nel.org,
aliceryhl@...gle.com,
masahiroy@...nel.org,
akpm@...ux-foundation.org,
tj@...nel.org,
yoann.congal@...le.fr,
mmaurer@...gle.com,
roman.gushchin@...ux.dev,
chenridong@...wei.com,
axboe@...nel.dk,
mark.rutland@....com,
jannh@...gle.com,
vincent.guittot@...aro.org,
hannes@...xchg.org,
dan.j.williams@...el.com,
david@...hat.com,
joel.granados@...nel.org,
rostedt@...dmis.org,
anna.schumaker@...cle.com,
song@...nel.org,
zhangguopeng@...inos.cn,
linux@...ssschuh.net,
linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org,
linux-mm@...ck.org,
gregkh@...uxfoundation.org,
tglx@...utronix.de,
mingo@...hat.com,
bp@...en8.de,
dave.hansen@...ux.intel.com,
x86@...nel.org,
hpa@...or.com,
rafael@...nel.org,
dakr@...nel.org,
bartosz.golaszewski@...aro.org,
cw00.choi@...sung.com,
myungjoo.ham@...sung.com,
yesanishhere@...il.com,
Jonathan.Cameron@...wei.com,
quic_zijuhu@...cinc.com,
aleksander.lobakin@...el.com,
ira.weiny@...el.com,
andriy.shevchenko@...ux.intel.com,
leon@...nel.org,
lukas@...ner.de,
bhelgaas@...gle.com,
wagi@...nel.org,
djeffery@...hat.com,
stuart.w.hayes@...il.com,
ptyadav@...zon.de
Subject: [RFC v2 09/16] luo: luo_files: implement file systems callbacks
Implements the core logic within luo_files.c to invoke the prepare,
reboot, finish, and cancel callbacks for preserved file instances,
replacing the previous stub implementations. It also handles
the persistence and retrieval of the u64 data payload associated with
each file via the LUO FDT.
This completes the core mechanism enabling registered filesystem
handlers to actively manage file state across the live update
transition using the LUO framework.
Signed-off-by: Pasha Tatashin <pasha.tatashin@...een.com>
---
drivers/misc/liveupdate/luo_files.c | 105 +++++++++++++++++++++++++++-
1 file changed, 103 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/liveupdate/luo_files.c b/drivers/misc/liveupdate/luo_files.c
index 953fc40db3d7..091bf07e051a 100644
--- a/drivers/misc/liveupdate/luo_files.c
+++ b/drivers/misc/liveupdate/luo_files.c
@@ -272,6 +272,48 @@ int luo_files_fdt_setup(void *fdt)
return -ENOSPC;
}
+static void __luo_do_files_cancel_calls(struct luo_file *boundary_file)
+{
+ unsigned long token;
+ struct luo_file *h;
+
+ xa_for_each(&luo_files_xa_out, token, h) {
+ if (h == boundary_file)
+ break;
+
+ if (h->fs->cancel) {
+ h->fs->cancel(h->file, h->fs->arg, h->private_data);
+ h->private_data = 0;
+ }
+ }
+}
+
+static int luo_files_commit_data_to_fdt(void)
+{
+ int files_node_offset, node_offset, ret;
+ unsigned long token;
+ char token_str[19];
+ struct luo_file *h;
+
+ files_node_offset = fdt_subnode_offset(luo_fdt_out, 0,
+ LUO_FILES_NODE_NAME);
+ xa_for_each(&luo_files_xa_out, token, h) {
+ snprintf(token_str, sizeof(token_str), "%#0llx", (u64)token);
+ node_offset = fdt_subnode_offset(luo_fdt_out,
+ files_node_offset,
+ token_str);
+ ret = fdt_setprop(luo_fdt_out, node_offset, "data",
+ &h->private_data, sizeof(h->private_data));
+ if (ret < 0) {
+ pr_err("Failed to set data property for token %s: %s\n",
+ token_str, fdt_strerror(ret));
+ return -ENOSPC;
+ }
+ }
+
+ return 0;
+}
+
/**
* luo_do_files_prepare_calls - Calls prepare callbacks and updates FDT
* if all prepares succeed. Handles cancellation on failure.
@@ -287,7 +329,29 @@ int luo_files_fdt_setup(void *fdt)
*/
int luo_do_files_prepare_calls(void)
{
- return 0;
+ unsigned long token;
+ struct luo_file *h;
+ int ret;
+
+ xa_for_each(&luo_files_xa_out, token, h) {
+ if (h->fs->prepare) {
+ ret = h->fs->prepare(h->file, h->fs->arg,
+ &h->private_data);
+ if (ret < 0) {
+ pr_err("Prepare failed for file token %#0llx handler '%s' [%d]\n",
+ (u64)token, h->fs->compatible, ret);
+ __luo_do_files_cancel_calls(h);
+
+ return ret;
+ }
+ }
+ }
+
+ ret = luo_files_commit_data_to_fdt();
+ if (ret)
+ __luo_do_files_cancel_calls(NULL);
+
+ return ret;
}
/**
@@ -305,7 +369,29 @@ int luo_do_files_prepare_calls(void)
*/
int luo_do_files_freeze_calls(void)
{
- return 0;
+ unsigned long token;
+ struct luo_file *h;
+ int ret;
+
+ xa_for_each(&luo_files_xa_out, token, h) {
+ if (h->fs->freeze) {
+ ret = h->fs->freeze(h->file, h->fs->arg,
+ &h->private_data);
+ if (ret < 0) {
+ pr_err("Freeze callback failed for file token %#0llx handler '%s' [%d]\n",
+ (u64)token, h->fs->compatible, ret);
+ __luo_do_files_cancel_calls(h);
+
+ return ret;
+ }
+ }
+ }
+
+ ret = luo_files_commit_data_to_fdt();
+ if (ret)
+ __luo_do_files_cancel_calls(NULL);
+
+ return ret;
}
/**
@@ -316,7 +402,20 @@ int luo_do_files_freeze_calls(void)
*/
void luo_do_files_finish_calls(void)
{
+ unsigned long token;
+ struct luo_file *h;
+
luo_files_recreate_luo_files_xa_in();
+ xa_for_each(&luo_files_xa_in, token, h) {
+ mutex_lock(&h->mutex);
+ if (h->state == LIVEUPDATE_STATE_UPDATED && h->fs->finish) {
+ h->fs->finish(h->file, h->fs->arg,
+ h->private_data,
+ h->reclaimed);
+ h->state = LIVEUPDATE_STATE_NORMAL;
+ }
+ mutex_unlock(&h->mutex);
+ }
}
/**
@@ -330,6 +429,8 @@ void luo_do_files_finish_calls(void)
*/
void luo_do_files_cancel_calls(void)
{
+ __luo_do_files_cancel_calls(NULL);
+ luo_files_commit_data_to_fdt();
}
/**
--
2.49.0.1101.gccaa498523-goog
Powered by blists - more mailing lists