From nobody@FreeBSD.org  Wed Apr 11 12:08:13 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id EB4641065672
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Apr 2012 12:08:13 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id D5C2F8FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Apr 2012 12:08:13 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q3BC8D2Y057008
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 11 Apr 2012 12:08:13 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q3BC8Daq057007;
	Wed, 11 Apr 2012 12:08:13 GMT
	(envelope-from nobody)
Message-Id: <201204111208.q3BC8Daq057007@red.freebsd.org>
Date: Wed, 11 Apr 2012 12:08:13 GMT
From: Johan Bergs <johan.bergs@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Quotas: used block count increases but does not decrease
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         166840
>Category:       kern
>Synopsis:       [quota] used block count increases but does not decrease
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 11 12:10:14 UTC 2012
>Closed-Date:    Thu Dec 06 16:38:37 UTC 2012
>Last-Modified:  Thu Dec  6 16:40:00 UTC 2012
>Originator:     Johan Bergs
>Release:        9.0-RELEASE
>Organization:
University of Antwerp
>Environment:
FreeBSD euterpe.cmi.ua.ac.be 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Fri Mar 30 11:02:32 CEST 2012     root@euterpe.cmi.ua.ac.be:/usr/obj/usr/src/sys/PATS  amd64
>Description:
We have user quotas enabled on an amd64 system. The filesystem that has quotas enabled is mounted using the following options: (ufs, NFS exported, local, with quotas, journaled soft-updates)

When we check the user quotas using repquota, we can see all user quota. If a user adds new files to the filesystem, repquota does indeed reflect this: the used block count goes up. However, if a user deletes files, the used block count does not go down.

Running quotacheck recalculates the used block count, but afterwards the situation remains the same: used block count can increase, but does not decrease.

The system has recently been upgraded from FreeBSD 8.2. Quotas were working fine when running 8.2.



>How-To-Repeat:
Enable quotas on a FreeBSD 9.0 system, on a partition with soft updates and soft update journaling enabled. Create files and the used block count increases. Delete some files and the used block count remains the same.
>Fix:
None

>Release-Note:
>Audit-Trail:

From: Erwin Van de Velde <erwin.vandevelde@gmail.com>
To: bug-followup@freebsd.org, johan.bergs@gmail.com
Cc:  
Subject: Re: kern/166840: [quota] used block count increases but does not decrease
Date: Mon, 7 May 2012 11:26:51 +0200

 --14dae9340bdff4314c04bf6edfc3
 Content-Type: text/plain; charset=ISO-8859-1
 
 Found another problem report pointing to this (Thanks to koobs, Barnerd
 from IRC :-) ):
 - PR Kern/164734
 
 
 Potential patch (
 http://tips.paddyonline.net/index.php/FreeBSD_9.0_issues_with_Quota):
 
 diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
 index 5b4b6b9..ed2db79 100644
 --- a/sys/ufs/ffs/ffs_softdep.c
 +++ b/sys/ufs/ffs/ffs_softdep.c
 @@ -43,6 +43,7 @@
  __FBSDID("$FreeBSD$");
 
  #include "opt_ffs.h"
 +#include "opt_quota.h"
  #include "opt_ddb.h"
 
  /*
 @@ -6428,7 +6429,7 @@ softdep_setup_freeblocks(ip, length, flags)
   }
  #ifdef QUOTA
   /* Reference the quotas in case the block count is wrong in the end. */
 - quotaref(vp, freeblks->fb_quota);
 + quotaref(ITOV(ip), freeblks->fb_quota);
   (void) chkdq(ip, -datablocks, NOCRED, 0);
  #endif
   freeblks->fb_chkcnt = -datablocks;
 
 
 Did not test it myself yet.
 
 --14dae9340bdff4314c04bf6edfc3
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 Found another problem report pointing to this (Thanks to koobs, Barnerd fro=
 m IRC :-) ):<div>- PR Kern/164734</div><div><br></div><div><br></div><div>P=
 otential patch (<a href=3D"http://tips.paddyonline.net/index.php/FreeBSD_9.=
 0_issues_with_Quota">http://tips.paddyonline.net/index.php/FreeBSD_9.0_issu=
 es_with_Quota</a>):</div>
 
 <div><br></div><div><div>diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/f=
 fs/ffs_softdep.c</div><div>index 5b4b6b9..ed2db79 100644</div><div>--- a/sy=
 s/ufs/ffs/ffs_softdep.c</div><div>+++ b/sys/ufs/ffs/ffs_softdep.c</div>
 
 <div>@@ -43,6 +43,7 @@</div><div>=A0__FBSDID(&quot;$FreeBSD$&quot;);</div><=
 div>=A0</div><div>=A0#include &quot;opt_ffs.h&quot;</div><div>+#include &qu=
 ot;opt_quota.h&quot;</div><div>=A0#include &quot;opt_ddb.h&quot;</div><div>=
 =A0</div>
 
 <div>=A0/*</div><div>@@ -6428,7 +6429,7 @@ softdep_setup_freeblocks(ip, len=
 gth, flags)</div><div>=A0<span class=3D"Apple-tab-span" style=3D"white-spac=
 e:pre">	</span>}</div><div>=A0#ifdef QUOTA</div><div>=A0<span class=3D"Appl=
 e-tab-span" style=3D"white-space:pre">	</span>/* Reference the quotas in ca=
 se the block count is wrong in the end. */</div>
 
 <div>-<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>quot=
 aref(vp, freeblks-&gt;fb_quota);</div><div>+<span class=3D"Apple-tab-span" =
 style=3D"white-space:pre">	</span>quotaref(ITOV(ip), freeblks-&gt;fb_quota)=
 ;</div>
 
 <div>=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>(v=
 oid) chkdq(ip, -datablocks, NOCRED, 0);</div><div>=A0#endif</div><div>=A0<s=
 pan class=3D"Apple-tab-span" style=3D"white-space:pre">	</span>freeblks-&gt=
 ;fb_chkcnt =3D -datablocks;</div>
 
 </div><div><br></div><div><br></div><div>Did not test it myself yet.</div><=
 div><br></div>
 
 --14dae9340bdff4314c04bf6edfc3--

