Source-Changes-HG archive

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

[src/bouyer-quota2]: src/sys/ufs Minimal hacking to make 'options QUOTA' comp...



details:   https://anonhg.NetBSD.org/src/rev/f0f54f4fc023
branches:  bouyer-quota2
changeset: 761124:f0f54f4fc023
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Feb 08 20:00:53 2011 +0000

description:
Minimal hacking to make 'options QUOTA' compile again.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |   23 ++-------
 sys/ufs/ufs/ufs_extern.h |    7 ++-
 sys/ufs/ufs/ufs_quota.c  |   10 ++-
 sys/ufs/ufs/ufs_quota.h  |    8 ++-
 sys/ufs/ufs/ufs_quota1.c |  101 ++++++++++++++++++++++++++++++++--------------
 sys/ufs/ufs/ufs_quota2.c |   16 ++++--
 6 files changed, 102 insertions(+), 63 deletions(-)

diffs (truncated from 475 to 300 lines):

diff -r 19a962856579 -r f0f54f4fc023 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Tue Feb 08 19:29:29 2011 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Tue Feb 08 20:00:53 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.263.4.1 2011/01/20 14:25:02 bouyer Exp $      */
+/*     $NetBSD: ffs_vfsops.c,v 1.263.4.2 2011/02/08 20:00:53 bouyer Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.263.4.1 2011/01/20 14:25:02 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.263.4.2 2011/02/08 20:00:53 bouyer Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -1474,23 +1474,12 @@
                flags &= ~FORCECLOSE;
        ump = VFSTOUFS(mp);
 #ifdef QUOTA
-       if (mp->mnt_flag & MNT_QUOTA) {
-               int i;
-               if ((error = vflush(mp, NULLVP, SKIPSYSTEM | flags)) != 0)
-                       return (error);
-               for (i = 0; i < MAXQUOTAS; i++) {
-                       if (ump->um_quotas[i] == NULLVP)
-                               continue;
-                       quotaoff(l, mp, i);
-               }
-               /*
-                * Here we fall through to vflush again to ensure
-                * that we have gotten rid of all the system vnodes.
-                */
-       }
+       if ((error = quota1_umount(mp, flags)) != 0)
+               return (error);
 #endif
 #ifdef QUOTA2
-       quota2_umount(mp);
+       if ((error = quota2_umount(mp, flags)) != 0)
+               return (error);
 #endif
        if ((error = vflush(mp, 0, SKIPSYSTEM | flags)) != 0)
                return (error);
diff -r 19a962856579 -r f0f54f4fc023 sys/ufs/ufs/ufs_extern.h
--- a/sys/ufs/ufs/ufs_extern.h  Tue Feb 08 19:29:29 2011 +0000
+++ b/sys/ufs/ufs/ufs_extern.h  Tue Feb 08 20:00:53 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_extern.h,v 1.62.8.1 2011/01/20 14:25:03 bouyer Exp $       */
+/*     $NetBSD: ufs_extern.h,v 1.62.8.2 2011/02/08 20:00:53 bouyer Exp $       */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -144,8 +144,11 @@
 int    quota_handle_cmd(struct mount *, struct lwp *, prop_dictionary_t);
 int    qsync(struct mount *);
 
+/* ufs_quota1.c */
+int    quota1_umount(struct mount *, int);
+
 /* ufs_quota2.c */
-void   quota2_umount(struct mount *);
+int    quota2_umount(struct mount *, int);
 
 /* ufs_vfsops.c */
 void   ufs_init(void);
