Mnemofs's Master Node

The master node in mnemofs is the entity that can be used to get the location of the root of the file system.

When the journal is flushed (or, rather, the first n blocks are flushed), then all of the changes in the journal are applied to the entire file system in a true CoW way, and this finally cascades to the root of the file system, till the root is updated.

At this state, both the old data and the new data exist simultaneously, and the new location of the root is recorded in a new master node and written to the flash. Once the new master node is written to the flash, only the entire file system's "base state" gets updated, and now there is no risk of losing changes or leaving the device in an unrecoverable state (at least, till new updates come in). The block allocator ensures that both the data exist together and that old pages are not erased until the new master node is written which can allow for rollback of changes.

The master blocks are duplicates of each other, and contain multiple instances of the master node. The master node takes no more than a single page and contains information about the root, in a way similar to a parent directory. The master blocks contain various "revisions" (or instances) of the master blocks. It's important to note that only the latest master block is a "valid" master block. This means that all older master blocks do not point to a valid file system.

Journal Flush

The master blocks contain multiple master nodes. When the first n blocks of the journal are flushed, a new master node entry is created. Thus, a master block can hold pages_per_block number of master nodes. This also means that the master node does not need to be erased for every journal flush, but rather, in integral multiples of flushes. Thus, there are some times when the journal moves alone, while at others, the journal moves along with the msater blocks, and so, master blocks move much less that the other journal blocks.

Conclusion

Here you saw how the journal of mnemofs works. Now, moving on to the block allocator.



⌂ Home

MIT 2024 © resyfer.