xous-core
xous-core copied to clipboard
PDDB basis root record location does not change
The PDDB Basis root record is meant to be re-allocated every time it is updated. However, the current implementation keeps on writing it to the same location on disk.
The routine is here:
https://github.com/betrusted-io/xous-core/blob/779cc61c56dca623b110e738bbe4451bd9a428b5/services/pddb/src/backend/basis.rs#L1610-L1639
Instead of re-using the sector, it should use hw.try_fast_space_alloc()
and if it succeeds, takes the page, sets valid to true, dirty to true, and then updates the self.v2p_map.insert(basis_vpage, new_page)
. The old page can be dropped back into the fast space cache with fast_space_free
(it may generate a warning on the first time because the page wouldn't be in the cache already since it's not allocated out of the cache).
If the alloc doesn't succeed, I think it should just re-use the sector; later on, the alloc will run and make more space, but, because this is in a sync operation it should be infalliable in case of memory exhaustion; re-using the location in this case is probably fine.
This will require a lot of testing before pushing because we're modifying the root structure, so even though the changes are simple the regression testing is not.