From: =?ISO-8859-1?Q?Antti_Nikkil=E4?= <atp99@kolumbus.fi>
To: bug-followup@FreeBSD.org, johan.bergs@gmail.com
Cc:  
Subject: Re: kern/166840: [quota] used block count increases but does not
 decrease
Date: Fri, 20 Jul 2012 11:21:17 +0300

 This is a multi-part message in MIME format.
 --------------040907030707010706000400
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hi,
 
 This is a follow-up to the problem report kern/166840: [quota] used 
 block count increases but does not decrease.
 
 We tested the reported potential patch 
 (http://tips.paddyonline.net/index.php/FreeBSD_9.0_issues_with_Quota 
 <http://tips.paddyonline.net/index.php/FreeBSD_9.0_issues_with_Quota%29:>) 
 on our 64bit Freebsd 9.0 system (running on VMWare ESXi). We applied the 
 patch over 2 months ago and the system has been running without any 
 problems since we applied the patch. Now the used block count increases 
 and decreases correctly (the partition has quota, soft updates and 
 softupdate journaling enabled).
 
 Environment:
 FreeBSD koala 9.0-RELEASE-p2 FreeBSD 9.0-RELEASE-p2 #0: Sat Jun  2 
 07:16:04 EEST 2012     hfvk@koala:/usr/obj/usr/src/sys/ELIZABETH amd64
 
 - Antti
 
 --------------040907030707010706000400
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 <html>
   <head>
 
     <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   </head>
   <body bgcolor="#FFFFFF" text="#000000">
     Hi,<br>
     <br>
     This is a follow-up to the problem report kern/166840: [quota] used
     block count increases but does not decrease.<br>
     <br>
     We tested the reported potential patch (<a
 href="http://tips.paddyonline.net/index.php/FreeBSD_9.0_issues_with_Quota%29:">http://tips.paddyonline.net/index.php/FreeBSD_9.0_issues_with_Quota</a>)
     on our 64bit Freebsd 9.0 system (running on VMWare ESXi). We applied
     the patch over 2 months ago and the system has been running without
     any problems since we applied the patch. Now the used block count
     increases and decreases correctly (the partition has quota, soft
     updates and softupdate journaling enabled).<br>
     <br>
     Environment:<br>
     FreeBSD koala 9.0-RELEASE-p2 FreeBSD 9.0-RELEASE-p2 #0: Sat Jun&nbsp; 2
     07:16:04 EEST 2012&nbsp;&nbsp;&nbsp;&nbsp; hfvk@koala:/usr/obj/usr/src/sys/ELIZABETH&nbsp;
     amd64<br>
     <br>
     - Antti<br>
   </body>
 </html>
 
 --------------040907030707010706000400--
State-Changed-From-To: open->closed 
State-Changed-By: gavin 
State-Changed-When: Thu Dec 6 16:37:44 UTC 2012 
State-Changed-Why:  
Fixed in r231091, merged to stable/9 as r231581. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166840 

From: Winston Weinert <winstonw@lavabit.com>
To: bug-followup@FreeBSD.org, johan.bergs@gmail.com
Cc:  
Subject: Re: kern/166840: [quota] used block count increases but does not
 decrease
Date: Thu, 06 Dec 2012 10:31:43 -0600

 I'd like to ask for a status update on PR kern/166840. This bug affects
 a VPS used for shell accounts I administrate.
 
 
>Unformatted:
