Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/sys/ufs/ufs Introduce quota2_ufs_rwq2v() and quota2_...
details: https://anonhg.NetBSD.org/src/rev/b1367d46a096
branches: bouyer-quota2
changeset: 761073:b1367d46a096
user: bouyer <bouyer%NetBSD.org@localhost>
date: Fri Jan 28 18:36:06 2011 +0000
description:
Introduce quota2_ufs_rwq2v() and quota2_ufs_rwq2e() functions, which
byteswap a quota2_val or quota2_entry if needed.
Use this to get quota2_entry in host order before calling q2etoprop().
quota2_walk_list() will byteswap the offset if needed to leave
it in FS byte order in callers.
diffstat:
sys/ufs/ufs/quota2.h | 4 +++-
sys/ufs/ufs/quota2_subr.c | 23 ++++++++++++++++++++++-
sys/ufs/ufs/ufs_quota2.c | 30 ++++++++++++++++++------------
3 files changed, 43 insertions(+), 14 deletions(-)
diffs (165 lines):
diff -r 69df40ebb73b -r b1367d46a096 sys/ufs/ufs/quota2.h
--- a/sys/ufs/ufs/quota2.h Fri Jan 21 16:58:06 2011 +0000
+++ b/sys/ufs/ufs/quota2.h Fri Jan 28 18:36:06 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2.h,v 1.1.2.2 2011/01/21 16:58:06 bouyer Exp $ */
+/* $NetBSD: quota2.h,v 1.1.2.3 2011/01/28 18:36:06 bouyer Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -97,4 +97,6 @@
/* quota2_subr.c */
void quota2_addfreeq2e(struct quota2_header *, void *, uint64_t, uint64_t, int);
void quota2_create_blk0(uint64_t, void *bp, int, int, int);
+void quota2_ufs_rwq2v(const struct quota2_val *, struct quota2_val *, int);
+void quota2_ufs_rwq2e(const struct quota2_entry *, struct quota2_entry *, int);
#endif /* _UFS_UFS_QUOTA2_H_ */
diff -r 69df40ebb73b -r b1367d46a096 sys/ufs/ufs/quota2_subr.c
--- a/sys/ufs/ufs/quota2_subr.c Fri Jan 21 16:58:06 2011 +0000
+++ b/sys/ufs/ufs/quota2_subr.c Fri Jan 28 18:36:06 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2_subr.c,v 1.1.2.1 2011/01/20 14:25:03 bouyer Exp $ */
+/* $NetBSD: quota2_subr.c,v 1.1.2.2 2011/01/28 18:36:06 bouyer Exp $ */
/*-
* Copyright (c) 2010 Manuel Bouyer
* All rights reserved.
@@ -84,3 +84,24 @@
/* first quota entry, after the hash table */
quota2_addfreeq2e(q2h, bp, quota2_full_header_size, bsize, ns);
}
+
+void
+quota2_ufs_rwq2v(const struct quota2_val *s, struct quota2_val *d, int needswap)
+{
+ d->q2v_hardlimit = ufs_rw64(s->q2v_hardlimit, needswap);
+ d->q2v_softlimit = ufs_rw64(s->q2v_softlimit, needswap);
+ d->q2v_cur = ufs_rw64(s->q2v_cur, needswap);
+ d->q2v_time = ufs_rw64(s->q2v_time, needswap);
+ d->q2v_grace = ufs_rw64(s->q2v_grace, needswap);
+}
+
+void
+quota2_ufs_rwq2e(const struct quota2_entry *s, struct quota2_entry *d,
+int needswap)
+{
+ quota2_ufs_rwq2v(&s->q2e_val[Q2V_BLOCK], &d->q2e_val[Q2V_BLOCK],
+ needswap);
+ quota2_ufs_rwq2v(&s->q2e_val[Q2V_FILE], &d->q2e_val[Q2V_FILE],
+ needswap);
+ d->q2e_uid = ufs_rw32(s->q2e_uid, needswap);
+}
diff -r 69df40ebb73b -r b1367d46a096 sys/ufs/ufs/ufs_quota2.c
--- a/sys/ufs/ufs/ufs_quota2.c Fri Jan 21 16:58:06 2011 +0000
+++ b/sys/ufs/ufs/ufs_quota2.c Fri Jan 28 18:36:06 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.1.2.2 2011/01/21 16:58:06 bouyer Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.1.2.3 2011/01/28 18:36:06 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.2 2011/01/21 16:58:06 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.1.2.3 2011/01/28 18:36:06 bouyer Exp $");
#include <sys/buf.h>
#include <sys/param.h>
@@ -401,9 +401,10 @@
struct dquot *dq;
int error;
struct quota2_header *q2h;
- struct quota2_entry *q2e;
+ struct quota2_entry *q2ep, q2e;
struct buf *bp;
prop_dictionary_t dict;
+ const int needswap = UFS_MPNEEDSWAP(ump);
if (ump->um_quotas[type] == NULLVP)
return ENODEV;
@@ -414,7 +415,7 @@
mutex_exit(&dqlock);
return error;
}
- q2e = &q2h->q2h_defentry;
+ q2ep = &q2h->q2h_defentry;
} else {
error = dqget(NULLVP, id, ump, type, &dq);
@@ -426,11 +427,12 @@
return ENOENT;
}
error = getq2e(ump, type, dq->dq2_lblkno, dq->dq2_blkoff,
- &bp, &q2e, 0);
+ &bp, &q2ep, 0);
if (error)
return error;
}
- dict = q2etoprop(q2e, defaultq);
+ quota2_ufs_rwq2e(q2ep, &q2e, needswap);
+ dict = q2etoprop(&q2e, defaultq);
if (defaultq)
mutex_exit(&dqlock);
else
@@ -448,12 +450,15 @@
static int
quota2_getall_callback(struct ufsmount *ump, uint64_t *offp,
- struct quota2_entry *q2e, uint64_t off, void *v)
+ struct quota2_entry *q2ep, uint64_t off, void *v)
{
prop_array_t replies = v;
prop_dictionary_t dict;
+ const int needswap = UFS_MPNEEDSWAP(ump);
+ struct quota2_entry q2e;
- dict = q2etoprop(q2e, 0);
+ quota2_ufs_rwq2e(q2ep, &q2e, needswap);
+ dict = q2etoprop(&q2e, 0);
if (!prop_array_add_and_rel(replies, dict)) {
return ENOMEM;
}
@@ -465,6 +470,7 @@
{
int error;
struct quota2_header *q2h;
+ struct quota2_entry q2e;
struct buf *hbp;
prop_dictionary_t dict;
uint64_t offset;
@@ -477,14 +483,15 @@
error = getq2h(ump, type, &hbp, &q2h, 0);
if (error)
return error;
- dict = q2etoprop(&q2h->q2h_defentry, 1);
+ quota2_ufs_rwq2e(&q2h->q2h_defentry, &q2e, needswap);
+ dict = q2etoprop(&q2e, 1);
if (!prop_array_add_and_rel(replies, dict)) {
brelse(hbp, 0);
return ENOMEM;
}
quota2_hash_size = ufs_rw16(q2h->q2h_hash_size, needswap);
for (i = 0; i < quota2_hash_size ; i++) {
- offset = ufs_rw64(q2h->q2h_entries[i], needswap);
+ offset = q2h->q2h_entries[i], needswap;
error = quota2_walk_list(ump, hbp, type, &offset, 0, replies,
quota2_getall_callback);
if (error)
@@ -533,7 +540,6 @@
int error;
daddr_t offset;
u_long hash_mask;
- const int needswap = UFS_MPNEEDSWAP(ump);
struct dq2get_callback c = {
.id = id,
.dq = dq
@@ -545,7 +551,7 @@
goto out_mutex;
/* look for our entry */
hash_mask = ((1 << q2h->q2h_hash_shift) - 1);
- offset = ufs_rw64(q2h->q2h_entries[id & hash_mask], needswap);
+ offset = q2h->q2h_entries[id & hash_mask];
error = quota2_walk_list(ump, bp, type, &offset, 0, (void *)&c,
dq2get_callback);
brelse(bp, 0);
Home |
Main Index |
Thread Index |
Old Index