kernel - Improve tmpfs support

Operating Systems / DragonFlyBSD - Matthew Dillon [] - 13 February 2020 20:33 EST

- When a file in tmpfs is truncated to a size that is not on a block boundary, or extended (but not written) to a size that is not on a block boundary, the nvextendbuf() and nvtruncbuf() functions must modify the contents of the straddling buffer and bdwrite().

However, a bdwrite() for a tmpfs buffer will result in a dirty buffer cache buffer and likely force it to be cycled out to swap relatively soon under a modest load. This is not desirable if there is no memory pressure present to force it out.

Tmpfs almost always uses buwrite() in order to leave the buffer 'clean' (the underlying VM pages are dirtied instead), to prevent unecessary paging of tmpfs data to swap when the buffer gets recycled or the vnode cycles out.

- Add support for calling buwrite() in these functions by changing the 'trivial' boolean into a flags variable.

- Tmpfs now passes the appropriate flag, preventing the undesirable behavior.

9cd86db5ab kernel - Improve tmpfs support
sys/kern/vfs_vm.c | 24 +++++++++++++---------
sys/sys/vnode.h | 10 ++++++++--
sys/vfs/hammer/hammer_vnops.c | 2 +-
sys/vfs/nfs/nfs.h | 2 +-
sys/vfs/nfs/nfs_bio.c | 10 +++++-----
sys/vfs/tmpfs/tmpfs.h | 1 +
sys/vfs/tmpfs/tmpfs_subr.c | 46 ++++++++++++++++++++++++++++++++++++++-----
sys/vfs/tmpfs/tmpfs_vfsops.c | 5 ++++-
sys/vfs/tmpfs/tmpfs_vnops.c | 28 +++++++++++++++-----------
sys/vfs/tmpfs/tmpfs_vnops.h | 1 +
10 files changed, 93 insertions(+), 36 deletions(-)


  • Share