Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jul 2002 08:00:08 -0700 (PDT)
From:      Ivan Albetkov <ivan_alb@agava.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/37057: Problem with rlimits on filesystem mounted from /dev/vn0c
Message-ID:  <200207101500.g6AF086N077484@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/37057; it has been noted by GNATS.

From: Ivan Albetkov <ivan_alb@agava.com>
To: freebsd-gnats-submit@FreeBSD.org, xi@borderworlds.dk
Cc:  
Subject: Re: kern/37057: Problem with rlimits on filesystem mounted from /dev/vn0c
Date: Wed, 10 Jul 2002 18:52:18 +0400

 This is a multi-part message in MIME format.
 --------------020304090205040304030603
 Content-Type: text/plain; charset=KOI8-R; format=flowed
 Content-Transfer-Encoding: 7bit
 
 I've just discovered this problem for myself and wrote a patch. But 
 later i've found this one. I'm not a kernel guru, so i ask for an 
 analysis: which of them is "better" (more reliable, etc.) and why.
 
 Tanks.
 My patch attached.
 
 P.S. Of course, my patch is working only if vn file is on a ufs fs. But 
 it is not diffcult to patch all this fs* files like ufs_readwrite.c.
 
 -- 
 
 Ivan Albetkov
 AGAVA Software (http://www.agava.com)
 
 
 --------------020304090205040304030603
 Content-Type: text/plain;
  name="vnfilesizelimit.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="vnfilesizelimit.diff"
 
 diff -u ufs/ufs/ufs_readwrite.c.orig ufs/ufs/ufs_readwrite.c
 --- ufs/ufs/ufs_readwrite.c.orig	Tue Jul  9 18:21:20 2002
 +++ ufs/ufs/ufs_readwrite.c	Tue Jul  9 19:33:24 2002
 @@ -402,6 +402,17 @@
  	int seqcount;
  	int blkoffset, error, extended, flags, ioflag, resid, size, xfersize;
  	vm_object_t object;
 +	int vn_used;
 +
 +	if(ap->a_vp->v_type == VREGVN)
 +        {
 +                vn_used = 1;
 +                ap->a_vp->v_type = VREG;
 +        }
 +        else
 +	{
 +                vn_used = 0;
 +	}
  
  	extended = 0;
  	seqcount = ap->a_ioflag >> 16;
 @@ -453,6 +464,7 @@
  	 * file servers have no limits, I don't think it matters.
  	 */
  	p = uio->uio_procp;
 +	if(!vn_used) {
  	if (vp->v_type == VREG && p &&
  	    uio->uio_offset + uio->uio_resid >
  	    p->p_rlimit[RLIMIT_FSIZE].rlim_cur) {
 @@ -460,6 +472,7 @@
  		if (object)
  			vm_object_vndeallocate(object);
  		return (EFBIG);
 +	}
  	}
  
  	resid = uio->uio_resid;
 diff -u dev/vn/vn.c.orig dev/vn/vn.c
 --- dev/vn/vn.c.orig	Tue Jul  9 18:21:00 2002
 +++ dev/vn/vn.c	Tue Jul  9 19:23:33 2002
 @@ -388,8 +388,13 @@
  		vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
  		if (bp->b_flags & B_READ)
  			error = VOP_READ(vn->sc_vp, &auio, IO_DIRECT, vn->sc_cred);
 -		else
 +		else {
 +			if(vn->sc_vp->v_type==VREG)
 +				vn->sc_vp->v_type=VREGVN;
  			error = VOP_WRITE(vn->sc_vp, &auio, IO_NOWDRAIN, vn->sc_cred);
 +		if(vn->sc_vp->v_type==VREGVN)
 +			vn->sc_vp->v_type=VREG;
 +		}
  		VOP_UNLOCK(vn->sc_vp, 0, curproc);
  		bp->b_resid = auio.uio_resid;
  
 diff -u sys/vnode.h.orig sys/vnode.h
 --- sys/vnode.h.orig	Tue Jul  9 16:32:24 2002
 +++ sys/vnode.h	Tue Jul  9 16:32:40 2002
 @@ -54,7 +54,7 @@
  /*
   * Vnode types.  VNON means no type.
   */
 -enum vtype	{ VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
 +enum vtype	{ VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD, VREGVN };
  
  /*
   * Vnode tag types.
 
 --------------020304090205040304030603--
 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200207101500.g6AF086N077484>