Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Stop treating the default values specially in QUOTACTL_G...



details:   https://anonhg.NetBSD.org/src/rev/bf830c0bc7cf
branches:  trunk
changeset: 773195:bf830c0bc7cf
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 07:06:01 2012 +0000

description:
Stop treating the default values specially in QUOTACTL_GETALL.

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c  |  22 +++++++++-------
 sys/sys/quotactl.h       |   4 +--
 sys/ufs/ufs/ufs_quota2.c |  63 ++++++++++++++++++++++++++++++++++++++---------
 3 files changed, 64 insertions(+), 25 deletions(-)

diffs (207 lines):

diff -r 0b3ccc391a43 -r bf830c0bc7cf sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 07:05:12 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 07:06:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.24 2012/01/29 07:05:12 dholland Exp $       */
+/*     $NetBSD: vfs_quotactl.c,v 1.25 2012/01/29 07:06:01 dholland Exp $       */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.24 2012/01/29 07:05:12 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.25 2012/01/29 07:06:01 dholland Exp $");
 
 #include <sys/malloc.h> /* XXX: temporary */
 #include <sys/mount.h>
@@ -512,6 +512,8 @@
        prop_array_t replies;
        prop_dictionary_t dict;
        unsigned i;
+       id_t id;
+       int defaultq;
        int error, error2;
        int skip = 0;
 
@@ -559,15 +561,15 @@
                goto skip;
        }
 
