"nfiles" is a bad name for a global variable. Call it "openfiles" instead

as this is more correct and matches the sysctl variable.
This commit is contained in:
Poul-Henning Kamp 2004-12-01 09:22:26 +00:00
parent cc2f51ef32
commit e4643c730a
3 changed files with 10 additions and 10 deletions

View File

@ -140,7 +140,7 @@ struct filedesc0 {
* Descriptor management.
*/
struct filelist filehead; /* head of list of open files */
int nfiles; /* actual number of open files */
int openfiles; /* actual number of open files */
struct sx filelist_lock; /* sx to protect filelist */
struct mtx sigio_lock; /* mtx to protect pointers to sigio */
@ -1363,8 +1363,8 @@ falloc(td, resultfp, resultfd)
fp = uma_zalloc(file_zone, M_WAITOK | M_ZERO);
sx_xlock(&filelist_lock);
if ((nfiles >= maxuserfiles && (td->td_ucred->cr_ruid != 0 ||
jailed(td->td_ucred))) || nfiles >= maxfiles) {
if ((openfiles >= maxuserfiles && (td->td_ucred->cr_ruid != 0 ||
jailed(td->td_ucred))) || openfiles >= maxfiles) {
if (ppsratecheck(&lastfail, &curfail, 1)) {
printf("kern.maxfiles limit exceeded by uid %i, please see tuning(7).\n",
td->td_ucred->cr_ruid);
@ -1373,7 +1373,7 @@ falloc(td, resultfp, resultfd)
uma_zfree(file_zone, fp);
return (ENFILE);
}
nfiles++;
openfiles++;
/*
* If the process has file descriptor zero open, add the new file
@ -1421,7 +1421,7 @@ ffree(struct file *fp)
KASSERT(fp->f_count == 0, ("ffree: fp_fcount not 0!"));
sx_xlock(&filelist_lock);
LIST_REMOVE(fp, f_list);
nfiles--;
openfiles--;
sx_xunlock(&filelist_lock);
crfree(fp->f_cred);
uma_zfree(file_zone, fp);
@ -2460,7 +2460,7 @@ SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW,
&maxfiles, 0, "Maximum number of files");
SYSCTL_INT(_kern, OID_AUTO, openfiles, CTLFLAG_RD,
&nfiles, 0, "System-wide number of open files");
&openfiles, 0, "System-wide number of open files");
static void
fildesc_drvinit(void *unused)

View File

@ -1664,11 +1664,11 @@ unp_gc()
* 91/09/19, bsy@cs.cmu.edu
*/
again:
nfiles_snap = nfiles + nfiles_slack; /* some slack */
nfiles_snap = openfiles + nfiles_slack; /* some slack */
extra_ref = malloc(nfiles_snap * sizeof(struct file *), M_TEMP,
M_WAITOK);
sx_slock(&filelist_lock);
if (nfiles_snap < nfiles) {
if (nfiles_snap < openfiles) {
sx_sunlock(&filelist_lock);
free(extra_ref, M_TEMP);
nfiles_slack += 20;

View File

@ -166,8 +166,8 @@ extern struct fileops badfileops;
extern struct fileops socketops;
extern int maxfiles; /* kernel limit on number of open files */
extern int maxfilesperproc; /* per process limit on number of open files */
extern int nfiles; /* (fl) actual number of open files */
extern struct sx filelist_lock; /* sx to protect filelist and nfiles */
extern int openfiles; /* (fl) actual number of open files */
extern struct sx filelist_lock; /* sx to protect filelist and openfiles */
int fget(struct thread *td, int fd, struct file **fpp);
int fget_read(struct thread *td, int fd, struct file **fpp);