Sun Jan 29 06:48:51 2012 UTC ()
Combine the miscellaneous QUOTACTL_SET args into a struct quotakey.

Note: this change requires a kernel version bump.


(dholland)
diff -r1.13 -r1.14 src/sys/kern/vfs_quotactl.c
diff -r1.11 -r1.12 src/sys/sys/quotactl.h
diff -r1.83 -r1.84 src/sys/ufs/ufs/ufs_quota.c
diff -r1.8 -r1.9 src/sys/ufs/ufs/ufs_quota.h
diff -r1.13 -r1.14 src/sys/ufs/ufs/ufs_quota1.c
diff -r1.9 -r1.10 src/sys/ufs/ufs/ufs_quota2.c

cvs diff -r1.13 -r1.14 src/sys/kern/vfs_quotactl.c (expand / switch to unified diff)

--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:47:38 1.13
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:48:50 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_quotactl.c,v 1.13 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: vfs_quotactl.c,v 1.14 2012/01/29 06:48:50 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -70,27 +70,27 @@ @@ -70,27 +70,27 @@
70 * 70 *
71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp 72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp
73 */ 73 */
74 74
75/* 75/*
76 * Note that both of the copyrights above are moderately spurious; 76 * Note that both of the copyrights above are moderately spurious;
77 * this code should almost certainly have the Copyright 2010 Manuel 77 * this code should almost certainly have the Copyright 2010 Manuel
78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c. 78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c.
79 * However, they're what was on the files this code was sliced out of. 79 * However, they're what was on the files this code was sliced out of.
80 */ 80 */
81 81
82#include <sys/cdefs.h> 82#include <sys/cdefs.h>
83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.13 2012/01/29 06:47:38 dholland Exp $"); 83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.14 2012/01/29 06:48:50 dholland Exp $");
84 84
85#include <sys/mount.h> 85#include <sys/mount.h>
86#include <sys/quota.h> 86#include <sys/quota.h>
87#include <sys/quotactl.h> 87#include <sys/quotactl.h>
88#include <quota/quotaprop.h> 88#include <quota/quotaprop.h>
89 89
90static int 90static int
91vfs_quotactl_getversion(struct mount *mp, 91vfs_quotactl_getversion(struct mount *mp,
92 prop_dictionary_t cmddict, int q2type, 92 prop_dictionary_t cmddict, int q2type,
93 prop_array_t datas) 93 prop_array_t datas)
94{ 94{
95 prop_array_t replies; 95 prop_array_t replies;
96 prop_dictionary_t data; 96 prop_dictionary_t data;
@@ -351,26 +351,27 @@ vfs_quotactl_set_extractinfo(prop_dictio @@ -351,26 +351,27 @@ vfs_quotactl_set_extractinfo(prop_dictio
351} 351}
352 352
353static int 353static int
354vfs_quotactl_set(struct mount *mp, 354vfs_quotactl_set(struct mount *mp,
355 prop_dictionary_t cmddict, int q2type, 355 prop_dictionary_t cmddict, int q2type,
356 prop_array_t datas) 356 prop_array_t datas)
357{ 357{
358 prop_array_t replies; 358 prop_array_t replies;
359 prop_object_iterator_t iter; 359 prop_object_iterator_t iter;
360 prop_dictionary_t data; 360 prop_dictionary_t data;
361 int defaultq; 361 int defaultq;
362 uint32_t id; 362 uint32_t id;
363 const char *idstr; 363 const char *idstr;
 364 struct quotakey qk;
364 struct quotaval blocks, files; 365 struct quotaval blocks, files;
365 struct vfs_quotactl_args args; 366 struct vfs_quotactl_args args;
366 int error; 367 int error;
367 368
368 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); 369 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
369 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); 370 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
370 371
371 replies = prop_array_create(); 372 replies = prop_array_create();
372 if (replies == NULL) 373 if (replies == NULL)
373 return ENOMEM; 374 return ENOMEM;
374 375
375 iter = prop_array_iterator(datas); 376 iter = prop_array_iterator(datas);
376 if (iter == NULL) { 377 if (iter == NULL) {
@@ -389,42 +390,44 @@ vfs_quotactl_set(struct mount *mp, @@ -389,42 +390,44 @@ vfs_quotactl_set(struct mount *mp,
389 if (strcmp(idstr, "default")) 390 if (strcmp(idstr, "default"))
390 continue; 391 continue;
391 id = 0; 392 id = 0;
392 defaultq = 1; 393 defaultq = 1;
393 } else { 394 } else {
394 defaultq = 0; 395 defaultq = 0;
395 } 396 }
396 397
397 error = vfs_quotactl_set_extractinfo(data, &blocks, &files); 398 error = vfs_quotactl_set_extractinfo(data, &blocks, &files);
398 if (error) { 399 if (error) {
399 goto err; 400 goto err;
400 } 401 }
401 402
 403 qk.qk_idtype = q2type;
 404 qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
 405 qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
 406
402 args.qc_type = QCT_SET; 407 args.qc_type = QCT_SET;
403 args.u.set.qc_idtype = q2type; 408 args.u.set.qc_key = &qk;
404 args.u.set.qc_id = id; 
405 args.u.set.qc_defaultq = defaultq; 
406 args.u.set.qc_objtype = QUOTA_OBJTYPE_BLOCKS; 
407 args.u.set.qc_val = &blocks; 409 args.u.set.qc_val = &blocks;
408 error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args); 410 error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
409 if (error) { 411 if (error) {
410 goto err; 412 goto err;
411 } 413 }
412 414
 415 qk.qk_idtype = q2type;
 416 qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
 417 qk.qk_objtype = QUOTA_OBJTYPE_FILES;
 418
413 args.qc_type = QCT_SET; 419 args.qc_type = QCT_SET;
414 args.u.set.qc_idtype = q2type; 420 args.u.set.qc_key = &qk;
415 args.u.set.qc_id = id; 
416 args.u.set.qc_defaultq = defaultq; 
417 args.u.set.qc_objtype = QUOTA_OBJTYPE_FILES; 
418 args.u.set.qc_val = &files; 421 args.u.set.qc_val = &files;
419 error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args); 422 error = VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
420 if (error) { 423 if (error) {
421 goto err; 424 goto err;
422 } 425 }
423 } 426 }
424 prop_object_iterator_release(iter); 427 prop_object_iterator_release(iter);
425 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 428 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
426 error = ENOMEM; 429 error = ENOMEM;
427 } else { 430 } else {
428 error = 0; 431 error = 0;
429 } 432 }
430 return error; 433 return error;

