Module Name: src Committed By: dholland Date: Sun Jan 29 06:32:44 UTC 2012
Modified Files: src/sys/kern: vfs_quotactl.c vfs_subr.c src/sys/miscfs/genfs: layer_extern.h layer_vfsops.c src/sys/sys: mount.h src/sys/ufs/ufs: ufs_extern.h ufs_vfsops.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.426 -r1.427 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.29 -r1.30 src/sys/miscfs/genfs/layer_extern.h cvs rdiff -u -r1.34 -r1.35 src/sys/miscfs/genfs/layer_vfsops.c cvs rdiff -u -r1.202 -r1.203 src/sys/sys/mount.h cvs rdiff -u -r1.66 -r1.67 src/sys/ufs/ufs/ufs_extern.h cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ufs/ufs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_quotactl.c diff -u src/sys/kern/vfs_quotactl.c:1.2 src/sys/kern/vfs_quotactl.c:1.3 --- src/sys/kern/vfs_quotactl.c:1.2 Sun Jan 29 06:29:05 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 06:32:43 2012 @@ -1,4 +1,41 @@ -/* $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 @@ -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; } Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.426 src/sys/kern/vfs_subr.c:1.427 --- src/sys/kern/vfs_subr.c:1.426 Fri Dec 2 12:32:38 2011 +++ src/sys/kern/vfs_subr.c Sun Jan 29 06:32:43 2012 @@ -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 @@ VFS_ROOT(struct mount *mp, struct vnode } 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); } Index: src/sys/miscfs/genfs/layer_extern.h diff -u src/sys/miscfs/genfs/layer_extern.h:1.29 src/sys/miscfs/genfs/layer_extern.h:1.30 --- src/sys/miscfs/genfs/layer_extern.h:1.29 Mon Jul 11 08:27:38 2011 +++ src/sys/miscfs/genfs/layer_extern.h Sun Jan 29 06:32:44 2012 @@ -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 @@ struct vnode *layer_node_find(struct mou /* 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 **); Index: src/sys/miscfs/genfs/layer_vfsops.c diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.34 src/sys/miscfs/genfs/layer_vfsops.c:1.35 --- src/sys/miscfs/genfs/layer_vfsops.c:1.34 Sun Mar 6 17:08:36 2011 +++ src/sys/miscfs/genfs/layer_vfsops.c Sun Jan 29 06:32:44 2012 @@ -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 @@ layerfs_root(struct mount *mp, struct vn } 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 Index: src/sys/sys/mount.h diff -u src/sys/sys/mount.h:1.202 src/sys/sys/mount.h:1.203 --- src/sys/sys/mount.h:1.202 Sun Jan 29 06:29:04 2012 +++ src/sys/sys/mount.h Sun Jan 29 06:32:43 2012 @@ -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 @@ struct vfsops { 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_MOUNT(struct mount *, const char 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 **); Index: src/sys/ufs/ufs/ufs_extern.h diff -u src/sys/ufs/ufs/ufs_extern.h:1.66 src/sys/ufs/ufs/ufs_extern.h:1.67 --- src/sys/ufs/ufs/ufs_extern.h:1.66 Sun Jul 17 22:07:59 2011 +++ src/sys/ufs/ufs/ufs_extern.h Sun Jan 29 06:32:44 2012 @@ -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_reinit(void); 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 */ Index: src/sys/ufs/ufs/ufs_vfsops.c diff -u src/sys/ufs/ufs/ufs_vfsops.c:1.43 src/sys/ufs/ufs/ufs_vfsops.c:1.44 --- src/sys/ufs/ufs/ufs_vfsops.c:1.43 Fri Jan 27 19:22:50 2012 +++ src/sys/ufs/ufs/ufs_vfsops.c Sun Jan 29 06:32:44 2012 @@ -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 @@ ufs_root(struct mount *mp, struct vnode * 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