Sun Jan 29 06:32:44 2012 UTC ()
Move the code for iterating over the multiple RPC calls in a quota
proplib XML packet to vfs_quotactl.c out of sys/ufs/ufs.
Add a dummy extra arg to VFS_QUOTACTL for compile safety.
Note: this change requires a kernel version bump.
(dholland)
diff -r1.2 -r1.3 src/sys/kern/vfs_quotactl.c
diff -r1.426 -r1.427 src/sys/kern/vfs_subr.c
diff -r1.29 -r1.30 src/sys/miscfs/genfs/layer_extern.h
diff -r1.34 -r1.35 src/sys/miscfs/genfs/layer_vfsops.c
diff -r1.202 -r1.203 src/sys/sys/mount.h
diff -r1.66 -r1.67 src/sys/ufs/ufs/ufs_extern.h
diff -r1.43 -r1.44 src/sys/ufs/ufs/ufs_vfsops.c
--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:29:05 1.2
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:32:43 1.3
@@ -1,6 +1,43 @@
-/* $NetBSD: vfs_quotactl.c,v 1.2 2012/01/29 06:29:05 dholland Exp $ */
+/* $NetBSD: vfs_quotactl.c,v 1.3 2012/01/29 06:32:43 dholland Exp $ */
/*
+ * Copyright (c) 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95
+ * From NetBSD: ufs_vfsops.c,v 1.42 2011/03/24 17:05:46 bouyer Exp
+ */
+
+/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
* The Regents of the University of California. All rights reserved.
*
@@ -32,16 +69,50 @@
* SUCH DAMAGE.
*
* @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
- * From ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp
+ * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp
*/
+/*
+ * Note that both of the copyrights above are moderately spurious;
+ * this code should almost certainly have the Copyright 2010 Manuel
+ * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c.
+ * However, they're what was on the files this code was sliced out of.
+ */
+
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.2 2012/01/29 06:29:05 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.3 2012/01/29 06:32:43 dholland Exp $");
#include <sys/mount.h>
+#include <quota/quotaprop.h>
int
vfs_quotactl(struct mount *mp, prop_dictionary_t dict)
{
- return VFS_QUOTACTL(mp, dict);
+ prop_dictionary_t cmddict;
+ prop_array_t commands;
+ prop_object_iterator_t iter;
+ int error;
+
+ error = quota_get_cmds(dict, &commands);
+ if (error) {
+ return error;
+ }
+
+ iter = prop_array_iterator(commands);
+ if (iter == NULL) {
+ return ENOMEM;
+ }
+
+ while ((cmddict = prop_object_iterator_next(iter)) != NULL) {
+ if (prop_object_type(cmddict) != PROP_TYPE_DICTIONARY) {
+ /* XXX shouldn't this be an error? */
+ continue;
+ }
+ error = VFS_QUOTACTL(mp, cmddict, 0/*dummy*/);
+ if (error) {
+ break;
+ }
+ }
+ prop_object_iterator_release(iter);
+ return error;
}
--- src/sys/kern/vfs_subr.c 2011/12/02 12:32:38 1.426
+++ src/sys/kern/vfs_subr.c 2012/01/29 06:32:43 1.427
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.426 2011/12/02 12:32:38 yamt Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.427 2012/01/29 06:32:43 dholland Exp $ */
/*-
* Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.426 2011/12/02 12:32:38 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.427 2012/01/29 06:32:43 dholland Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -1006,14 +1006,14 @@
}
int
-VFS_QUOTACTL(struct mount *mp, prop_dictionary_t dict)
+VFS_QUOTACTL(struct mount *mp, prop_dictionary_t dict, int dummy)
{
int error;
if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
KERNEL_LOCK(1, NULL);
}
- error = (*(mp->mnt_op->vfs_quotactl))(mp, dict);
+ error = (*(mp->mnt_op->vfs_quotactl))(mp, dict, dummy);
if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
KERNEL_UNLOCK_ONE(NULL);
}
--- src/sys/miscfs/genfs/layer_extern.h 2011/07/11 08:27:38 1.29
+++ src/sys/miscfs/genfs/layer_extern.h 2012/01/29 06:32:44 1.30
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_extern.h,v 1.29 2011/07/11 08:27:38 hannken Exp $ */
+/* $NetBSD: layer_extern.h,v 1.30 2012/01/29 06:32:44 dholland Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -88,7 +88,7 @@
/* VFS routines */
int layerfs_start(struct mount *, int);
int layerfs_root(struct mount *, struct vnode **);
-int layerfs_quotactl(struct mount *, prop_dictionary_t);
+int layerfs_quotactl(struct mount *, prop_dictionary_t, int);
int layerfs_statvfs(struct mount *, struct statvfs *);
int layerfs_sync(struct mount *, int, struct kauth_cred *);
int layerfs_vget(struct mount *, ino_t, struct vnode **);
--- src/sys/miscfs/genfs/layer_vfsops.c 2011/03/06 17:08:36 1.34
+++ src/sys/miscfs/genfs/layer_vfsops.c 2012/01/29 06:32:44 1.35
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_vfsops.c,v 1.34 2011/03/06 17:08:36 bouyer Exp $ */
+/* $NetBSD: layer_vfsops.c,v 1.35 2012/01/29 06:32:44 dholland Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.34 2011/03/06 17:08:36 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.35 2012/01/29 06:32:44 dholland Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -141,10 +141,10 @@
}
int
-layerfs_quotactl(struct mount *mp, prop_dictionary_t dict)
+layerfs_quotactl(struct mount *mp, prop_dictionary_t dict, int dummy)
{
- return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, dict);
+ return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, dict, dummy);
}
int
--- src/sys/sys/mount.h 2012/01/29 06:29:04 1.202
+++ src/sys/sys/mount.h 2012/01/29 06:32:43 1.203
@@ -1,4 +1,4 @@
-/* $NetBSD: mount.h,v 1.202 2012/01/29 06:29:04 dholland Exp $ */
+/* $NetBSD: mount.h,v 1.203 2012/01/29 06:32:43 dholland Exp $ */
/*
* Copyright (c) 1989, 1991, 1993
@@ -208,7 +208,7 @@
int (*vfs_start) (struct mount *, int);
int (*vfs_unmount) (struct mount *, int);
int (*vfs_root) (struct mount *, struct vnode **);
- int (*vfs_quotactl) (struct mount *, prop_dictionary_t);
+ int (*vfs_quotactl) (struct mount *, prop_dictionary_t, int);
int (*vfs_statvfs) (struct mount *, struct statvfs *);
int (*vfs_sync) (struct mount *, int, struct kauth_cred *);
int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
@@ -243,7 +243,7 @@
int VFS_START(struct mount *, int);
int VFS_UNMOUNT(struct mount *, int);
int VFS_ROOT(struct mount *, struct vnode **);
-int VFS_QUOTACTL(struct mount *, prop_dictionary_t);
+int VFS_QUOTACTL(struct mount *, prop_dictionary_t, int);
int VFS_STATVFS(struct mount *, struct statvfs *);
int VFS_SYNC(struct mount *, int, struct kauth_cred *);
int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **);
--- src/sys/ufs/ufs/ufs_extern.h 2011/07/17 22:07:59 1.66
+++ src/sys/ufs/ufs/ufs_extern.h 2012/01/29 06:32:44 1.67
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_extern.h,v 1.66 2011/07/17 22:07:59 dholland Exp $ */
+/* $NetBSD: ufs_extern.h,v 1.67 2012/01/29 06:32:44 dholland Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -163,7 +163,7 @@
void ufs_done(void);
int ufs_start(struct mount *, int);
int ufs_root(struct mount *, struct vnode **);
-int ufs_quotactl(struct mount *, prop_dictionary_t);
+int ufs_quotactl(struct mount *, prop_dictionary_t, int);
int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **);
/* ufs_vnops.c */
--- src/sys/ufs/ufs/ufs_vfsops.c 2012/01/27 19:22:50 1.43
+++ src/sys/ufs/ufs/ufs_vfsops.c 2012/01/29 06:32:44 1.44
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_vfsops.c,v 1.43 2012/01/27 19:22:50 para Exp $ */
+/* $NetBSD: ufs_vfsops.c,v 1.44 2012/01/29 06:32:44 dholland Exp $ */
/*
* Copyright (c) 1991, 1993, 1994
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.43 2012/01/27 19:22:50 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.44 2012/01/29 06:32:44 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -100,47 +100,31 @@
* Do operations associated with quotas
*/
int
-ufs_quotactl(struct mount *mp, prop_dictionary_t dict)
+ufs_quotactl(struct mount *mp, prop_dictionary_t cmddict, int dummy)
{
struct lwp *l = curlwp;
#if !defined(QUOTA) && !defined(QUOTA2)
(void) mp;
- (void) dict;
+ (void) cmddict;
+ (void) dummy;
(void) l;
return (EOPNOTSUPP);
#else
int error;
- prop_dictionary_t cmddict;
- prop_array_t commands;
- prop_object_iterator_t iter;
+ KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
+
/* Mark the mount busy, as we're passing it to kauth(9). */
error = vfs_busy(mp, NULL);
- if (error)
+ if (error) {
return (error);
-
- error = quota_get_cmds(dict, &commands);
- if (error)
- goto out_vfs;
- iter = prop_array_iterator(commands);
- if (iter == NULL) {
- error = ENOMEM;
- goto out_vfs;
}
-
-
mutex_enter(&mp->mnt_updating);
- while ((cmddict = prop_object_iterator_next(iter)) != NULL) {
- if (prop_object_type(cmddict) != PROP_TYPE_DICTIONARY)
- continue;
- error = quota_handle_cmd(mp, l, cmddict);
- if (error)
- break;
- }
- prop_object_iterator_release(iter);
+
+ error = quota_handle_cmd(mp, l, cmddict);
+
mutex_exit(&mp->mnt_updating);
-out_vfs:
vfs_unbusy(mp, false, NULL);
return (error);
#endif