From bg@bg.sics.se  Tue Apr  3 11:46:49 2001
Return-Path: <bg@bg.sics.se>
Received: from bg.sics.se (bg.sics.se [193.10.66.124])
	by hub.freebsd.org (Postfix) with ESMTP id 7800237B71D
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  3 Apr 2001 11:46:48 -0700 (PDT)
	(envelope-from bg@bg.sics.se)
Received: (from bg@localhost)
	by bg.sics.se (8.11.1/8.11.1) id f33IknH19740;
	Tue, 3 Apr 2001 20:46:49 +0200 (CEST)
	(envelope-from bg)
Message-Id: <200104031846.f33IknH19740@bg.sics.se>
Date: Tue, 3 Apr 2001 20:46:49 +0200 (CEST)
From: bg@sics.se
Reply-To: bg@sics.se
To: FreeBSD-gnats-submit@freebsd.org
Cc: bg@sics.se
Subject: Quota subsystem generates zero-length files
X-Send-Pr-Version: 3.2

>Number:         26323
>Category:       kern
>Synopsis:       [ufs] [patch] Quota system creates zero-length files
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-fs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Apr 03 11:50:01 PDT 2001
>Closed-Date:    Mon May 18 16:40:58 UTC 2009
>Last-Modified:  Mon May 18 16:40:58 UTC 2009
>Originator:     Bjoern Groenvall
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
SICS
>Environment:

Systems using the UFS quota subsystem.

>Description:

When a user comes close to his block quota limit, there are often many
zero-length files created. This can be avoided be requiring a minimum
number of blocks before inode creation is allowed to prooeed.

>How-To-Repeat:

	

>Fix:

Enable the following code using sysctl.

--- ufs_quota.c	2000/11/18 11:49:53	1.1
+++ ufs_quota.c	2000/11/19 09:22:03	1.2
@@ -46,12 +46,17 @@
 #include <sys/proc.h>
 #include <sys/vnode.h>
 #include <sys/mount.h>
+#include <sys/sysctl.h>
+
 #include <vm/vm_zone.h>
 
 #include <ufs/ufs/quota.h>
 #include <ufs/ufs/inode.h>
 #include <ufs/ufs/ufsmount.h>
 
+static int quota_minblocks = 0;
+SYSCTL_INT(_debug, OID_AUTO, quota_minblocks , CTLFLAG_RW, &quota_minblocks, 0, "");
+
 static MALLOC_DEFINE(M_DQUOT, "UFS quota", "UFS quota entries");
 
 /*
@@ -275,6 +280,15 @@
 			error = chkiqchg(ip, change, cred, i);
 			if (error)
 				return (error);
+			/*
+			 * If user has fewer than quota_minblocks
+			 * left, disallow inode allocation.
+			 */
+			if (quota_minblocks > 0) {
+				error = chkdqchg(ip, quota_minblocks, cred, i);
+				if (error)
+					return (error);
+			}
 		}
 	}
 	for (i = 0; i < MAXQUOTAS; i++) {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-fs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon May 18 03:04:38 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=26323 
State-Changed-From-To: open->closed 
State-Changed-By: kib 
State-Changed-When: Mon May 18 16:37:26 UTC 2009 
State-Changed-Why:  
Described behaviour is a consequence of the design of the quita system 
and (probably) misbehaving applications. Proposed patch tries to implement 
the "disallow new inode allocations when too low number of blocks 
in user quota left", that is just silly, IMHO. 

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