Module Name:    src
Committed By:   bouyer
Date:           Tue Feb  8 20:00:54 UTC 2011

Modified Files:
        src/sys/ufs/ffs [bouyer-quota2]: ffs_vfsops.c
        src/sys/ufs/ufs [bouyer-quota2]: ufs_extern.h ufs_quota.c ufs_quota.h
            ufs_quota1.c ufs_quota2.c

Log Message:
Minimal hacking to make 'options QUOTA' compile again.


To generate a diff of this commit:
cvs rdiff -u -r1.263.4.1 -r1.263.4.2 src/sys/ufs/ffs/ffs_vfsops.c
cvs rdiff -u -r1.62.8.1 -r1.62.8.2 src/sys/ufs/ufs/ufs_extern.h
cvs rdiff -u -r1.68.4.8 -r1.68.4.9 src/sys/ufs/ufs/ufs_quota.c
cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/ufs/ufs/ufs_quota.h
cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/sys/ufs/ufs/ufs_quota2.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/ufs/ffs/ffs_vfsops.c
diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.263.4.1 src/sys/ufs/ffs/ffs_vfsops.c:1.263.4.2
--- src/sys/ufs/ffs/ffs_vfsops.c:1.263.4.1	Thu Jan 20 14:25:02 2011
+++ src/sys/ufs/ffs/ffs_vfsops.c	Tue Feb  8 20:00:53 2011
@@ -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);

Index: src/sys/ufs/ufs/ufs_extern.h
diff -u src/sys/ufs/ufs/ufs_extern.h:1.62.8.1 src/sys/ufs/ufs/ufs_extern.h:1.62.8.2
--- src/sys/ufs/ufs/ufs_extern.h:1.62.8.1	Thu Jan 20 14:25:03 2011
+++ src/sys/ufs/ufs/ufs_extern.h	Tue Feb  8 20:00:53 2011
@@ -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);

Index: src/sys/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.68.4.8 src/sys/ufs/ufs/ufs_quota.c:1.68.4.9
--- src/sys/ufs/ufs/ufs_quota.c:1.68.4.8	Mon Feb  7 20:30:39 2011
+++ src/sys/ufs/ufs/ufs_quota.c	Tue Feb  8 20:00:53 2011
@@ -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

Index: src/sys/ufs/ufs/ufs_quota.h
diff -u src/sys/ufs/ufs/ufs_quota.h:1.1.2.5 src/sys/ufs/ufs/ufs_quota.h:1.1.2.6
--- src/sys/ufs/ufs/ufs_quota.h:1.1.2.5	Mon Feb  7 20:30:39 2011
+++ src/sys/ufs/ufs/ufs_quota.h	Tue Feb  8 20:00:53 2011
@@ -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);

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.1.2.2 src/sys/ufs/ufs/ufs_quota1.c:1.1.2.3
--- src/sys/ufs/ufs/ufs_quota1.c:1.1.2.2	Mon Jan 31 15:24:10 2011
+++ src/sys/ufs/ufs/ufs_quota1.c	Tue Feb  8 20:00:53 2011
@@ -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.
+ * turn off disk quotas for a filesystem.
  */
-int
+static int
 quotaoff(struct lwp *l, struct mount *mp, int type)
 {
 	struct vnode *vp;
@@ -476,6 +498,22 @@
 	return (error);
 }
 
+int             
+quota1_handle_cmd_get(struct ufsmount *ump, int type, int id,
+    int defaultq, prop_array_t replies)
+{
+	return EOPNOTSUPP;
+}
+
+int
+quota1_handle_cmd_set(struct ufsmount *ump, int type, int id,
+    int defaultq, prop_dictionary_t data)
+{
+	return EOPNOTSUPP;
+}
+
+
+#if 0
 /*
  * Q_GETQUOTA - return current values in a dqblk structure.
  */
@@ -487,7 +525,7 @@
 
 	if ((error = dqget(NULLVP, id, VFSTOUFS(mp), type, &dq)) != 0)
 		return (error);
-	memcpy(dqb, (void *)&dq->dq_dqb, sizeof (struct dqblk));
+	memcpy(dqb, (void *)&dq->dq_un.dq1_dqb, sizeof (struct dqblk));
 	dqrele(NULLVP, dq);
 	return (error);
 }
@@ -526,11 +564,11 @@
 	    dq->dq_curinodes >= dqb->dqb_isoftlimit &&
 	    (dq->dq_isoftlimit == 0 || dq->dq_curinodes < dq->dq_isoftlimit))
 		dqb->dqb_itime = time_second + ump->umq1_itime[type];
-	dq->dq_dqb = *dqb;
+	dq->dq_un.dq1_dqb = *dqb;
 	if (dq->dq_curblocks < dq->dq_bsoftlimit)
-		dq->dq_flags &= ~DQ_BLKS;
+		dq->dq_flags &= ~DQ_WARN(QL_BLOCK);
 	if (dq->dq_curinodes < dq->dq_isoftlimit)
-		dq->dq_flags &= ~DQ_INODS;
+		dq->dq_flags &= ~DQ_WARN(QL_FILE);
 	if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 &&
 	    dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0)
 		dq->dq_flags |= DQ_FAKE;
