Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid is_mountable calls #440

Closed
robin-nitrokey opened this issue Feb 13, 2024 · 3 comments · Fixed by #489
Closed

Avoid is_mountable calls #440

robin-nitrokey opened this issue Feb 13, 2024 · 3 comments · Fixed by #489

Comments

@robin-nitrokey
Copy link
Member

Filesystem::is_mountable calls Filesystem::mount, checks the result and drops the mounted filesystem. This means that code that first calls is_mountable and then mount on the same storage mounts the storage twice.

fn init_vfs(
vfs_storage: &'static mut VolatileStorage,
vfs_alloc: &'static mut Allocation<VolatileStorage>,
) -> LfsResult<Filesystem<'static, VolatileStorage>> {
if !Filesystem::is_mountable(vfs_storage) {
Filesystem::format(vfs_storage).ok();
}
Filesystem::mount(vfs_alloc, vfs_storage)
}

Instead we should first call Filesystem::mount and handle the error case directly.

@robin-nitrokey
Copy link
Member Author

This should significantly reduce bootup time. With logging enabled (log-semihosting,log-info), removing the is_mountable call reduces the mount time from 1 000 ms to 500 ms and the total bootup time from 2 300 ms to 1 800 ms. Unfortunately, the borrow checker does not allow us to re-try the mount in the error case because of the static lifetime of the returned filesystem. Maybe we can find a workaround.

robin-nitrokey added a commit that referenced this issue Apr 24, 2024
With this patch, the EFS is only mounted once if it is mountable.  This
significantly reduces bootup time by approximately 0.5 s.

Fixes: #440
@sosthene-nitrokey
Copy link
Collaborator

We could have a mount_or_format method in littlefs2 ?

I'm not sure I see the borrow checker error. Is this NLL case N°3 again?

@robin-nitrokey
Copy link
Member Author

Yes, we can do it in littlefs2 but not directly in the firmware.

robin-nitrokey added a commit that referenced this issue May 22, 2024
With this patch, the EFS is only mounted once if it is mountable.  This
significantly reduces bootup time by approximately 0.5 s.

Fixes: #440
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants