Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Move second-layer proplib frobbing within ufs quota code up ...
details: https://anonhg.NetBSD.org/src/rev/071571fa0134
branches: trunk
changeset: 773169:071571fa0134
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jan 29 06:38:23 2012 +0000
description:
Move second-layer proplib frobbing within ufs quota code up to the
first layer. (Step 2 of several for QUOTACTL_GET.)
diffstat:
include/quota.h | 3 -
sys/sys/quota.h | 5 ++-
sys/ufs/ufs/ufs_quota.c | 44 +++++++++++++++++++---
sys/ufs/ufs/ufs_quota.h | 8 ++-
sys/ufs/ufs/ufs_quota1.c | 46 ++++++++--------------
sys/ufs/ufs/ufs_quota2.c | 94 ++++++++++++++++++++++++++++++++++++++++++-----
6 files changed, 148 insertions(+), 52 deletions(-)
diffs (truncated from 395 to 300 lines):
diff -r 7140b7fda492 -r 071571fa0134 include/quota.h
--- a/include/quota.h Sun Jan 29 06:37:30 2012 +0000
+++ b/include/quota.h Sun Jan 29 06:38:23 2012 +0000
@@ -44,9 +44,6 @@
#define QUOTA_OBJTYPE_BLOCKS 0
#define QUOTA_OBJTYPE_FILES 1
-/* id value for "default" */
-#define QUOTA_DEFAULTID ((id_t)-1)
-
/* limit value for "no limit" */
#define QUOTA_NOLIMIT ((uint64_t)0xffffffffffffffffULL)
diff -r 7140b7fda492 -r 071571fa0134 sys/sys/quota.h
--- a/sys/sys/quota.h Sun Jan 29 06:37:30 2012 +0000
+++ b/sys/sys/quota.h Sun Jan 29 06:38:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota.h,v 1.7 2012/01/01 15:41:16 dholland Exp $ */
+/* $NetBSD: quota.h,v 1.8 2012/01/29 06:38:23 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -30,6 +30,9 @@
#include <sys/types.h>
+/* id value for "default" */
+#define QUOTA_DEFAULTID ((id_t)-1)
+
/*
* Structure used to describe the value part of a quota record.
*/
diff -r 7140b7fda492 -r 071571fa0134 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:37:30 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c Sun Jan 29 06:38:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.c,v 1.74 2012/01/29 06:37:30 dholland Exp $ */
+/* $NetBSD: ufs_quota.c,v 1.75 2012/01/29 06:38:24 dholland 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.74 2012/01/29 06:37:30 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.75 2012/01/29 06:38:24 dholland Exp $");
#if defined(_KERNEL_OPT)
#include "opt_quota.h"
@@ -226,6 +226,33 @@
KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, KAUTH_ARG(id), NULL);
}
+static int
+quota_fill_cmd_get_reply(id_t id,
+ int defaultq,
+ const struct quotaval *blocks,
+ const struct quotaval *files,
+ prop_array_t replies)
+{
+ prop_dictionary_t dict;
+
+ /* XXX illegal casts */
+ uint64_t *valuesp[QUOTA_NLIMITS];
+ valuesp[QUOTA_LIMIT_BLOCK] = (void *)(intptr_t)&blocks->qv_hardlimit;
+ valuesp[QUOTA_LIMIT_FILE] = (void *)(intptr_t)&files->qv_hardlimit;
+
+ dict = quota64toprop(id, defaultq, valuesp,
+ ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
+ ufs_quota_limit_names, QUOTA_NLIMITS);
+ if (dict == NULL)
+ return ENOMEM;
+ if (!prop_array_add_and_rel(replies, dict)) {
+ prop_object_release(dict);
+ return ENOMEM;
+ }
+
+ return 0;
+}
+
static int
quota_handle_cmd_get(struct mount *mp, struct lwp *l,
struct vfs_quotactl_args *args)
@@ -236,6 +263,7 @@
int q2type;
int defaultq;
prop_array_t replies;
+ struct quotaval blocks, files;
KASSERT(args->qc_type == QCT_GET);
id = args->u.get.qc_id;
@@ -251,21 +279,25 @@
if (error != 0)
return error;
#ifdef QUOTA
- if (ump->um_flags & UFS_QUOTA)
+ if (ump->um_flags & UFS_QUOTA) {
error = quota1_handle_cmd_get(ump, q2type, id, defaultq,
- replies);
- else
+ &blocks, &files);
+ } else
#endif
#ifdef QUOTA2
if (ump->um_flags & UFS_QUOTA2) {
error = quota2_handle_cmd_get(ump, q2type, id, defaultq,
- replies);
+ &blocks, &files);
} else
#endif
panic("quota_handle_cmd_get: no support ?");
if (error != 0)
return error;
+
+ error = quota_fill_cmd_get_reply(id, defaultq,
+ &blocks, &files,
+ replies);
}
return error;
diff -r 7140b7fda492 -r 071571fa0134 sys/ufs/ufs/ufs_quota.h
--- a/sys/ufs/ufs/ufs_quota.h Sun Jan 29 06:37:30 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.h Sun Jan 29 06:38:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.h,v 1.2 2011/03/06 17:08:39 bouyer Exp $ */
+/* $NetBSD: ufs_quota.h,v 1.3 2012/01/29 06:38:24 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -113,7 +113,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_get(struct ufsmount *, int, int, int,
+ struct quotaval *, struct quotaval *);
int quota1_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
const char *);
@@ -121,7 +122,8 @@
int chkdq2(struct inode *, int64_t, kauth_cred_t, int);
int chkiq2(struct inode *, int32_t, kauth_cred_t, int);
-int quota2_handle_cmd_get(struct ufsmount *, int, int, int, prop_array_t);
+int quota2_handle_cmd_get(struct ufsmount *, int, int, int,
+ struct quotaval *, struct quotaval *);
int quota2_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
int quota2_handle_cmd_clear(struct ufsmount *, int, int, int, prop_dictionary_t);
int quota2_handle_cmd_getall(struct ufsmount *, int, prop_array_t);
diff -r 7140b7fda492 -r 071571fa0134 sys/ufs/ufs/ufs_quota1.c
--- a/sys/ufs/ufs/ufs_quota1.c Sun Jan 29 06:37:30 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota1.c Sun Jan 29 06:38:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota1.c,v 1.7 2012/01/29 06:23:20 dholland Exp $ */
+/* $NetBSD: ufs_quota1.c,v 1.8 2012/01/29 06:38:24 dholland 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.7 2012/01/29 06:23:20 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.8 2012/01/29 06:38:24 dholland Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -493,51 +493,39 @@
}
int
-quota1_handle_cmd_get(struct ufsmount *ump, int type, int id,
- int defaultq, prop_array_t replies)
+quota1_handle_cmd_get(struct ufsmount *ump, int idtype, int id,
+ int defaultq, struct quotaval *blocks, struct quotaval *files)
{
struct dquot *dq;
- struct quotaval qv[QUOTA_NLIMITS];
- prop_dictionary_t dict;
int error;
uint64_t *valuesp[QUOTA_NLIMITS];
- valuesp[QUOTA_LIMIT_BLOCK] = &qv[QUOTA_LIMIT_BLOCK].qv_hardlimit;
- valuesp[QUOTA_LIMIT_FILE] = &qv[QUOTA_LIMIT_FILE].qv_hardlimit;
+ valuesp[QUOTA_LIMIT_BLOCK] = &blocks->qv_hardlimit;
+ valuesp[QUOTA_LIMIT_FILE] = &files->qv_hardlimit;
- if (ump->um_quotas[type] == NULLVP)
+ if (ump->um_quotas[idtype] == NULLVP)
return ENODEV;
if (defaultq) { /* we want the grace period of id 0 */
- if ((error = dqget(NULLVP, 0, ump, type, &dq)) != 0)
+ if ((error = dqget(NULLVP, 0, ump, idtype, &dq)) != 0)
return error;
} else {
- if ((error = dqget(NULLVP, id, ump, type, &dq)) != 0)
+ if ((error = dqget(NULLVP, id, ump, idtype, &dq)) != 0)
return error;
}
- dqblk_to_quotavals(&dq->dq_un.dq1_dqb,
- &qv[QUOTA_LIMIT_BLOCK], &qv[QUOTA_LIMIT_FILE]);
+ dqblk_to_quotavals(&dq->dq_un.dq1_dqb, blocks, files);
dqrele(NULLVP, dq);
if (defaultq) {
- if (qv[QUOTA_LIMIT_BLOCK].qv_expiretime > 0)
- qv[QUOTA_LIMIT_BLOCK].qv_grace =
- qv[QUOTA_LIMIT_BLOCK].qv_expiretime;
- else
- qv[QUOTA_LIMIT_BLOCK].qv_grace = MAX_DQ_TIME;
- if (qv[QUOTA_LIMIT_FILE].qv_expiretime > 0)
- qv[QUOTA_LIMIT_FILE].qv_grace =
- qv[QUOTA_LIMIT_FILE].qv_expiretime;
+ if (blocks->qv_expiretime > 0)
+ blocks->qv_grace = blocks->qv_expiretime;
else
- qv[QUOTA_LIMIT_FILE].qv_grace = MAX_DQ_TIME;
+ blocks->qv_grace = MAX_DQ_TIME;
+ if (files->qv_expiretime > 0)
+ files->qv_grace = files->qv_expiretime;
+ else
+ files->qv_grace = MAX_DQ_TIME;
}
- dict = quota64toprop(id, defaultq, valuesp,
- ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
- ufs_quota_limit_names, QUOTA_NLIMITS);
- if (dict == NULL)
- return ENOMEM;
- if (!prop_array_add_and_rel(replies, dict))
- return ENOMEM;
return 0;
}
diff -r 7140b7fda492 -r 071571fa0134 sys/ufs/ufs/ufs_quota2.c
--- a/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 06:37:30 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 06:38:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.4 2011/06/07 14:56:13 bouyer Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.5 2012/01/29 06:38:24 dholland Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.4 2011/06/07 14:56:13 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.5 2012/01/29 06:38:24 dholland Exp $");
#include <sys/buf.h>
#include <sys/param.h>
@@ -41,6 +41,7 @@
#include <sys/fstrans.h>
#include <sys/kauth.h>
#include <sys/wapbl.h>
+#include <sys/quota.h>
#include <ufs/ufs/quota2.h>
#include <ufs/ufs/inode.h>
@@ -76,6 +77,8 @@
static int quota2_dict_update_q2e_limits(prop_dictionary_t,
struct quota2_entry *);
static prop_dictionary_t q2etoprop(struct quota2_entry *, int);
+static void q2e_to_quotavals(struct quota2_entry *, int, id_t *,
+ struct quotaval *, struct quotaval *);
static const char *limnames[] = INITQLNAMES;
@@ -135,6 +138,41 @@
return NULL;
}
+/*
+ * Convert internal representation to FS-independent representation.
+ * (Note that while the two types are currently identical, the
+ * internal representation is an on-disk struct and the FS-independent
+ * representation is not, and they might diverge in the future.)
+ */
+static void
+q2val_to_quotaval(struct quota2_val *q2v, struct quotaval *qv)
+{
+ qv->qv_softlimit = q2v->q2v_softlimit;
+ qv->qv_hardlimit = q2v->q2v_hardlimit;
+ qv->qv_usage = q2v->q2v_cur;
+ qv->qv_expiretime = q2v->q2v_time;
+ qv->qv_grace = q2v->q2v_grace;
+}
+
+/*
+ * Convert a quota2entry and default-flag to the FS-independent
+ * representation.
+ */
+static void
+q2e_to_quotavals(struct quota2_entry *q2e, int def,
+ id_t *id, struct quotaval *blocks, struct quotaval *files)
+{
+ if (def) {
Home |
Main Index |
Thread Index |
Old Index