diff -r 19a962856579 -r f0f54f4fc023 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c   Tue Feb 08 19:29:29 2011 +0000
+++ b/sys/ufs/ufs/ufs_quota.c   Tue Feb 08 20:00:53 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.c,v 1.68.4.8 2011/02/07 20:30:39 bouyer Exp $        */
+/*     $NetBSD: ufs_quota.c,v 1.68.4.9 2011/02/08 20:00:53 bouyer Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.68.4.8 2011/02/07 20:30:39 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.68.4.9 2011/02/08 20:00:53 bouyer Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -284,7 +284,8 @@
                }
 #ifdef QUOTA
                if (ump->um_flags & UFS_QUOTA)
-                       error = quota1_handle_cmd_get(ump, type, id, replies)
+                       error = quota1_handle_cmd_get(ump, type, id, defaultq,
+                           replies);
                else
 #endif
 #ifdef QUOTA2
@@ -352,7 +353,8 @@
                }
 #ifdef QUOTA
                if (ump->um_flags & UFS_QUOTA)
-                       error = quota1_handle_cmd_get(ump, type, id, data);
+                       error = quota1_handle_cmd_set(ump, type, id, defaultq,
+                           data);
                else
 #endif
 #ifdef QUOTA2
diff -r 19a962856579 -r f0f54f4fc023 sys/ufs/ufs/ufs_quota.h
--- a/sys/ufs/ufs/ufs_quota.h   Tue Feb 08 19:29:29 2011 +0000
+++ b/sys/ufs/ufs/ufs_quota.h   Tue Feb 08 20:00:53 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.h,v 1.1.2.5 2011/02/07 20:30:39 bouyer Exp $ */
+/*     $NetBSD: ufs_quota.h,v 1.1.2.6 2011/02/08 20:00:53 bouyer Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -83,8 +83,8 @@
 #define        dq_ihardlimit   dq_un.dq1_dqb.dqb_ihardlimit
 #define        dq_isoftlimit   dq_un.dq1_dqb.dqb_isoftlimit
 #define        dq_curinodes    dq_un.dq1_dqb.dqb_curinodes
-#define        dq_btime        dq_un.dq_dqb.dqb_btime
-#define        dq_itime        dq_un.dq_dqb.dqb_itime
+#define        dq_btime        dq_un.dq1_dqb.dqb_btime
+#define        dq_itime        dq_un.dq1_dqb.dqb_itime
 
 #define dq2_lblkno     dq_un.dq2_desc.dq2_lblkno
 #define dq2_blkoff     dq_un.dq2_desc.dq2_blkoff
@@ -124,6 +124,8 @@
 int q1sync(struct mount *);
 int dq1get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *);
 int dq1sync(struct vnode *, struct dquot *);
+int quota1_handle_cmd_get(struct ufsmount *, int, int, int, prop_array_t);
+int quota1_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
 
 int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
 int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
diff -r 19a962856579 -r f0f54f4fc023 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c  Tue Feb 08 19:29:29 2011 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c  Tue Feb 08 20:00:53 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota1.c,v 1.1.2.2 2011/01/31 15:24:10 bouyer Exp $        */
+/*     $NetBSD: ufs_quota1.c,v 1.1.2.3 2011/02/08 20:00:53 bouyer Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.1.2.2 2011/01/31 15:24:10 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.1.2.3 2011/02/08 20:00:53 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -47,16 +47,15 @@
 #include <sys/mount.h>
 #include <sys/kauth.h>
 
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/ufs_quota.h>
+#include <ufs/ufs/quota1.h>
 #include <ufs/ufs/inode.h>
 #include <ufs/ufs/ufsmount.h>
 #include <ufs/ufs/ufs_extern.h>
+#include <ufs/ufs/ufs_quota.h>
 
 static int chkdqchg(struct inode *, int64_t, kauth_cred_t, int);
 static int chkiqchg(struct inode *, int32_t, kauth_cred_t, int);
-static void dqref(struct dquot *);
-static void dqrele(struct vnode *, struct dquot *); 
+static int quotaoff(struct lwp *, struct mount *, int);
 
 /*
  * Update disk usage, and take corrective action.
@@ -82,7 +81,7 @@
                                dq->dq_curblocks = ncurblocks;
                        else
                                dq->dq_curblocks = 0;
-                       dq->dq_flags &= ~DQ_BLKS;
+                       dq->dq_flags &= ~DQ_WARN(QL_BLOCK);
                        dq->dq_flags |= DQ_MOD;
                        mutex_exit(&dq->dq_interlock);
                }
@@ -128,12 +127,12 @@
         * If user would exceed their hard limit, disallow space allocation.
         */
        if (ncurblocks >= dq->dq_bhardlimit && dq->dq_bhardlimit) {
-               if ((dq->dq_flags & DQ_BLKS) == 0 &&
+               if ((dq->dq_flags & DQ_WARN(QL_BLOCK)) == 0 &&
                    ip->i_uid == kauth_cred_geteuid(cred)) {
                        uprintf("\n%s: write failed, %s disk limit reached\n",
                            ITOV(ip)->v_mount->mnt_stat.f_mntonname,
                            quotatypes[type]);
-                       dq->dq_flags |= DQ_BLKS;
+                       dq->dq_flags |= DQ_WARN(QL_BLOCK);
                }
                return (EDQUOT);
        }
@@ -152,13 +151,13 @@
                        return (0);
                }
                if (time_second > dq->dq_btime) {
-                       if ((dq->dq_flags & DQ_BLKS) == 0 &&
+                       if ((dq->dq_flags & DQ_WARN(QL_BLOCK)) == 0 &&
                            ip->i_uid == kauth_cred_geteuid(cred)) {
                                uprintf("\n%s: write failed, %s %s\n",
                                    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
                                    quotatypes[type],
                                    "disk quota exceeded for too long");
-                               dq->dq_flags |= DQ_BLKS;
+                               dq->dq_flags |= DQ_WARN(QL_BLOCK);
                        }
                        return (EDQUOT);
                }
@@ -190,7 +189,7 @@
                                dq->dq_curinodes = ncurinodes;
                        else
                                dq->dq_curinodes = 0;
-                       dq->dq_flags &= ~DQ_INODS;
+                       dq->dq_flags &= ~DQ_WARN(QL_FILE);
                        dq->dq_flags |= DQ_MOD;
                        mutex_exit(&dq->dq_interlock);
                }
