aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2021-11-08 20:59:31 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2021-11-20 21:49:57 +0000
commit53cff1d4ddb9f46d9c68eb3ec1f81717f7a8767c (patch)
tree28c8f0aa972bc3bb77ddfb7b4998a8e611f6b0a6
parent92b40444d07aeef2bf4b20109f3f90ac343b90df (diff)
downloadsrc-53cff1d4ddb9f46d9c68eb3ec1f81717f7a8767c.tar.gz
src-53cff1d4ddb9f46d9c68eb3ec1f81717f7a8767c.zip
nfsd: Fix f_bavail and f_ffree for NFSv4 when negative
Since the NFS Space_available and Files_available are unsigned, the NFSv3 server sets them to 0 when negative, so that they do not appear to be large positive values for non-FreeBSD clients. This patch fixes the NFSv4 server to do the same. Found during a recent IEFT NFSv4 working group testing event. (cherry picked from commit d70ca5b00eede3367ce659a03b2f9cc9729cd0dd)
-rw-r--r--sys/fs/nfs/nfs_commonsubs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/fs/nfs/nfs_commonsubs.c b/sys/fs/nfs/nfs_commonsubs.c
index 390d6e91535f..e4120d4d9e78 100644
--- a/sys/fs/nfs/nfs_commonsubs.c
+++ b/sys/fs/nfs/nfs_commonsubs.c
@@ -2482,6 +2482,17 @@ nfsv4_fillattr(struct nfsrv_descript *nd, struct mount *mp, vnode_t vp,
}
NFSCLRSTATFS_ATTRBIT(retbitp);
}
+ /*
+ * Since NFS handles these values as unsigned on the
+ * wire, there is no way to represent negative values,
+ * so set them to 0. Without this, they will appear
+ * to be very large positive values for clients like
+ * Solaris10.
+ */
+ if (fs->f_bavail < 0)
+ fs->f_bavail = 0;
+ if (fs->f_ffree < 0)
+ fs->f_ffree = 0;
}
#endif