@@ -574,14 +612,15 @@
 	dq->dq_curblocks = usage.dqb_curblocks;
 	dq->dq_curinodes = usage.dqb_curinodes;
 	if (dq->dq_curblocks < dq->dq_bsoftlimit)
-		dq->dq_flags &= ~DQ_BLKS;
+		dq->dq_flags &= ~DQ_WARN(QL_BLOCK);
 	if (dq->dq_curinodes < dq->dq_isoftlimit)
-		dq->dq_flags &= ~DQ_INODS;
+		dq->dq_flags &= ~DQ_WARN(QL_FILE);
 	dq->dq_flags |= DQ_MOD;
 	mutex_exit(&dq->dq_interlock);
 	dqrele(NULLVP, dq);
 	return (0);
 }
+#endif
 
 /*
  * Q_SYNC - sync quota files to disk.
@@ -655,18 +694,18 @@
  * reading the information from the file if necessary.
  */
 int
-dq1get(struct vnode *dqvp, , u_long id, struct ufsmount *ump, int type,
+dq1get(struct vnode *dqvp, u_long id, struct ufsmount *ump, int type,
     struct dquot *dq)
 {
 	struct iovec aiov;
 	struct uio auio;
 	int error;
 
-	KASSERT(mutex_locked(&dq->dq_interlock);
+	KASSERT(mutex_locked(&dq->dq_interlock));
 	vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY);
 	auio.uio_iov = &aiov;
 	auio.uio_iovcnt = 1;
-	aiov.iov_base = (void *)&dq->dq_dqb;
+	aiov.iov_base = (void *)&dq->dq_un.dq1_dqb;
 	aiov.iov_len = sizeof (struct dqblk);
 	auio.uio_resid = sizeof (struct dqblk);
 	auio.uio_offset = (off_t)(id * sizeof (struct dqblk));
@@ -674,7 +713,7 @@
 	UIO_SETUP_SYSSPACE(&auio);
 	error = VOP_READ(dqvp, &auio, 0, ump->um_cred[type]);
 	if (auio.uio_resid == sizeof(struct dqblk) && error == 0)
-		memset((void *)&dq->dq_dqb, 0, sizeof(struct dqblk));
+		memset((void *)&dq->dq_un.dq1_dqb, 0, sizeof(struct dqblk));
 	VOP_UNLOCK(dqvp);
 	/*
 	 * I/O error in reading quota file, release
@@ -720,7 +759,7 @@
 	vn_lock(dqvp, LK_EXCLUSIVE | LK_RETRY);
 	auio.uio_iov = &aiov;
 	auio.uio_iovcnt = 1;
-	aiov.iov_base = (void *)&dq->dq_dqb;
+	aiov.iov_base = (void *)&dq->dq_un.dq1_dqb;
 	aiov.iov_len = sizeof (struct dqblk);
 	auio.uio_resid = sizeof (struct dqblk);
 	auio.uio_offset = (off_t)(dq->dq_id * sizeof (struct dqblk));

Index: src/sys/ufs/ufs/ufs_quota2.c
diff -u src/sys/ufs/ufs/ufs_quota2.c:1.1.2.9 src/sys/ufs/ufs/ufs_quota2.c:1.1.2.10
--- src/sys/ufs/ufs/ufs_quota2.c:1.1.2.9	Mon Feb  7 20:30:39 2011
+++ src/sys/ufs/ufs/ufs_quota2.c	Tue Feb  8 20:00:53 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.1.2.9 2011/02/07 20:30:39 bouyer Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.1.2.10 2011/02/08 20:00:53 bouyer Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -28,7 +28,7 @@
   */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.1.2.9 2011/02/07 20:30:39 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.1.2.10 2011/02/08 20:00:53 bouyer Exp $");
 
 #include <sys/buf.h>
 #include <sys/param.h>
@@ -199,12 +199,15 @@
 	return ret;
 }
 
-void
-quota2_umount(struct mount *mp)
+int
+quota2_umount(struct mount *mp, int flags)
 {
 	int i, error;
 	struct ufsmount *ump = VFSTOUFS(mp);
 
+	if ((ump->um_flags & UFS_QUOTA2) == 0)
+		return 0;
+
 	for (i = 0; i < MAXQUOTAS; i++) {
 		if (ump->um_quotas[i]) {
 			error = vn_close(ump->um_quotas[i], FREAD|FWRITE,
@@ -212,9 +215,11 @@
 			if (error) {
 				printf("quota2_umount failed: close(%p) %d\n",
 				    ump->um_quotas[i], error);
+				return error;
 			}
 		}
 	}
+	return 0;
 }
 
 static int 
@@ -322,13 +327,12 @@
 	}
 	/* now get the corresponding quota entry */
 	for (i = 0; i < MAXQUOTAS; i++) {
-		struct vnode *dqvp = ump->um_quotas[i];
 		bpp[i] = NULL;
 		q2ep[i] = NULL;
 		dq = ip->i_dquot[i];
 		if (dq == NODQUOT)
 			continue;
-		KASSERT(dqvp != NULL);
+		KASSERT(ump->um_quotas[i] != NULL);
 
 		if ((dq->dq2_lblkno | dq->dq2_blkoff) == 0) {
 			if (alloc == 0) {

Reply via email to