Bug 26323 - [ufs] [patch] Quota system creates zero-length files
Summary: [ufs] [patch] Quota system creates zero-length files
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 4.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-fs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-04-03 19:50 UTC by bg
Modified: 2009-05-18 17:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bg 2001-04-03 19:50:01 UTC
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.

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++) {
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2009-05-18 04:04:38 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 2 Konstantin Belousov freebsd_committer freebsd_triage 2009-05-18 17:37:26 UTC
State Changed
From-To: open->closed

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.