Print this page
7178 tmpfs incorrectly calculates amount of free space
@@ -19,10 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright 2016 RackTop Systems.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
@@ -587,11 +588,11 @@
/*
* If tm_anonmax for this mount is less than the available swap space
* (minus the amount tmpfs can't use), use that instead
*/
- if (blocks > tmpfs_minfree)
+ if (blocks > tmpfs_minfree && tm->tm_anonmax > tm->tm_anonmem)
sbp->f_bfree = MIN(blocks - tmpfs_minfree,
tm->tm_anonmax - tm->tm_anonmem);
else
sbp->f_bfree = 0;
@@ -628,17 +629,13 @@
* The maximum number of files available is approximately the number
* of tmpnodes we can allocate from the remaining kernel memory
* available to tmpfs. This is fairly inaccurate since it doesn't
* take into account the names stored in the directory entries.
*/
- if (tmpfs_maxkmem > tmp_kmemspace)
- sbp->f_ffree = (tmpfs_maxkmem - tmp_kmemspace) /
+ sbp->f_ffree = sbp->f_bfree == 0 ? 0 : sbp->f_bfree /
(sizeof (struct tmpnode) + sizeof (struct tdirent));
- else
- sbp->f_ffree = 0;
-
- sbp->f_files = tmpfs_maxkmem /
+ sbp->f_files = sbp->f_blocks == 0 ? 0 : sbp->f_blocks /
(sizeof (struct tmpnode) + sizeof (struct tdirent));
sbp->f_favail = (fsfilcnt64_t)(sbp->f_ffree);
(void) cmpldev(&d32, vfsp->vfs_dev);
sbp->f_fsid = d32;
(void) strcpy(sbp->f_basetype, vfssw[tmpfsfstype].vsw_name);