From nobody@FreeBSD.org  Fri Nov 18 18:47:16 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8416116A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 Nov 2005 18:47:16 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 017A143D76
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 Nov 2005 18:47:11 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id jAIIlBNg086163
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 18 Nov 2005 18:47:11 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id jAIIlBF4086162;
	Fri, 18 Nov 2005 18:47:11 GMT
	(envelope-from nobody)
Message-Id: <200511181847.jAIIlBF4086162@www.freebsd.org>
Date: Fri, 18 Nov 2005 18:47:11 GMT
From: Mark Tinguely <tinguely@casselton.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: QUOTA in 6.0/7.0-current leak
X-Send-Pr-Version: www-2.3

>Number:         89247
>Category:       kern
>Synopsis:       [ffs] [patch] QUOTA in 6.0/7.0-current leak
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mpp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 18 18:50:25 GMT 2005
>Closed-Date:    Thu Feb 01 07:55:41 GMT 2007
>Last-Modified:  Thu Feb 01 07:55:41 GMT 2007
>Originator:     Mark Tinguely
>Release:        FreeBSD -6.0 and 7-current
>Organization:
>Environment:
FreeBSD markie 6.0-RELEASE FreeBSD 6.0-RELEASE #2: Fri Nov 18 12:12:33 CST 2005    tinguely@markie:/usr/src/sys/i386/compile/markie  i386
>Description:
In FreeBSD 6.0 and 7.0 -current /sys/ufs/ffs/ffs_alloc.c ffs_alloc() QUOTA is set before checking if the allocation can be met. Either the quota check should be after checking if there is available disk space or when determining there is no space, the reserved quota should be removed. I like option 2 - see below patch.
>How-To-Repeat:
1) fill a partition that has QUOTA enabled
2) quota -v
3) try to write a chunk of data (it will fail because the partition is full)
4) quota -v  and notice the quota keep increasing by the attempted chunk amount
5) delete all the data owned by this user in this partition
6) quota -v and notice the quota is still off by the attempted chunk amount

or visually look at code and see the chkdq() don't match
>Fix:
move the noswap: label above the chkdq() that readjusts the allocated quota:

*** ffs_alloc.c.orig    Fri Nov 18 12:37:38 2005
--- ffs_alloc.c Fri Nov 18 12:38:35 2005
***************
*** 185,190 ****
--- 185,191 ----
                *bnp = bno;
                return (0);
        }
+ nospace:
  #ifdef QUOTA
        UFS_UNLOCK(ump);
        /*
***************
*** 193,199 ****
        (void) chkdq(ip, -btodb(size), cred, FORCE);
        UFS_LOCK(ump);
  #endif
- nospace:
        if (fs->fs_pendingblocks > 0 && reclaimed == 0) {
                reclaimed = 1;
                softdep_request_cleanup(fs, ITOV(ip));
--- 194,199 ----

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: mpp 
State-Changed-When: Thu Jan 25 11:53:55 UTC 2007 
State-Changed-Why:  
Fixed in -current. 

Patch to -stable to follow after more stress testing in -current. 


Responsible-Changed-From-To: freebsd-bugs->mpp 
Responsible-Changed-By: mpp 
Responsible-Changed-When: Thu Jan 25 11:53:55 UTC 2007 
Responsible-Changed-Why:  
Fixed in -current. 

Patch to -stable to follow after more stress testing in -current. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89247 
State-Changed-From-To: patched->closed 
State-Changed-By: mpp 
State-Changed-When: Thu Feb 1 07:55:07 UTC 2007 
State-Changed-Why:  
Suggested fix applied to -stable and -current.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=89247 
>Unformatted:
