Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src Change semantic of limits to allow up to the limit i...
details: https://anonhg.NetBSD.org/src/rev/bf73bacfcc4f
branches: bouyer-quota2
changeset: 761108:bf73bacfcc4f
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Feb 03 17:36:30 2011 +0000
description:
Change semantic of limits to allow up to the limit inclued (instead of
up to one less than the limit: I feel that if my limit is 1000 inodes
I should be able to create 1000 files, not 999).
Keep the previous semantic for quota1 dquot, the conversion functions
will add or remove 1 when converting limits from/to the new format.
Adjust test for this change.
diffstat:
sys/ufs/ufs/quota1_subr.c | 12 ++++--------
sys/ufs/ufs/quota2_subr.c | 12 ++++++------
tests/fs/ffs/h_quota2_tests.c | 10 +++++-----
tests/fs/ffs/t_quotalimit.sh | 24 ++++++++++++------------
4 files changed, 27 insertions(+), 31 deletions(-)
diffs (193 lines):
diff -r d35a7f24b1b7 -r bf73bacfcc4f sys/ufs/ufs/quota1_subr.c
--- a/sys/ufs/ufs/quota1_subr.c Thu Feb 03 15:56:15 2011 +0000
+++ b/sys/ufs/ufs/quota1_subr.c Thu Feb 03 17:36:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota1_subr.c,v 1.1.2.2 2011/01/31 15:24:10 bouyer Exp $ */
+/* $NetBSD: quota1_subr.c,v 1.1.2.3 2011/02/03 17:36:30 bouyer Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.1.2.2 2011/01/31 15:24:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: quota1_subr.c,v 1.1.2.3 2011/02/03 17:36:30 bouyer Exp $");
#include <sys/types.h>
#include <machine/limits.h>
@@ -41,10 +41,8 @@
{
if (lim == 0)
return UQUAD_MAX;
- else if (lim == 1)
- return 0;
else
- return lim;
+ return (lim - 1);
}
static uint32_t
@@ -52,10 +50,8 @@
{
if (lim == UQUAD_MAX)
return 0;
- else if (lim == 0)
- return 1;
else
- return lim;
+ return (lim + 1);
}
void
diff -r d35a7f24b1b7 -r bf73bacfcc4f sys/ufs/ufs/quota2_subr.c
--- a/sys/ufs/ufs/quota2_subr.c Thu Feb 03 15:56:15 2011 +0000
+++ b/sys/ufs/ufs/quota2_subr.c Thu Feb 03 17:36:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2_subr.c,v 1.1.2.5 2011/02/03 15:56:16 bouyer Exp $ */
+/* $NetBSD: quota2_subr.c,v 1.1.2.6 2011/02/03 17:36:30 bouyer Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.1.2.5 2011/02/03 15:56:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: quota2_subr.c,v 1.1.2.6 2011/02/03 17:36:30 bouyer Exp $");
#include <sys/param.h>
#include <sys/time.h>
@@ -112,12 +112,12 @@
int
quota2_check_limit(struct quota2_val *q2v, uint64_t change, time_t now)
{
- if (q2v->q2v_cur + change >= q2v->q2v_hardlimit) {
- if (q2v->q2v_cur < q2v->q2v_softlimit)
+ if (q2v->q2v_cur + change > q2v->q2v_hardlimit) {
+ if (q2v->q2v_cur <= q2v->q2v_softlimit)
return (QL_F_CROSS | QL_S_DENY_HARD);
return QL_S_DENY_HARD;
- } else if (q2v->q2v_cur + change >= q2v->q2v_softlimit) {
- if (q2v->q2v_cur < q2v->q2v_softlimit)
+ } else if (q2v->q2v_cur + change > q2v->q2v_softlimit) {
+ if (q2v->q2v_cur <= q2v->q2v_softlimit)
return (QL_F_CROSS | QL_S_ALLOW_SOFT);
if (now > q2v->q2v_time) {
return QL_S_DENY_GRACE;
diff -r d35a7f24b1b7 -r bf73bacfcc4f tests/fs/ffs/h_quota2_tests.c
--- a/tests/fs/ffs/h_quota2_tests.c Thu Feb 03 15:56:15 2011 +0000
+++ b/tests/fs/ffs/h_quota2_tests.c Thu Feb 03 17:36:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_quota2_tests.c,v 1.1.2.1 2011/02/02 19:17:08 bouyer Exp $ */
+/* $NetBSD: h_quota2_tests.c,v 1.1.2.2 2011/02/03 17:36:31 bouyer Exp $ */
/*
* rump server for advanced quota tests
@@ -87,8 +87,8 @@
*/
int i;
- /* write 1.5k: with the directory this makes 2K */
- for (i = 0; i < 3; i++) {
+ /* write 2k: with the directory this makes 2.5K */
+ for (i = 0; i < 4; i++) {
error = rump_sys_write(fd, buf, sizeof(buf));
if (error != sizeof(buf))
err(1, "write failed early");
@@ -162,10 +162,10 @@
}
/*
- * create files up to the soft limit: one less as we already own the
+ * create files one past the soft limit: one less as we already own the
* root directory
*/
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < 4; i++) {
sprintf(buf, "file%d", i);
fd = rump_sys_open(buf, O_EXCL| O_CREAT | O_RDWR, 0644);
if (fd < 0)
diff -r d35a7f24b1b7 -r bf73bacfcc4f tests/fs/ffs/t_quotalimit.sh
--- a/tests/fs/ffs/t_quotalimit.sh Thu Feb 03 15:56:15 2011 +0000
+++ b/tests/fs/ffs/t_quotalimit.sh Thu Feb 03 17:36:30 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_quotalimit.sh,v 1.1.2.2 2011/02/02 21:01:08 bouyer Exp $
+# $NetBSD: t_quotalimit.sh,v 1.1.2.3 2011/02/03 17:36:31 bouyer Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
@@ -82,10 +82,10 @@
$(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2560 B\* 2048 B 3072 B 2:0 2 4 6 ' \
+ -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
- -o match:'daemon \+- 2 2 3 2:0 2 4 6' \
+ -o match:'daemon \+- 3 2 3 2:0 2 4 6' \
$(atf_get_srcdir)/rump_repquota -$q /mnt
done
rump_shutdown
@@ -129,7 +129,7 @@
$(atf_get_srcdir)/h_quota2_tests -b 1 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2048 B\* 2048 B 3072 B none 2 4 6 ' \
+ -o match:'/mnt 2560 B\* 2048 B 3072 B none 2 4 6 ' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
-o match:'daemon \+- 2 2 3 none 2 4 6' \
@@ -176,10 +176,10 @@
$(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 2:0' \
+ -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
- -o match:'daemon -\+ 2 2048 3072 5 4 6 2:0' \
+ -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \
$(atf_get_srcdir)/rump_repquota -$q /mnt
done
rump_shutdown
@@ -223,10 +223,10 @@
$(atf_get_srcdir)/h_quota2_tests -b 3 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2048 B 2048 K 3072 K 4 \* 4 6 none' \
+ -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 none' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
- -o match:'daemon -\+ 2 2048 3072 4 4 6 none' \
+ -o match:'daemon -\+ 2 2048 3072 5 4 6 none' \
$(atf_get_srcdir)/rump_repquota -$q /mnt
done
rump_shutdown
@@ -275,10 +275,10 @@
$(atf_get_srcdir)/h_quota2_tests -b 0 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2560 B\* 2048 B 3072 B 2:0 2 4 6 ' \
+ -o match:'/mnt 3072 B\* 2048 B 3072 B 2:0 2 4 6 ' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
- -o match:'daemon \+- 2 2 3 2:0 2 4 6' \
+ -o match:'daemon \+- 3 2 3 2:0 2 4 6' \
$(atf_get_srcdir)/rump_repquota -$q /mnt
done
rump_shutdown
@@ -327,10 +327,10 @@
$(atf_get_srcdir)/h_quota2_tests -b 2 ${IMG} ${RUMP_SERVER}
for q in ${expect} ; do
atf_check -s exit:0 \
- -o match:'/mnt 2560 B 2048 K 3072 K 5 \* 4 6 2:0' \
+ -o match:'/mnt 3072 B 2048 K 3072 K 6 \* 4 6 2:0' \
$(atf_get_srcdir)/rump_quota -$q -h ${id}
atf_check -s exit:0 \
- -o match:'daemon -\+ 2 2048 3072 5 4 6 2:0' \
+ -o match:'daemon -\+ 3 2048 3072 6 4 6 2:0' \
$(atf_get_srcdir)/rump_repquota -$q /mnt
done
rump_shutdown
Home |
Main Index |
Thread Index |
Old Index