cvs diff -r1.11 -r1.12 src/sys/sys/quotactl.h (expand / switch to unified diff)

--- src/sys/sys/quotactl.h 2012/01/29 06:47:38 1.11
+++ src/sys/sys/quotactl.h 2012/01/29 06:48:50 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quotactl.h,v 1.11 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: quotactl.h,v 1.12 2012/01/29 06:48:50 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2011 The NetBSD Foundation, Inc. 3 * Copyright (c) 2011 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by David A. Holland. 7 * by David A. Holland.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -59,23 +59,20 @@ struct vfs_quotactl_args { @@ -59,23 +59,20 @@ struct vfs_quotactl_args {
59 struct { 59 struct {
60 prop_dictionary_t qc_cmddict; 60 prop_dictionary_t qc_cmddict;
61 int qc_q2type; 61 int qc_q2type;
62 prop_array_t qc_datas; 62 prop_array_t qc_datas;
63 } proplib; 63 } proplib;
64 struct { 64 struct {
65 int *qc_version_ret; 65 int *qc_version_ret;
66 } getversion; 66 } getversion;
67 struct { 67 struct {
68 const struct quotakey *qc_key; 68 const struct quotakey *qc_key;
69 struct quotaval *qc_ret; 69 struct quotaval *qc_ret;
70 } get; 70 } get;
71 struct { 71 struct {
72 int qc_idtype; 72 const struct quotakey *qc_key;
73 id_t qc_id; 
74 int qc_defaultq; 
75 int qc_objtype; 
76 const struct quotaval *qc_val; 73 const struct quotaval *qc_val;
77 } set; 74 } set;
78 } u; 75 } u;
79}; 76};
80 77
81#endif /* _SYS_QUOTACTL_H_ */ 78#endif /* _SYS_QUOTACTL_H_ */

cvs diff -r1.83 -r1.84 src/sys/ufs/ufs/ufs_quota.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:47:38 1.83
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:48:50 1.84
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.c,v 1.83 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: ufs_quota.c,v 1.84 2012/01/29 06:48:50 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993, 1995 4 * Copyright (c) 1982, 1986, 1990, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne. 8 * Robert Elz at The University of Melbourne.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.83 2012/01/29 06:47:38 dholland Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.84 2012/01/29 06:48:50 dholland Exp $");
39 39
40#if defined(_KERNEL_OPT) 40#if defined(_KERNEL_OPT)
41#include "opt_quota.h" 41#include "opt_quota.h"
42#endif  42#endif
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/namei.h> 46#include <sys/namei.h>
47#include <sys/file.h> 47#include <sys/file.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
49#include <sys/vnode.h> 49#include <sys/vnode.h>
50#include <sys/mount.h> 50#include <sys/mount.h>
51#include <sys/kauth.h> 51#include <sys/kauth.h>
@@ -258,59 +258,58 @@ quota_handle_cmd_get(struct mount *mp, s @@ -258,59 +258,58 @@ quota_handle_cmd_get(struct mount *mp, s
258 panic("quota_handle_cmd_get: no support ?"); 258 panic("quota_handle_cmd_get: no support ?");
259  259
260 if (error != 0) 260 if (error != 0)
261 return error; 261 return error;
262 262
263 return error; 263 return error;
264} 264}
265 265
266static int  266static int
267quota_handle_cmd_set(struct mount *mp, struct lwp *l,  267quota_handle_cmd_set(struct mount *mp, struct lwp *l,
268 struct vfs_quotactl_args *args) 268 struct vfs_quotactl_args *args)
269{ 269{
270 struct ufsmount *ump = VFSTOUFS(mp); 270 struct ufsmount *ump = VFSTOUFS(mp);
271 int idtype; 271 const struct quotakey *qk;
272 id_t id; 
273 int defaultq; 
274 int objtype; 
275 const struct quotaval *qv; 272 const struct quotaval *qv;
 273 id_t kauth_id;
276 int error; 274 int error;
277 275
278 KASSERT(args->qc_type == QCT_SET); 276 KASSERT(args->qc_type == QCT_SET);
279 idtype = args->u.set.qc_idtype; 277 qk = args->u.set.qc_key;
280 id = args->u.set.qc_id; 
281 defaultq = args->u.set.qc_defaultq; 
282 objtype = args->u.set.qc_objtype; 
283 qv = args->u.set.qc_val; 278 qv = args->u.set.qc_val;
284 279
285 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) 280 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
286 return EOPNOTSUPP; 281 return EOPNOTSUPP;
287 282
 283 kauth_id = qk->qk_id;
 284 if (kauth_id == QUOTA_DEFAULTID) {
 285 kauth_id = 0;
 286 }
 287
288 /* avoid whitespace changes */ 288 /* avoid whitespace changes */
289 { 289 {
290 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 290 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
291 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); 291 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(kauth_id),
 292 NULL);
292 if (error != 0) 293 if (error != 0)
293 goto err; 294 goto err;
294#ifdef QUOTA 295#ifdef QUOTA
295 if (ump->um_flags & UFS_QUOTA) 296 if (ump->um_flags & UFS_QUOTA)
296 error = quota1_handle_cmd_set(ump, idtype, id, defaultq, 297 error = quota1_handle_cmd_set(ump, qk, qv);
297 objtype, qv); 
298 else 298 else
299#endif 299#endif
300#ifdef QUOTA2 300#ifdef QUOTA2
301 if (ump->um_flags & UFS_QUOTA2) { 301 if (ump->um_flags & UFS_QUOTA2) {
302 error = quota2_handle_cmd_set(ump, idtype, id, defaultq, 302 error = quota2_handle_cmd_set(ump, qk, qv);
303 objtype, qv); 
304 } else 303 } else
305#endif 304#endif
306 panic("quota_handle_cmd_get: no support ?"); 305 panic("quota_handle_cmd_get: no support ?");
307  306
308 if (error && error != ENOENT) 307 if (error && error != ENOENT)
309 goto err; 308 goto err;
310 } 309 }
311 310
312 return 0; 311 return 0;
313 err: 312 err:
314 return error; 313 return error;
315} 314}
316 315

cvs diff -r1.8 -r1.9 src/sys/ufs/ufs/ufs_quota.h (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:47:38 1.8
+++ src/sys/ufs/ufs/ufs_quota.h 2012/01/29 06:48:50 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.h,v 1.8 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: ufs_quota.h,v 1.9 2012/01/29 06:48:50 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993, 1995 4 * Copyright (c) 1982, 1986, 1990, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne. 8 * Robert Elz at The University of Melbourne.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -105,30 +105,30 @@ const char *quotatypes[MAXQUOTAS]; @@ -105,30 +105,30 @@ const char *quotatypes[MAXQUOTAS];
105int getinoquota(struct inode *); 105int getinoquota(struct inode *);
106int dqget(struct vnode *, u_long, struct ufsmount *, int, struct dquot **); 106int dqget(struct vnode *, u_long, struct ufsmount *, int, struct dquot **);
107void dqref(struct dquot *); 107void dqref(struct dquot *);
108void dqrele(struct vnode *, struct dquot *); 108void dqrele(struct vnode *, struct dquot *);
109void dqflush(struct vnode *); 109void dqflush(struct vnode *);
110 110
111int chkdq1(struct inode *, int64_t, kauth_cred_t, int); 111int chkdq1(struct inode *, int64_t, kauth_cred_t, int);
112int chkiq1(struct inode *, int32_t, kauth_cred_t, int); 112int chkiq1(struct inode *, int32_t, kauth_cred_t, int);
113int q1sync(struct mount *); 113int q1sync(struct mount *);
114int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); 114int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
115int dq1sync(struct vnode *, struct dquot *); 115int dq1sync(struct vnode *, struct dquot *);
116int quota1_handle_cmd_get(struct ufsmount *, const struct quotakey *, 116int quota1_handle_cmd_get(struct ufsmount *, const struct quotakey *,
117 struct quotaval *); 117 struct quotaval *);
118int quota1_handle_cmd_set(struct ufsmount *, int, int, int, int, 118int quota1_handle_cmd_set(struct ufsmount *, const struct quotakey *,
119 const struct quotaval *); 119 const struct quotaval *);
120int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int, 120int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
121 const char *); 121 const char *);
122int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int); 122int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int);
123 123
124int chkdq2(struct inode *, int64_t, kauth_cred_t, int); 124int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
125int chkiq2(struct inode *, int32_t, kauth_cred_t, int); 125int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
126int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *, 126int quota2_handle_cmd_get(struct ufsmount *, const struct quotakey *,
127 struct quotaval *); 127 struct quotaval *);
128int quota2_handle_cmd_set(struct ufsmount *, int, int, int, int, 128int quota2_handle_cmd_set(struct ufsmount *, const struct quotakey *,
129 const struct quotaval *); 129 const struct quotaval *);
130int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t); 130int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t);
131int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t); 131int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t);
132int q2sync(struct mount *); 132int q2sync(struct mount *);
133int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); 133int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
134int dq2sync(struct vnode *, struct dquot *); 134int dq2sync(struct vnode *, struct dquot *);

cvs diff -r1.13 -r1.14 src/sys/ufs/ufs/ufs_quota1.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota1.c 2012/01/29 06:47:38 1.13
+++ src/sys/ufs/ufs/ufs_quota1.c 2012/01/29 06:48:51 1.14
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota1.c,v 1.13 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: ufs_quota1.c,v 1.14 2012/01/29 06:48:51 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993, 1995 4 * Copyright (c) 1982, 1986, 1990, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne. 8 * Robert Elz at The University of Melbourne.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.13 2012/01/29 06:47:38 dholland Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.14 2012/01/29 06:48:51 dholland Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/kernel.h> 41#include <sys/kernel.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/namei.h> 43#include <sys/namei.h>
44#include <sys/file.h> 44#include <sys/file.h>
45#include <sys/proc.h> 45#include <sys/proc.h>
46#include <sys/vnode.h> 46#include <sys/vnode.h>
47#include <sys/mount.h> 47#include <sys/mount.h>
48#include <sys/kauth.h> 48#include <sys/kauth.h>
49 49
50#include <quota/quotaprop.h> 50#include <quota/quotaprop.h>
51#include <ufs/ufs/quota1.h> 51#include <ufs/ufs/quota1.h>
@@ -543,106 +543,118 @@ quota1_handle_cmd_get(struct ufsmount *u @@ -543,106 +543,118 @@ quota1_handle_cmd_get(struct ufsmount *u
543 return 0; 543 return 0;
544} 544}
545 545
546static uint32_t 546static uint32_t
547quota1_encode_limit(uint64_t lim) 547quota1_encode_limit(uint64_t lim)
548{ 548{
549 if (lim == QUOTA_NOLIMIT || lim >= 0xffffffff) { 549 if (lim == QUOTA_NOLIMIT || lim >= 0xffffffff) {
550 return 0; 550 return 0;
551 } 551 }
552 return lim; 552 return lim;
553} 553}
554 554
555int 555int
556quota1_handle_cmd_set(struct ufsmount *ump, int idtype, int id, 556quota1_handle_cmd_set(struct ufsmount *ump, const struct quotakey *key,
557 int defaultq, int objtype, const struct quotaval *val) 557 const struct quotaval *val)
558{ 558{
559 struct dquot *dq; 559 struct dquot *dq;
560 struct dqblk dqb; 560 struct dqblk dqb;
561 int error; 561 int error;
562 562
563 switch (objtype) { 563 switch (key->qk_idtype) {
 564 case QUOTA_IDTYPE_USER:
 565 case QUOTA_IDTYPE_GROUP:
 566 break;
 567 default:
 568 return EINVAL;
 569 }
 570
 571 switch (key->qk_objtype) {
564 case QUOTA_OBJTYPE_BLOCKS: 572 case QUOTA_OBJTYPE_BLOCKS:
565 case QUOTA_OBJTYPE_FILES: 573 case QUOTA_OBJTYPE_FILES:
566 break; 574 break;
567 default: 575 default:
568 return EINVAL; 576 return EINVAL;
569 } 577 }
570 578
571 if (ump->um_quotas[idtype] == NULLVP) 579 if (ump->um_quotas[key->qk_idtype] == NULLVP)
572 return ENODEV; 580 return ENODEV;
573 581
574 if (defaultq) { 582 if (key->qk_id == QUOTA_DEFAULTID) {
575 /* just update grace times */ 583 /* just update grace times */
576 KASSERT(id == 0); 584 id_t id = 0;
577 if ((error = dqget(NULLVP, id, ump, idtype, &dq)) != 0) 585
 586 if ((error = dqget(NULLVP, id, ump, key->qk_idtype, &dq)) != 0)
578 return error; 587 return error;
579 mutex_enter(&dq->dq_interlock); 588 mutex_enter(&dq->dq_interlock);
580 if (objtype == QUOTA_OBJTYPE_BLOCKS && val->qv_grace > 0) 589 if (val->qv_grace != QUOTA_NOTIME) {
581 ump->umq1_btime[idtype] = dq->dq_btime = 590 if (key->qk_objtype == QUOTA_OBJTYPE_BLOCKS)
582 val->qv_grace; 591 ump->umq1_btime[key->qk_idtype] = dq->dq_btime =
583 if (objtype == QUOTA_OBJTYPE_FILES && val->qv_grace > 0) 592 val->qv_grace;
584 ump->umq1_itime[idtype] = dq->dq_itime = 593 if (key->qk_objtype == QUOTA_OBJTYPE_FILES)
585 val->qv_grace; 594 ump->umq1_itime[key->qk_idtype] = dq->dq_itime =
586 mutex_exit(&dq->dq_interlock); 595 val->qv_grace;
 596 }
587 dq->dq_flags |= DQ_MOD; 597 dq->dq_flags |= DQ_MOD;
 598 mutex_exit(&dq->dq_interlock);
588 dqrele(NULLVP, dq); 599 dqrele(NULLVP, dq);
589 return 0; 600 return 0;
590 } 601 }
591 602
592 if ((error = dqget(NULLVP, id, ump, idtype, &dq)) != 0) 603 if ((error = dqget(NULLVP, key->qk_id, ump, key->qk_idtype, &dq)) != 0)
593 return (error); 604 return (error);
594 mutex_enter(&dq->dq_interlock); 605 mutex_enter(&dq->dq_interlock);
595 /* 606 /*
596 * Copy all but the current values. 607 * Copy all but the current values.
597 * Reset time limit if previously had no soft limit or were 608 * Reset time limit if previously had no soft limit or were
598 * under it, but now have a soft limit and are over it. 609 * under it, but now have a soft limit and are over it.
599 */ 610 */
600 dqb.dqb_curblocks = dq->dq_curblocks; 611 dqb.dqb_curblocks = dq->dq_curblocks;
601 dqb.dqb_curinodes = dq->dq_curinodes; 612 dqb.dqb_curinodes = dq->dq_curinodes;
602 dqb.dqb_btime = dq->dq_btime; 613 dqb.dqb_btime = dq->dq_btime;
603 dqb.dqb_itime = dq->dq_itime; 614 dqb.dqb_itime = dq->dq_itime;
604 switch (objtype) { 615 switch (key->qk_objtype) {
605 case QUOTA_OBJTYPE_BLOCKS: 616 case QUOTA_OBJTYPE_BLOCKS:
606 dqb.dqb_bsoftlimit = quota1_encode_limit(val->qv_softlimit); 617 dqb.dqb_bsoftlimit = quota1_encode_limit(val->qv_softlimit);
607 dqb.dqb_bhardlimit = quota1_encode_limit(val->qv_hardlimit); 618 dqb.dqb_bhardlimit = quota1_encode_limit(val->qv_hardlimit);
608 dqb.dqb_isoftlimit = dq->dq_isoftlimit; 619 dqb.dqb_isoftlimit = dq->dq_isoftlimit;
609 dqb.dqb_ihardlimit = dq->dq_ihardlimit; 620 dqb.dqb_ihardlimit = dq->dq_ihardlimit;
610 break; 621 break;
611 case QUOTA_OBJTYPE_FILES: 622 case QUOTA_OBJTYPE_FILES:
612 dqb.dqb_bsoftlimit = dq->dq_bsoftlimit; 623 dqb.dqb_bsoftlimit = dq->dq_bsoftlimit;
613 dqb.dqb_bhardlimit = dq->dq_bhardlimit; 624 dqb.dqb_bhardlimit = dq->dq_bhardlimit;
614 dqb.dqb_isoftlimit = quota1_encode_limit(val->qv_softlimit); 625 dqb.dqb_isoftlimit = quota1_encode_limit(val->qv_softlimit);
615 dqb.dqb_ihardlimit = quota1_encode_limit(val->qv_hardlimit); 626 dqb.dqb_ihardlimit = quota1_encode_limit(val->qv_hardlimit);
616 break; 627 break;
617 } 628 }
618 if (dq->dq_id == 0 && val->qv_grace != QUOTA_NOTIME) { 629 if (dq->dq_id == 0 && val->qv_grace != QUOTA_NOTIME) {
619 /* also update grace time if available */ 630 /* also update grace time if available */
620 if (objtype == QUOTA_OBJTYPE_BLOCKS) { 631 if (key->qk_objtype == QUOTA_OBJTYPE_BLOCKS) {
621 ump->umq1_btime[idtype] = dqb.dqb_btime = val->qv_grace; 632 ump->umq1_btime[key->qk_idtype] = dqb.dqb_btime =
622  633 val->qv_grace;
623 } 634 }
624 if (objtype == QUOTA_OBJTYPE_FILES) { 635 if (key->qk_objtype == QUOTA_OBJTYPE_FILES) {
625 ump->umq1_itime[idtype] = dqb.dqb_itime = val->qv_grace; 636 ump->umq1_itime[key->qk_idtype] = dqb.dqb_itime =
 637 val->qv_grace;
626 } 638 }
627 } 639 }
628 if (dqb.dqb_bsoftlimit && 640 if (dqb.dqb_bsoftlimit &&
629 dq->dq_curblocks >= dqb.dqb_bsoftlimit && 641 dq->dq_curblocks >= dqb.dqb_bsoftlimit &&
630 (dq->dq_bsoftlimit == 0 || dq->dq_curblocks < dq->dq_bsoftlimit)) 642 (dq->dq_bsoftlimit == 0 || dq->dq_curblocks < dq->dq_bsoftlimit))
631 dqb.dqb_btime = time_second + ump->umq1_btime[idtype]; 643 dqb.dqb_btime = time_second + ump->umq1_btime[key->qk_idtype];
632 if (dqb.dqb_isoftlimit && 644 if (dqb.dqb_isoftlimit &&
633 dq->dq_curinodes >= dqb.dqb_isoftlimit && 645 dq->dq_curinodes >= dqb.dqb_isoftlimit &&
634 (dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit)) 646 (dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit))
635 dqb.dqb_itime = time_second + ump->umq1_itime[idtype]; 647 dqb.dqb_itime = time_second + ump->umq1_itime[key->qk_idtype];
636 dq->dq_un.dq1_dqb = dqb; 648 dq->dq_un.dq1_dqb = dqb;
637 if (dq->dq_curblocks < dq->dq_bsoftlimit) 649 if (dq->dq_curblocks < dq->dq_bsoftlimit)
638 dq->dq_flags &= ~DQ_WARN(QL_BLOCK); 650 dq->dq_flags &= ~DQ_WARN(QL_BLOCK);
639 if (dq->dq_curinodes < dq->dq_isoftlimit) 651 if (dq->dq_curinodes < dq->dq_isoftlimit)
640 dq->dq_flags &= ~DQ_WARN(QL_FILE); 652 dq->dq_flags &= ~DQ_WARN(QL_FILE);
641 if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 && 653 if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 &&
642 dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0) 654 dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0)
643 dq->dq_flags |= DQ_FAKE; 655 dq->dq_flags |= DQ_FAKE;
644 else 656 else
645 dq->dq_flags &= ~DQ_FAKE; 657 dq->dq_flags &= ~DQ_FAKE;
646 dq->dq_flags |= DQ_MOD; 658 dq->dq_flags |= DQ_MOD;
647 mutex_exit(&dq->dq_interlock); 659 mutex_exit(&dq->dq_interlock);
648 dqrele(NULLVP, dq); 660 dqrele(NULLVP, dq);

