[comp.bugs.4bsd] reno kernel `panic: missing dquot' when turning on accounting

chris@mimsy.umd.edu (Chris Torek) (08/23/90)

Index: sys/kern/kern_acct.c 4.3BSD-reno Fix

Description:
	If you have compiled your kernel with the DIAGNOSTIC option,
	quotas are enabled on some file system, and accounting is
	subsequently enabled on that file system, the kernel will panic
	with `missing dquot' as soon as a process exits.

Repeat-by:
	[compile with `options DIAGNOSTIC'; set up quotas for /var]
	# quotaon /var
	# accton /var/adm/acct
	# (exit)
	[machine crashes]

Fix:
	The problem is that the accounting code does not honor the
	normal vnode open protocol.  In particular, it never calls
	the vnode's access operation.  This is where the ufs code
	reads the quotas for a file system, since only files that
	are being written will ever have a quota change.

	No panic occurs if quotas are enabled *after* turning on
	accounting, because then the quota code attaches the dquot
	structures directly (by scanning all vnodes on that
	particular file system).  However, in this case the
	access and open operations still have not been called,
	so a file system type that uses these operations (e.g.,
	a Sprite-like system) would cause trouble if it were used
	for accounting.

	The line numbers below are off by one from the actual Reno
	distribution.

RCS file: RCS/kern_acct.c,v
retrieving revision 1.3
diff -c2 -r1.3 kern_acct.c
*** /tmp/,RCSt1000479	Wed Aug 22 14:10:38 1990
--- kern_acct.c	Wed Aug 22 14:10:24 1990
***************
*** 17,20 ****
--- 17,21 ----
  #include "mount.h"
  #include "kernel.h"
+ #include "file.h"
  #include "acct.h"
  #include "uio.h"
***************
*** 57,61 ****
  		savacctp = NULL;
  	}
! 	if (uap->fname==NULL) {
  		if (vp = acctp) {
  			acctp = NULL;
--- 58,62 ----
  		savacctp = NULL;
  	}
! 	if (uap->fname == NULL) {
  		if (vp = acctp) {
  			acctp = NULL;
***************
*** 65,72 ****
  		return (0);
  	}
- 	ndp->ni_nameiop = LOOKUP | FOLLOW;
  	ndp->ni_segflg = UIO_USERSPACE;
  	ndp->ni_dirp = uap->fname;
! 	if (error = namei(ndp))
  		return (error);
  	vp = ndp->ni_vp;
--- 66,72 ----
  		return (0);
  	}
  	ndp->ni_segflg = UIO_USERSPACE;
  	ndp->ni_dirp = uap->fname;
! 	if (error = vn_open(ndp, FWRITE, 0644))
  		return (error);
  	vp = ndp->ni_vp;
***************
*** 74,81 ****
  		vrele(vp);
  		return (EACCES);
- 	}
- 	if (vp->v_mount->mnt_flag & MNT_RDONLY) {
- 		vrele(vp);
- 		return (EROFS);
  	}
  	oacctp = acctp;
--- 74,77 ----
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain:	chris@cs.umd.edu	Path:	uunet!mimsy!chris