9ns: Allow racy truncations
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 27 Mar 2018 22:27:28 +0000 (18:27 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Apr 2018 18:36:26 +0000 (14:36 -0400)
commit5f78d2d374ebc6ddb8c3b05250fd19984dd7d97e
tree0d9c6e148a9fcd7087c1ef2d39f4ac743563284e
parent963a0c9c36b3fd67c13244034afd80a9b4484e9c
9ns: Allow racy truncations

I'm relaxing the consistency guarantees during truncate/hole_punches.  If
you do concurrent reads, writes, or mmaps during truncate, you might get
weird data: old, new, or a combination of the two.

My primary desire for this is to avoid qlocking the file during what could
be parallel operations: reading or writing to non-overlapping parts of a
file.

Part of this is that the qlock is not held during pm_load_page, especially
for mmap faults.  In an alternate version of this code, pm_load_page held
the qlock, the PM op didn't need to grab the lock, and every mmap hard
fault (i.e. not the nowait, the one with pm_load_page that blocks) would
qlock.  Soft faults (the read fast-path) wouldn't qlock.

I'm not 100% on this, so I haven't squashed this into the original FS file
work.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/fs_file.h
kern/src/mm.c
kern/src/ns/fs_file.c