Module Name: src Committed By: bouyer Date: Thu Feb 3 17:36:31 UTC 2011
Modified Files: src/sys/ufs/ufs [bouyer-quota2]: quota1_subr.c quota2_subr.c src/tests/fs/ffs [bouyer-quota2]: h_quota2_tests.c t_quotalimit.sh Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/ufs/ufs/quota1_subr.c cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/ufs/ufs/quota2_subr.c cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/tests/fs/ffs/h_quota2_tests.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/tests/fs/ffs/t_quotalimit.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/ufs/quota1_subr.c diff -u src/sys/ufs/ufs/quota1_subr.c:1.1.2.2 src/sys/ufs/ufs/quota1_subr.c:1.1.2.3 --- src/sys/ufs/ufs/quota1_subr.c:1.1.2.2 Mon Jan 31 15:24:10 2011 +++ src/sys/ufs/ufs/quota1_subr.c Thu Feb 3 17:36:30 2011 @@ -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 Index: src/sys/ufs/ufs/quota2_subr.c diff -u src/sys/ufs/ufs/quota2_subr.c:1.1.2.5 src/sys/ufs/ufs/quota2_subr.c:1.1.2.6 --- src/sys/ufs/ufs/quota2_subr.c:1.1.2.5 Thu Feb 3 15:56:16 2011 +++ src/sys/ufs/ufs/quota2_subr.c Thu Feb 3 17:36:30 2011 @@ -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; Index: src/tests/fs/ffs/h_quota2_tests.c diff -u src/tests/fs/ffs/h_quota2_tests.c:1.1.2.1 src/tests/fs/ffs/h_quota2_tests.c:1.1.2.2 --- src/tests/fs/ffs/h_quota2_tests.c:1.1.2.1 Wed Feb 2 19:17:08 2011 +++ src/tests/fs/ffs/h_quota2_tests.c Thu Feb 3 17:36:31 2011 @@ -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) Index: src/tests/fs/ffs/t_quotalimit.sh diff -u src/tests/fs/ffs/t_quotalimit.sh:1.1.2.2 src/tests/fs/ffs/t_quotalimit.sh:1.1.2.3 --- src/tests/fs/ffs/t_quotalimit.sh:1.1.2.2 Wed Feb 2 21:01:08 2011 +++ src/tests/fs/ffs/t_quotalimit.sh Thu Feb 3 17:36:31 2011 @@ -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