Re: file descriptor leak in 5.2-RC

From: David Malone <dwmalone_at_maths.tcd.ie>
Date: Sat, 27 Dec 2003 00:18:20 +0000
> during the machine is running on high load and after going to single 
> user mode. You can clearly see, that even though kern.openfiles still 
> shows a high number, pstat -f only finds very few files.

Ahhh crud - the kern.file sysctl isn't completly calculated from
the list of all open files - it iterates through all the processes
to form the final list. Could you try rerunning pstat with the patch
below - it walks the full open file list, rather than checking each
process (this may leak open file info to people within jails on the
machine, hopefully that is not a problem for you...)

(You'll need to recompile your kernel, but not anything else...)

If the files start to show up here, then we can begin to figure out
where they're comming from.

	David.


Index: sys/kern/kern_descrip.c
===================================================================
RCS file: /cvs/FreeBSD-CVS/src/sys/kern/kern_descrip.c,v
retrieving revision 1.215
diff -u -r1.215 kern_descrip.c
--- sys/kern/kern_descrip.c	19 Oct 2003 20:41:06 -0000	1.215
+++ sys/kern/kern_descrip.c	27 Dec 2003 00:01:06 -0000
_at__at_ -2312,6 +2312,24 _at__at_
 	error = 0;
 	bzero(&xf, sizeof(xf));
 	xf.xf_size = sizeof(xf);
+	/* DMXXX */
+	sx_slock(&filelist_lock);
+	LIST_FOREACH(fp, &filehead, f_list) {
+		xf.xf_fd = 0;
+		xf.xf_file = fp;
+		xf.xf_data = fp->f_data;
+		xf.xf_type = fp->f_type;
+		xf.xf_count = fp->f_count;
+		xf.xf_msgcount = fp->f_msgcount;
+		xf.xf_offset = fp->f_offset;
+		xf.xf_flag = fp->f_flag;
+		error = SYSCTL_OUT(req, &xf, sizeof(xf));
+		if (error)
+			break;
+	}
+	sx_sunlock(&filelist_lock);
+	return (error);
+	/* DMXXX */
 	sx_slock(&allproc_lock);
 	LIST_FOREACH(p, &allproc, p_list) {
 		PROC_LOCK(p);
Received on Fri Dec 26 2003 - 15:18:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:35 UTC