Source-Changes-HG archive

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

[src/trunk]: src/sys Introduce struct vfs_quotactl_args. Use it.



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

description:
Introduce struct vfs_quotactl_args. Use it.

This change uglifies vfs_quotactl some in order to make room for
moving operation-specific but FS-independent logic out of ufs_quota.c.

Note: this change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c         |  121 +++++++++++++++++++++++++++++---
 sys/kern/vfs_subr.c             |    9 +-
 sys/miscfs/genfs/layer_extern.h |    4 +-
 sys/miscfs/genfs/layer_vfsops.c |   10 +-
 sys/sys/mount.h                 |   10 +-
 sys/sys/quotactl.h              |   17 ++++-
 sys/ufs/ufs/ufs_extern.h        |    6 +-
 sys/ufs/ufs/ufs_quota.c         |  145 ++++++++++++++++++++++++++++++---------
 sys/ufs/ufs/ufs_vfsops.c        |   14 +--
 9 files changed, 256 insertions(+), 80 deletions(-)

diffs (truncated from 742 to 300 lines):

diff -r 08de58454a08 -r fe73a76c06b0 sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $        */
+/*     $NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $        */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,18 +80,115 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $");
 
 #include <sys/mount.h>
 #include <sys/quotactl.h>
 #include <quota/quotaprop.h>
 
 static int
+vfs_quotactl_getversion(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
+}
+
+static int
+vfs_quotactl_quotaon(struct mount *mp,
+                    prop_dictionary_t cmddict, int q2type,
+                    prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args);
+}
+
+static int
+vfs_quotactl_quotaoff(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args);
+}
+
+static int
+vfs_quotactl_get(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
+}
+
+static int
+vfs_quotactl_set(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
+}
+
+static int
+vfs_quotactl_getall(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_GETALL, &args);
+}
+
+static int
+vfs_quotactl_clear(struct mount *mp,
+                       prop_dictionary_t cmddict, int q2type,
+                       prop_array_t datas)
+{
+       struct vfs_quotactl_args args;
+
+       args.qc_type = QCT_PROPLIB;
+       args.u.proplib.qc_cmddict = cmddict;
+       args.u.proplib.qc_q2type = q2type;
+       args.u.proplib.qc_datas = datas;
+       return VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args);
+}
+
+static int
 vfs_quotactl_cmd(struct mount *mp, prop_dictionary_t cmddict)
 {
        int error;
        const char *cmd, *type;
-       int op;
        prop_array_t datas;
        int q2type;
 
@@ -117,28 +214,24 @@
        prop_dictionary_remove(cmddict, "data"); /* prepare for return */
 
        if (strcmp(cmd, "get version") == 0) {
-               op = QUOTACTL_GETVERSION;
+               error = vfs_quotactl_getversion(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "quotaon") == 0) {
-               op = QUOTACTL_QUOTAON;
+               error = vfs_quotactl_quotaon(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "quotaoff") == 0) {
-               op = QUOTACTL_QUOTAOFF;
+               error = vfs_quotactl_quotaoff(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "get") == 0) {
-               op = QUOTACTL_GET;
+               error = vfs_quotactl_get(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "set") == 0) {
-               op = QUOTACTL_SET;
+               error = vfs_quotactl_set(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "getall") == 0) {
-               op = QUOTACTL_GETALL;
+               error = vfs_quotactl_getall(mp, cmddict, q2type, datas);
        } else if (strcmp(cmd, "clear") == 0) {
-               op = QUOTACTL_CLEAR;
+               error = vfs_quotactl_clear(mp, cmddict, q2type, datas);
        } else {
                /* XXX this a bad errno for this case */
                error = EOPNOTSUPP;
-               goto fail;
        }
 
-       error = VFS_QUOTACTL(mp, op, cmddict, q2type, datas);
-
- fail:
        error = (prop_dictionary_set_int8(cmddict, "return",
            error) ? 0 : ENOMEM);
        prop_object_release(datas);
diff -r 08de58454a08 -r fe73a76c06b0 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/kern/vfs_subr.c       Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.428 2012/01/29 06:34:57 dholland Exp $  */
+/*     $NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 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.428 2012/01/29 06:34:57 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -1006,15 +1006,14 @@
 }
 
 int
-VFS_QUOTACTL(struct mount *mp, int op, prop_dictionary_t cmddict, int objtype,
-            prop_array_t datas)
+VFS_QUOTACTL(struct mount *mp, int op, struct vfs_quotactl_args *args)
 {
        int error;
 
        if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
                KERNEL_LOCK(1, NULL);
        }
-       error = (*(mp->mnt_op->vfs_quotactl))(mp, op, cmddict, objtype, datas);
+       error = (*(mp->mnt_op->vfs_quotactl))(mp, op, args);
        if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
                KERNEL_UNLOCK_ONE(NULL);
        }
diff -r 08de58454a08 -r fe73a76c06b0 sys/miscfs/genfs/layer_extern.h
--- a/sys/miscfs/genfs/layer_extern.h   Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/miscfs/genfs/layer_extern.h   Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_extern.h,v 1.31 2012/01/29 06:34:58 dholland Exp $       */
+/*     $NetBSD: layer_extern.h,v 1.32 2012/01/29 06:36:06 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 *, int, prop_dictionary_t, int, prop_array_t);
+int    layerfs_quotactl(struct mount *, int, struct vfs_quotactl_args *);
 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 **);
diff -r 08de58454a08 -r fe73a76c06b0 sys/miscfs/genfs/layer_vfsops.c
--- a/sys/miscfs/genfs/layer_vfsops.c   Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/miscfs/genfs/layer_vfsops.c   Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_vfsops.c,v 1.36 2012/01/29 06:34:58 dholland Exp $       */
+/*     $NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 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.36 2012/01/29 06:34:58 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -141,12 +141,10 @@
 }
 
 int
-layerfs_quotactl(struct mount *mp, int op, prop_dictionary_t dict, int objtype,
-                prop_array_t datas)
+layerfs_quotactl(struct mount *mp, int op, struct vfs_quotactl_args *args)
 {
 
-       return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, dict,
-                           objtype, datas);
+       return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, args);
 }
 
 int
diff -r 08de58454a08 -r fe73a76c06b0 sys/sys/mount.h
--- a/sys/sys/mount.h   Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/sys/mount.h   Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mount.h,v 1.204 2012/01/29 06:34:57 dholland Exp $     */
+/*     $NetBSD: mount.h,v 1.205 2012/01/29 06:36:06 dholland Exp $     */
 
 /*
  * Copyright (c) 1989, 1991, 1993
@@ -192,6 +192,7 @@
 
 #if defined(_KERNEL)
 #include <prop/proplib.h>
+struct vfs_quotactl_args;
 #if __STDC__
 struct nameidata;
 #endif
@@ -208,8 +209,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 *, int, prop_dictionary_t, int,
-                                   prop_array_t);
+       int     (*vfs_quotactl) (struct mount *, int, struct vfs_quotactl_args *);
        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 **);
@@ -244,7 +244,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 *, int, prop_dictionary_t, int, prop_array_t);
+int    VFS_QUOTACTL(struct mount *, int, struct vfs_quotactl_args *);
 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 **);
@@ -270,7 +270,7 @@
 int    fsname##_start(struct mount *, int);                            \
 int    fsname##_unmount(struct mount *, int);                          \
 int    fsname##_root(struct mount *, struct vnode **);                 \
-int    fsname##_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t);   \
+int    fsname##_quotactl(struct mount *, int, struct vfs_quotactl_args *);     \
 int    fsname##_statvfs(struct mount *, struct statvfs *);             \
 int    fsname##_sync(struct mount *, int, struct kauth_cred *);        \
 int    fsname##_vget(struct mount *, ino_t, struct vnode **);          \
diff -r 08de58454a08 -r fe73a76c06b0 sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 06:34:57 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 06:36:06 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.2 2012/01/29 06:34:57 dholland Exp $    */



Home | Main Index | Thread Index | Old Index