cvs diff -r1.9 -r1.10 src/sys/ufs/ufs/ufs_quota2.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:47:38 1.9
+++ src/sys/ufs/ufs/ufs_quota2.c 2012/01/29 06:48:51 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota2.c,v 1.9 2012/01/29 06:47:38 dholland Exp $ */ 1/* $NetBSD: ufs_quota2.c,v 1.10 2012/01/29 06:48:51 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2010 Manuel Bouyer 3 * Copyright (c) 2010 Manuel Bouyer
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.9 2012/01/29 06:47:38 dholland Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.10 2012/01/29 06:48:51 dholland Exp $");
30 30
31#include <sys/buf.h> 31#include <sys/buf.h>
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kernel.h> 33#include <sys/kernel.h>
34#include <sys/systm.h> 34#include <sys/systm.h>
35#include <sys/malloc.h> 35#include <sys/malloc.h>
36#include <sys/namei.h> 36#include <sys/namei.h>
37#include <sys/file.h> 37#include <sys/file.h>
38#include <sys/proc.h> 38#include <sys/proc.h>
39#include <sys/vnode.h> 39#include <sys/vnode.h>
40#include <sys/mount.h> 40#include <sys/mount.h>
41#include <sys/fstrans.h> 41#include <sys/fstrans.h>
42#include <sys/kauth.h> 42#include <sys/kauth.h>
@@ -601,76 +601,81 @@ quota2_check(struct inode *ip, int vtype @@ -601,76 +601,81 @@ quota2_check(struct inode *ip, int vtype
601int 601int
602chkdq2(struct inode *ip, int64_t change, kauth_cred_t cred, int flags) 602chkdq2(struct inode *ip, int64_t change, kauth_cred_t cred, int flags)
603{ 603{
604 return quota2_check(ip, QL_BLOCK, change, cred, flags); 604 return quota2_check(ip, QL_BLOCK, change, cred, flags);
605} 605}
606 606
607int 607int
608chkiq2(struct inode *ip, int32_t change, kauth_cred_t cred, int flags) 608chkiq2(struct inode *ip, int32_t change, kauth_cred_t cred, int flags)
609{ 609{
610 return quota2_check(ip, QL_FILE, change, cred, flags); 610 return quota2_check(ip, QL_FILE, change, cred, flags);
611} 611}
612 612
613int 613int
614quota2_handle_cmd_set(struct ufsmount *ump, int type, int id, 614quota2_handle_cmd_set(struct ufsmount *ump, const struct quotakey *key,
615 int defaultq, int objtype, const struct quotaval *val) 615 const struct quotaval *val)
616{ 616{
617 int error; 617 int error;
618 struct dquot *dq; 618 struct dquot *dq;
619 struct quota2_header *q2h; 619 struct quota2_header *q2h;
620 struct quota2_entry q2e, *q2ep; 620 struct quota2_entry q2e, *q2ep;
621 struct buf *bp; 621 struct buf *bp;
622 const int needswap = UFS_MPNEEDSWAP(ump); 622 const int needswap = UFS_MPNEEDSWAP(ump);
623 623
624 if (ump->um_quotas[type] == NULLVP) 624 /* make sure we can index by the fs-independent idtype */
 625 CTASSERT(QUOTA_IDTYPE_USER == USRQUOTA);
 626 CTASSERT(QUOTA_IDTYPE_GROUP == GRPQUOTA);
 627
 628 if (ump->um_quotas[key->qk_idtype] == NULLVP)
