Date: Thu, 04 Nov 2004 00:36:10 +0100 From: Uwe Doering <gemini@geminix.org> To: Igor Sysoev <is@rambler-co.ru> Cc: stable@freebsd.org Subject: Re: vnode_pager_putpages errors and DOS? Message-ID: <41896B6A.5020100@geminix.org> In-Reply-To: <4189666A.9020500@geminix.org> References: <Pine.NEB.3.96L.1041009150440.93055O-100000@fledge.watson.org> <4168578F.7060706@geminix.org> <20041103191641.K63546@is.park.rambler.ru> <4189666A.9020500@geminix.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------060904050603040106010807 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Uwe Doering wrote: > [...] > What we need here is an additional test that makes sure that in case of > a character device bwillwrite() gets called only if the device is in > fact a disk. Please consider trying out the attached patch. It will > not reduce the heavy disk activity (which is, after all, legitimate), > but it is supposed to enable you to operate the system at shell level > and kill the offending process, or do whatever is necessary to resolve > the problem. Slight correction: Please use the attached patch instead. The first version would cause the compiler to complain about a missing prototype for isndchr(). Sorry about the oversight. I extracted the patch by hand from a larger patch collection. Uwe -- Uwe Doering | EscapeBox - Managed On-Demand UNIX Servers gemini@geminix.org | http://www.escapebox.net --------------060904050603040106010807 Content-Type: text/plain; name="sys_generic.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sys_generic.c.diff" --- src/sys/kern/sys_generic.c.orig Tue Sep 14 19:56:53 2004 +++ src/sys/kern/sys_generic.c Sun Sep 26 13:13:46 2004 @@ -48,6 +48,7 @@ #include <sys/filio.h> #include <sys/fcntl.h> #include <sys/file.h> +#include <sys/vnode.h> #include <sys/proc.h> #include <sys/signalvar.h> #include <sys/socketvar.h> @@ -78,6 +79,22 @@ static int dofilewrite __P((struct proc *, struct file *, int, const void *, size_t, off_t, int)); +static __inline int +isndchr(struct vnode *vp) +{ + struct cdevsw *dp; + + if (vp->v_type != VCHR) + return (0); + if (vp->v_rdev == NULL) + return (0); + if ((dp = devsw(vp->v_rdev)) == NULL) + return (0); + if (dp->d_flags & D_DISK) + return (0); + return (1); +} + struct file* holdfp(fdp, fd, flag) struct filedesc* fdp; @@ -403,7 +419,7 @@ } #endif cnt = nbyte; - if (fp->f_type == DTYPE_VNODE) + if (fp->f_type == DTYPE_VNODE && !isndchr((struct vnode *)(fp->f_data))) bwillwrite(); if ((error = fo_write(fp, &auio, fp->f_cred, flags, p))) { if (auio.uio_resid != cnt && (error == ERESTART || @@ -496,7 +512,7 @@ } #endif cnt = auio.uio_resid; - if (fp->f_type == DTYPE_VNODE) + if (fp->f_type == DTYPE_VNODE && !isndchr((struct vnode *)(fp->f_data))) bwillwrite(); if ((error = fo_write(fp, &auio, fp->f_cred, 0, p))) { if (auio.uio_resid != cnt && (error == ERESTART || --------------060904050603040106010807--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41896B6A.5020100>