aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2023-04-25 07:40:05 +0000
committerStefan Eßer <se@FreeBSD.org>2023-04-25 07:59:15 +0000
commit88a795e80c03ff1d960d830ee273589664ab06cc (patch)
tree28d0832ed7e3dc6ff007ecc5a4c98e0cf91300ef
parent0728695c63efda298feccefb3615c23cb6682929 (diff)
downloadsrc-88a795e80c03f.tar.gz
src-88a795e80c03f.zip
sys/fs: do not report blocks allocated for synthetic file systems
The pseudo file systems (devfs, fdescfs, procfs, etc.) report total and available blocks and inodes despite being synthetic with no underlying storage device to which those values could be applied. The current code of these file systems tends to report a fixed number of total blocks but no free blocks, and in the case of procfs, libprocfs, linsysfs also no free inodes. This can be irritating in e.g. the "df" output, since 100% of the resources seem to be in use, but it can also create warnings in monitoring tools used for capacity management. This patch makes these file systems return the same value for the total and free parameters, leading to 0% in use being displayed by "df". Since there is no resource that can be exhausted, this appears to be a sensible result. Reviewed by: mckusick Differential Revision: https://reviews.freebsd.org/D39442
-rw-r--r--sys/fs/devfs/devfs_vfsops.c4
-rw-r--r--sys/fs/fdescfs/fdesc_vfsops.c4
-rw-r--r--sys/fs/pseudofs/pseudofs.c8
3 files changed, 8 insertions, 8 deletions
diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c
index 56297578ec2a..0fac2b68e2e1 100644
--- a/sys/fs/devfs/devfs_vfsops.c
+++ b/sys/fs/devfs/devfs_vfsops.c
@@ -230,8 +230,8 @@ devfs_statfs(struct mount *mp, struct statfs *sbp)
sbp->f_bsize = DEV_BSIZE;
sbp->f_iosize = DEV_BSIZE;
sbp->f_blocks = 2; /* 1K to keep df happy */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
+ sbp->f_bfree = 2;
+ sbp->f_bavail = 2;
sbp->f_files = 0;
sbp->f_ffree = 0;
return (0);
diff --git a/sys/fs/fdescfs/fdesc_vfsops.c b/sys/fs/fdescfs/fdesc_vfsops.c
index edc2cdd61847..2961c3bf6224 100644
--- a/sys/fs/fdescfs/fdesc_vfsops.c
+++ b/sys/fs/fdescfs/fdesc_vfsops.c
@@ -223,8 +223,8 @@ fdesc_statfs(struct mount *mp, struct statfs *sbp)
sbp->f_bsize = DEV_BSIZE;
sbp->f_iosize = DEV_BSIZE;
sbp->f_blocks = 2; /* 1K to keep df happy */
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
+ sbp->f_bfree = 2;
+ sbp->f_bavail = 2;
sbp->f_files = lim + 1; /* Allow for "." */
sbp->f_ffree = freefd; /* See comments above */
return (0);
diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c
index 29071b34bd06..15a714e23bc6 100644
--- a/sys/fs/pseudofs/pseudofs.c
+++ b/sys/fs/pseudofs/pseudofs.c
@@ -379,10 +379,10 @@ pfs_mount(struct pfs_info *pi, struct mount *mp)
vfs_mountedfrom(mp, pi->pi_name);
sbp->f_bsize = PAGE_SIZE;
sbp->f_iosize = PAGE_SIZE;
- sbp->f_blocks = 1;
- sbp->f_bfree = 0;
- sbp->f_bavail = 0;
- sbp->f_files = 1;
+ sbp->f_blocks = 2;
+ sbp->f_bfree = 2;
+ sbp->f_bavail = 2;
+ sbp->f_files = 0;
sbp->f_ffree = 0;
return (0);