Re: [PATCH v3 10/10] liveupdate: Defer file handler module refcounting to active sessions

From: Andrew Morton

Date: Fri Mar 27 2026 - 13:27:41 EST


On Fri, 27 Mar 2026 03:33:34 +0000 Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> wrote:

> Stop pinning modules indefinitely upon file handler registration.
> Instead, dynamically increment the module reference count only when a
> live update session actively uses the file handler (e.g., during
> preservation or deserialization), and release it when the session ends.
>
> This allows modules providing live update handlers to be gracefully
> unloaded when no live update is in progress.
>
> ...
>
> @@ -322,6 +323,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd)
> kfree(luo_file);
> err_flb_unpreserve:
> luo_flb_file_unpreserve(fh);
> +err_module_put:
> + module_put(fh->ops->owner);
> err_free_files_mem:
> luo_free_files_mem(file_set);
> err_fput:

This didn't anticipate your "liveupdate: prevent double management of
files". I resolved it thusly:

err_kfree:
kfree(luo_file);
err_flb_unpreserve:
luo_flb_file_unpreserve(fh);
err_erase_xa:
xa_erase(&luo_preserved_files, luo_get_id(fh, file));
err_module_put:
module_put(fh->ops->owner);
err_free_files_mem:
luo_free_files_mem(file_set);
err_fput:
fput(file);

return err;
}