625 return ENODEV; 629 return ENODEV;
626 error = UFS_WAPBL_BEGIN(ump->um_mountp); 630 error = UFS_WAPBL_BEGIN(ump->um_mountp);
627 if (error) 631 if (error)
628 return error; 632 return error;
629  633
630 if (defaultq) { 634 if (key->qk_id == QUOTA_DEFAULTID) {
631 mutex_enter(&dqlock); 635 mutex_enter(&dqlock);
632 error = getq2h(ump, type, &bp, &q2h, B_MODIFY); 636 error = getq2h(ump, key->qk_idtype, &bp, &q2h, B_MODIFY);
633 if (error) { 637 if (error) {
634 mutex_exit(&dqlock); 638 mutex_exit(&dqlock);
635 goto out_wapbl; 639 goto out_wapbl;
636 } 640 }
637 quota2_ufs_rwq2e(&q2h->q2h_defentry, &q2e, needswap); 641 quota2_ufs_rwq2e(&q2h->q2h_defentry, &q2e, needswap);
638 quota2_dict_update_q2e_limits(objtype, val, &q2e); 642 quota2_dict_update_q2e_limits(key->qk_objtype, val, &q2e);
639 quota2_ufs_rwq2e(&q2e, &q2h->q2h_defentry, needswap); 643 quota2_ufs_rwq2e(&q2e, &q2h->q2h_defentry, needswap);
640 mutex_exit(&dqlock); 644 mutex_exit(&dqlock);
641 quota2_bwrite(ump->um_mountp, bp); 645 quota2_bwrite(ump->um_mountp, bp);
642 goto out_wapbl; 646 goto out_wapbl;
643 } 647 }
644 648
645 error = dqget(NULLVP, id, ump, type, &dq); 649 error = dqget(NULLVP, key->qk_id, ump, key->qk_idtype, &dq);
646 if (error) 650 if (error)
647 goto out_wapbl; 651 goto out_wapbl;
648 652
649 mutex_enter(&dq->dq_interlock); 653 mutex_enter(&dq->dq_interlock);
650 if (dq->dq2_lblkno == 0 && dq->dq2_blkoff == 0) { 654 if (dq->dq2_lblkno == 0 && dq->dq2_blkoff == 0) {
651 /* need to alloc a new on-disk quot */ 655 /* need to alloc a new on-disk quot */
652 mutex_enter(&dqlock); 656 mutex_enter(&dqlock);
653 error = quota2_q2ealloc(ump, type, id, dq, &bp, &q2ep); 657 error = quota2_q2ealloc(ump, key->qk_idtype, key->qk_id, dq,
 658 &bp, &q2ep);
654 mutex_exit(&dqlock); 659 mutex_exit(&dqlock);
655 } else { 660 } else {
656 error = getq2e(ump, type, dq->dq2_lblkno, dq->dq2_blkoff, 661 error = getq2e(ump, key->qk_idtype, dq->dq2_lblkno,
657 &bp, &q2ep, B_MODIFY); 662 dq->dq2_blkoff, &bp, &q2ep, B_MODIFY);
658 } 663 }
659 if (error) 664 if (error)
660 goto out_il; 665 goto out_il;
661  666
662 quota2_ufs_rwq2e(q2ep, &q2e, needswap); 667 quota2_ufs_rwq2e(q2ep, &q2e, needswap);
663 quota2_dict_update_q2e_limits(objtype, val, &q2e); 668 quota2_dict_update_q2e_limits(key->qk_objtype, val, &q2e);
664 quota2_ufs_rwq2e(&q2e, q2ep, needswap); 669 quota2_ufs_rwq2e(&q2e, q2ep, needswap);
665 quota2_bwrite(ump->um_mountp, bp); 670 quota2_bwrite(ump->um_mountp, bp);
666 671
667out_il: 672out_il:
668 mutex_exit(&dq->dq_interlock); 673 mutex_exit(&dq->dq_interlock);
669 dqrele(NULLVP, dq); 674 dqrele(NULLVP, dq);
670out_wapbl: 675out_wapbl:
671 UFS_WAPBL_END(ump->um_mountp); 676 UFS_WAPBL_END(ump->um_mountp);
672 return error; 677 return error;
673} 678}
674 679
675struct dq2clear_callback { 680struct dq2clear_callback {
676 uid_t id; 681 uid_t id;