[vhffs-dev] [1349] now storing current quota in bytes instead of blocks ( fixed a bug when multiple files of few bytes are modified a lot)

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1349
Author:   gradator
Date:     2009-02-22 00:18:49 +0100 (Sun, 22 Feb 2009)

Log Message:
-----------
now storing current quota in bytes instead of blocks (fixed a bug when multiple files of few bytes are modified a lot)

Modified Paths:
--------------
    trunk/vhffs-fs/vhffsfs.c


Modified: trunk/vhffs-fs/vhffsfs.c
===================================================================
--- trunk/vhffs-fs/vhffsfs.c	2009-02-20 02:56:40 UTC (rev 1348)
+++ trunk/vhffs-fs/vhffsfs.c	2009-02-21 23:18:49 UTC (rev 1349)
@@ -970,7 +970,6 @@
 		free(dq);
 		return NULL;
 	}
-	dq->dqb_curspace >>= 10;
 	return dq;
 }
 
@@ -1027,7 +1026,7 @@
 			dq = malloc(sizeof(struct dqblk));
 			dq->dqb_bhardlimit = n->rq_bhardlimit;
 			dq->dqb_bsoftlimit = n->rq_bsoftlimit;
-			dq->dqb_curspace = n->rq_curblocks;
+			dq->dqb_curspace = n->rq_curblocks << 10;
 			dq->dqb_ihardlimit = n->rq_fhardlimit;
 			dq->dqb_isoftlimit = n->rq_fsoftlimit;
 			dq->dqb_curinodes = n->rq_curfiles;
@@ -1047,7 +1046,7 @@
 #endif
 
 /* return 0 if the gid is not over quota, 1 if over quota, -errno in case of error */
-int vhffsfs_checkquota_gid_with_realpath(char *realpath, gid_t gid, size_t newblocks, int newfiles)  {
+int vhffsfs_checkquota_gid_with_realpath(char *realpath, gid_t gid, size_t newbytes, int newfiles)  {
 	int mode = 0;  /* 0 = do nothing, 1 = data, 2 = repository */
 	struct dqblk *dq = NULL;
 	int ret = 0;
@@ -1094,9 +1093,9 @@
 	dq = vhffsfs_checkquota_cache_lookup(key);
 	if(dq)  {
 		/* we should lock here but an error in quota computation is not important at all */
-		dq->dqb_curspace += newblocks;
+		dq->dqb_curspace += newbytes;
 		dq->dqb_curinodes += newfiles;
-		if(dq->dqb_curspace > dq->dqb_bhardlimit  ||  dq->dqb_curinodes > dq->dqb_ihardlimit) ret = 1;
+		if(dq->dqb_curspace>>10 > dq->dqb_bhardlimit  ||  dq->dqb_curinodes > dq->dqb_ihardlimit) ret = 1;
 		vhffsfs_checkquota_cache_unref(key);
 		free(key);
 		return ret;
@@ -1129,7 +1128,7 @@
 
 
 	if(!dq) {
-		printf("vhffsfs: quota: %s\n", strerror(errno));
+		fprintf(stderr, "vhffsfs: quota: %s\n", strerror(errno));
 	}
 	else  {
 #ifdef WITH_CHECKQUOTA_CACHE
@@ -1146,9 +1145,9 @@
 
 		dq = vhffsfs_checkquota_cache_add(key, gid, path, dq);
 #endif
-		dq->dqb_curspace += newblocks;
+		dq->dqb_curspace += newbytes;
 		dq->dqb_curinodes += newfiles;
-		if(dq->dqb_curspace > dq->dqb_bhardlimit  ||  dq->dqb_curinodes > dq->dqb_ihardlimit) ret = 1;
+		if(dq->dqb_curspace>>10 > dq->dqb_bhardlimit  ||  dq->dqb_curinodes > dq->dqb_ihardlimit) ret = 1;
 #ifdef WITH_CHECKQUOTA_CACHE
 		vhffsfs_checkquota_cache_unref(key);
 		free(key);
@@ -1652,7 +1651,7 @@
 	rpath = vhffsfs_realpath(path, &uid, &gid);
 	if(!rpath) return -ENOENT;
 
-	res = vhffsfs_checkquota_gid_with_realpath(rpath, gid, (size >> 10) +1, 0);
+	res = vhffsfs_checkquota_gid_with_realpath(rpath, gid, size, 0);
 	free(rpath);
 	if(res) return -EDQUOT;
 #endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/