I am pleased to announce the first release of mirage-swapfs (swapfs on opam). It is an experimental library to use a mirage block device for ephemeral, append-only, anonymous “files”. It was developed for use cases such as in opam-mirror where opam package source archives are downloaded. The files are first downloaded to “swap” and if the download succeeds and the checksum is as expected the data is then copied over to the tar filesystem.
Internally it uses a weak pointer array (Weak.t
) to map “block” offsets to handles. The idea is the garbage collector can help us free up “blocks” if the user forgets to explicitly free the handle. A “block” is (configurable, see blocking_factor
) multiple of sectors in order to reduce bookkeeping overhead. With a sector size of 512 bytes the default is 1 MiB per block.
See also the documentation index (swapfs.index)
I would be interested to hear about other ideas or approaches.