I started this week's work by reading the first chapters of Design and Implementation of the UVM virtual memory system to see if I'd learn how to manage anonymous memory. I had been suggested to use anonymous memory objects (aobjs, for short) to store file contents, so I was shown with the task to learn what they are and how to use them. I have to confess that I was afraid of not knowing how to complete the read/write operations for the file-system, because things were very confusing to me even after reading the document. In fact, I spent two or three days reading documentation and code, as well as doing tests, but not doing any real work.
Fortunately, after lots of tests and some words of advice from my mentor, I started to understand how things worked and how aobjs could benefit tmpfs. After two days or so, I had a working implementation of the read and write hooks, which popped out to be simpler than I thought because most of the work is done by the memory manager. Well... the write operation is less than optimal: it uses the slowest algorithm it'd use to resize aobjs, but is enough for now. Note that it's a must to fix this item (plus several others; see below) before the file-system can be considered "decent".
Aside these two operations, which were my only goal for this week, I managed to complete all other functionality of the file-system. Some of the missing operations were trivial to implement, because the implementations provided by genfs are enough for them. Others, such as the ability to create and use symbolic links, named pipes and special devices, were a bit trickier, but not really difficult. These required refactoring some of the existing code to avoid duplication, which is good because I ended up with cleaner code.
Of special interest was the creation of the getpages function. The one in genfs is extremely complex because it's designed to read and write data block by block from a file-system stored on-disk (calling other operations such as bmap and strategy). In the tmpfs case, this only needs to loan pages from the internal file to the vnode object representing it, a fast operation done internally by UVM. Neat.
Summarizing: tmpfs is (almost) feature complete. It's now time to optimize it (this is very important), fix some stuff, debug it and write the two documents I promised (as described in the project's page). I've created a little non-exhaustive to-do list to not forget about anything. But if you want, you can start playing with it: just don't expect great performance nor stability. Enjoy!