-       dict = vfs_quotactl_getall_makereply(0, 1, &result.qr_defblocks,
-                                            &result.qr_deffiles);
-       if (!prop_array_add_and_rel(replies, dict)) {
-               error = ENOMEM;
-               goto err;
-       }
-
        for (i = 0; i < result.qr_num; i += 2) {
-               dict = vfs_quotactl_getall_makereply(result.qr_keys[i].qk_id,0,
+               id = result.qr_keys[i].qk_id;
+               if (id == QUOTA_DEFAULTID) {
+                       id = 0;
+                       defaultq = 1;
+               } else {
+                       defaultq = 0;
+               }
+               dict = vfs_quotactl_getall_makereply(id, defaultq,
                                                     &result.qr_vals[i],
                                                     &result.qr_vals[i+1]);
                if (dict == NULL) {
diff -r 0b3ccc391a43 -r bf830c0bc7cf sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 07:05:12 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 07:06:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.22 2012/01/29 07:05:12 dholland Exp $   */
+/*     $NetBSD: quotactl.h,v 1.23 2012/01/29 07:06:01 dholland Exp $   */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -107,8 +107,6 @@
                        struct quotakcursor *qc_cursor;
                        int qc_idtype;
                        struct quota_getall_result {
-                               struct quotaval qr_defblocks;
-                               struct quotaval qr_deffiles;
                                struct quotakey *qr_keys;
                                struct quotaval *qr_vals;
                                unsigned qr_num;
diff -r 0b3ccc391a43 -r bf830c0bc7cf sys/ufs/ufs/ufs_quota2.c
--- a/sys/ufs/ufs/ufs_quota2.c  Sun Jan 29 07:05:12 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota2.c  Sun Jan 29 07:06:01 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.21 2012/01/29 07:05:12 dholland Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.22 2012/01/29 07:06:02 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -26,7 +26,7 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.21 2012/01/29 07:05:12 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.22 2012/01/29 07:06:02 dholland Exp $");
 
 #include <sys/buf.h>
 #include <sys/param.h>
@@ -1055,9 +1055,12 @@
        const int needswap = UFS_MPNEEDSWAP(ump);
        struct getuids gu;
        id_t junkid;
-       struct quotaval qv;
+       struct quotakey bkey, fkey;
+       struct quotaval bval, fval;
+       int dobval = 0, dofval = 0;
        unsigned num, maxnum;
        int skipfirst, skiplast;
+       int maxreturn, numreturn;
 
        cursor = Q2CURSOR(qkc);
        error = q2cursor_check(cursor);
@@ -1069,6 +1072,9 @@
                return ENODEV;
        }
 
+       maxreturn = result->qr_max;
+       numreturn = 0;
+
        mutex_enter(&dqlock);
        error = getq2h(ump, idtype, &hbp, &q2h, 0);
        if (error) {
@@ -1079,13 +1085,19 @@
        if (cursor->q2c_defaults_done == 0) {
                quota2_ufs_rwq2e(&q2h->q2h_defentry, &q2e, needswap);
                if (cursor->q2c_blocks_done == 0) {
-                       q2e_to_quotaval(&q2e, 1, &junkid, QL_BLOCK, &qv);
-                       result->qr_defblocks = qv;
+                       q2e_to_quotaval(&q2e, 1, &junkid, QL_BLOCK, &bval);
+                       bkey.qk_idtype = idtype;
+                       bkey.qk_id = QUOTA_DEFAULTID;
+                       bkey.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
+                       dobval = 1;
                        cursor->q2c_blocks_done = 1;
                }
                if (cursor->q2c_blocks_done == 1) {
-                       q2e_to_quotaval(&q2e, 1, &junkid, QL_FILE, &qv);
-                       result->qr_deffiles = qv;
+                       q2e_to_quotaval(&q2e, 1, &junkid, QL_FILE, &fval);
+                       fkey.qk_idtype = idtype;
+                       fkey.qk_id = QUOTA_DEFAULTID;
+                       fkey.qk_objtype = QUOTA_OBJTYPE_FILES;
+                       dofval = 1;
                        cursor->q2c_blocks_done = 0;
                        cursor->q2c_defaults_done = 1;
                }
@@ -1110,10 +1122,14 @@
 
        gu.skip = cursor->q2c_uidpos;
        gu.seen = 0;
-       gu.limit = result->qr_max / 2;
-       if (gu.limit == 0 && result->qr_max > 0) {
+       gu.limit = (maxreturn - numreturn) / 2;
+       if (gu.limit == 0 && (maxreturn - numreturn) > 0) {
                gu.limit = 1;
        }
+       if (dobval && gu.limit > 0)
+               gu.limit--;
+       if (dofval && gu.limit > 0)
+               gu.limit--;
        for (i = cursor->q2c_hashpos; i < quota2_hash_size ; i++) {
                offset = q2h->q2h_entries[i];
                gu.seen = 0;
@@ -1140,11 +1156,29 @@
                return error;
 
        maxnum = gu.nuids*2;
+       if (dobval)
+               maxnum++;
+       if (dofval)
+               maxnum++;
        result->qr_keys = malloc(maxnum * sizeof(result->qr_keys[0]),
                                 M_TEMP, M_WAITOK);
        result->qr_vals = malloc(maxnum * sizeof(result->qr_vals[0]),
                                 M_TEMP, M_WAITOK);
 
+       if (dobval && numreturn < maxreturn) {
+               result->qr_keys[numreturn] = bkey;
+               result->qr_vals[numreturn] = bval;
+               numreturn++;
+       }
+       if (dofval && numreturn < maxreturn) {
+               result->qr_keys[numreturn] = fkey;
+               result->qr_vals[numreturn] = fval;
+               numreturn++;
+       }
+       if (numreturn == maxreturn) {
+               return 0;
+       }
+
        /*
         * If we've already sent back the blocks value for the first id,
         * don't send it again (skipfirst).
@@ -1158,16 +1192,21 @@
        num = 0;
        for (j = 0; j < gu.nuids; j++) {
                error = quota2_result_add_q2e(ump, idtype,
-                   gu.uids[j], result, j*2,
+                   gu.uids[j], result, numreturn + j*2,
                    j == 0 && skipfirst,
                    j + 1 == gu.nuids && skiplast);
                if (error == ENOENT)
                        continue;
                if (error)
                        break;
-               num += 2;
+               if ((j == 0 && skipfirst) || (j + 1 == gu.nuids && skiplast)) {
+                       num += 1;
+               } else {
+                       num += 2;
+               }
        }
-       result->qr_num = num;
+       numreturn += num;
+       result->qr_num = numreturn;
 
        cursor->q2c_blocks_done = skiplast;
 



Home | Main Index | Thread Index | Old Index