Reserve the last 5% of file descriptors for root use. This should allow

systems to fail more gracefully when a file descriptor exhaustion situation
occurs.

Original patch by:	David G. Andersen <dga@lcs.mit.edu>
PR:			45353
MFC after:		1 week
This commit is contained in:
Mike Silbersack 2003-06-18 18:57:58 +00:00
parent 7c2d2efd58
commit 438f085b2f

View File

@ -1192,13 +1192,14 @@ falloc(td, resultfp, resultfd)
struct proc *p = td->td_proc;
struct file *fp, *fq;
int error, i;
int maxuserfiles = maxfiles - (maxfiles / 20);
fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO);
sx_xlock(&filelist_lock);
if (nfiles >= maxfiles) {
if (((nfiles >= maxuserfiles) && (td->td_ucred->cr_ruid != 0))
|| (nfiles >= maxfiles)) {
sx_xunlock(&filelist_lock);
uma_zfree(file_zone, fp);
tablefull("file");
return (ENFILE);
}
nfiles++;