aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/tmpfs/tmpfs_subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/fs/tmpfs/tmpfs_subr.c')
-rw-r--r--sys/fs/tmpfs/tmpfs_subr.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c
index 0068656968b5..e454f45a089f 100644
--- a/sys/fs/tmpfs/tmpfs_subr.c
+++ b/sys/fs/tmpfs/tmpfs_subr.c
@@ -178,12 +178,14 @@ RB_PROTOTYPE_STATIC(tmpfs_dir, tmpfs_dirent, uh.td_entries, tmpfs_dirtree_cmp);
size_t
tmpfs_mem_avail(void)
{
- vm_ooffset_t avail;
+ size_t avail;
+ long reserved;
- avail = swap_pager_avail + vm_free_count() - tmpfs_pages_reserved;
- if (__predict_false(avail < 0))
- avail = 0;
- return (avail);
+ avail = swap_pager_avail + vm_free_count();
+ reserved = atomic_load_long(&tmpfs_pages_reserved);
+ if (__predict_false(avail < reserved))
+ return (0);
+ return (avail - reserved);
}
size_t