Closed tchajed closed 5 years ago
Specifically what happened was that we were calling AsyncFS.file_set_sz
to implement ftruncate
, which merely sets the inode size. That works for shrinking the file but doesn't grow the file correctly. There is a function AsyncFS.file_truncate
with a specification and proof, but it operates on blocks, not bytes. We fixed the bug by implementing ftruncate
correctly, but that code does not have a proof.
The implementation of
ftruncate
calls the wrong function inAsyncFS.v
, setting the inode size blindly without allocating new blocks if the size grows. Here's a bug that results from implicitly using block 0 for the new blocks:test-case.c
:bug.sh
:Running
bug.sh
(or compiling and runningtest-case.c
after mounting FSCQ to/tmp/fscqmnt
) producesbar: 01 02
, sincefoo
andbar
point to the same disk blocks.