Proper fmap support
I'd like input on something. As you might have noticed, the fmap support I added to redoxfs (redoxfs!35 (merged) and redoxfs!36 (merged)) is horrible. It loads in the entire chunk of the file you ask for, and then write the entire chunk on sync.
Unfortunately I only learned how linux does it after I actually got this implemented. What I optimally should do is this:
- Read PAGE_SIZE bytes of the file
- On page fault because it tries to access bytes that have not been loaded, read another page
- Write to the file on sync like normal.
But of course the pointer that the user has can't ever move. Not sure if this means that nothing can ever be reallocated or if it means that some virtual mapping thing needs to be updated to point to the new location. Linux solves this by finding a chunk in memory that can fit the entire file. Would this be a reasonable approach? How would this even be done, with a new syscall?
Another issue is that the bytes that aren't yet loaded can't be allocated because that wouldn't generate a page fault, but they also cannot be used by another program.