@@ -235,12 +234,12 @@
         * If user would exceed their hard limit, disallow inode allocation.
         */
        if (ncurinodes >= dq->dq_ihardlimit && dq->dq_ihardlimit) {
-               if ((dq->dq_flags & DQ_INODS) == 0 &&
+               if ((dq->dq_flags & DQ_WARN(QL_FILE)) == 0 &&
                    ip->i_uid == kauth_cred_geteuid(cred)) {
                        uprintf("\n%s: write failed, %s inode limit reached\n",
                            ITOV(ip)->v_mount->mnt_stat.f_mntonname,
                            quotatypes[type]);
-                       dq->dq_flags |= DQ_INODS;
+                       dq->dq_flags |= DQ_WARN(QL_FILE);
                }
                return (EDQUOT);
        }
@@ -259,13 +258,13 @@
                        return (0);
                }
                if (time_second > dq->dq_itime) {
-                       if ((dq->dq_flags & DQ_INODS) == 0 &&
+                       if ((dq->dq_flags & DQ_WARN(QL_FILE)) == 0 &&
                            ip->i_uid == kauth_cred_geteuid(cred)) {
                                uprintf("\n%s: write failed, %s %s\n",
                                    ITOV(ip)->v_mount->mnt_stat.f_mntonname,
                                    quotatypes[type],
                                    "inode quota exceeded for too long");
-                               dq->dq_flags |= DQ_INODS;
+                               dq->dq_flags |= DQ_WARN(QL_FILE);
                        }
                        return (EDQUOT);
                }
@@ -273,14 +272,36 @@
        return (0);
 }
 
+int
+quota1_umount(struct mount *mp, int flags)
+{
+       int i, error;
+       struct ufsmount *ump = VFSTOUFS(mp);
+       struct lwp *l = curlwp;
+
+       if ((ump->um_flags & UFS_QUOTA) == 0)
+               return 0;
+
+       if ((error = vflush(mp, NULLVP, SKIPSYSTEM | flags)) != 0)
+               return (error);
+
+       for (i = 0; i < MAXQUOTAS; i++) {
+               if (ump->um_quotas[i] != NULLVP) {
+                       quotaoff(l, mp, i);
+               }
+       }
+       return 0;
+}
+
 /*
  * Code to process quotactl commands.
  */
 
+#if 0
 /*
- * Q_QUOTAON - set up a quota file for a particular file system.
+ * set up a quota file for a particular file system.
  */
-int
+static int
 quotaon(struct lwp *l, struct mount *mp, int type, void *fname)
 {
        struct ufsmount *ump = VFSTOUFS(mp);
@@ -396,11 +417,12 @@
                quotaoff(l, mp, type);
        return (error);
 }
+#endif
 
 /*
- * Q_QUOTAOFF - turn off disk quotas for a filesystem.



Home | Main Index | Thread Index | Old Index