Bug 159351 - [nfs] [patch] - divide by zero in mountnfs()
Summary: [nfs] [patch] - divide by zero in mountnfs()
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-01 13:10 UTC by onwahe
Modified: 2019-01-19 20:06 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (550 bytes, patch)
2011-08-01 13:10 UTC, onwahe
no flags Details | Diff
file.diff (519 bytes, patch)
2011-08-01 13:10 UTC, onwahe
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description onwahe 2011-08-01 13:10:05 UTC
When nm_wcommitsize is initializing and desiredvnodes is less than 1000 a divide by zero happens.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-08-05 02:30:23 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 dfilter service freebsd_committer freebsd_triage 2011-11-15 01:39:16 UTC
Author: rmacklem
Date: Tue Nov 15 01:39:02 2011
New Revision: 227517
URL: http://svn.freebsd.org/changeset/base/227517

Log:
  Move the setting of the default value for nm_wcommitsize to
  before the nfs_decode_args() call in the new NFS client, so
  that a specfied command line value won't be overwritten.
  Also, modify the calculation for small values of desiredvnodes
  to avoid an unusually large value or a divide by zero crash.
  It seems that the default value for nm_wcommitsize is very
  conservative and may need to change at some time.
  
  PR:		kern/159351
  Submitted by:	onwahe at gmail.com (earlier version)
  Reviewed by:	jhb
  MFC after:	2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clvfsops.c

Modified: head/sys/fs/nfsclient/nfs_clvfsops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvfsops.c	Mon Nov 14 23:01:08 2011	(r227516)
+++ head/sys/fs/nfsclient/nfs_clvfsops.c	Tue Nov 15 01:39:02 2011	(r227517)
@@ -1231,6 +1231,10 @@ mountnfs(struct nfs_args *argp, struct m
 	nmp->nm_timeo = NFS_TIMEO;
 	nmp->nm_retry = NFS_RETRANS;
 	nmp->nm_readahead = NFS_DEFRAHEAD;
+	if (desiredvnodes >= 11000)
+		nmp->nm_wcommitsize = hibufspace / (desiredvnodes / 1000);
+	else
+		nmp->nm_wcommitsize = hibufspace / 10;
 
 	nfs_decode_args(mp, nmp, argp, hst, cred, td);
 
@@ -1252,7 +1256,6 @@ mountnfs(struct nfs_args *argp, struct m
 		nmp->nm_rsize = NFS_RSIZE;
 		nmp->nm_readdirsize = NFS_READDIRSIZE;
 	}
-	nmp->nm_wcommitsize = hibufspace / (desiredvnodes / 1000);
 	nmp->nm_numgrps = NFS_MAXGRPS;
 	nmp->nm_tprintf_delay = nfs_tprintf_delay;
 	if (nmp->nm_tprintf_delay < 0)
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:59 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Oleksandr Tymoshenko freebsd_committer freebsd_triage 2019-01-19 20:06:34 UTC
There was a commit referencing this bug, but it's still not closed and has been inactive for some time. Closing as "fixed". Please re-open it if the issue hasn't been completely resolved.