Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ufs Fix quota2 list corruption issue when defaultquo...
details: https://anonhg.NetBSD.org/src/rev/c8c18bb36731
branches: trunk
changeset: 781743:c8c18bb36731
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Sep 27 07:47:56 2012 +0000
description:
Fix quota2 list corruption issue when defaultquotas are 0 (deny any file
and block allocation).
When quota2_check() is called with an uid not yet in the list,
getinoquota2() will call quota2_q2ealloc() to allocate a new entry for this
uid. quota2_q2ealloc() will remove an entry from the free list and
put it at the head of the corresponding hash list, and flush the block
containing the header if it's not the one also containing the allocated entry.
quota2_q2ealloc() then return the alocated entry and corresponding block
to caller (getinoquota2() here), which returns it to quota2_check().
quota2_check() then checks if the allocation can succeed, and returns and
error if not and calls brelse() on the buffer (because from his POW no
change was made to the entry), effectively discarding changes
to the entry that may have been made by quota2_q2ealloc().
Fix by always bwrite()ing the entry in quota2_q2ealloc(), and re-reading
the entry in caller.
diffstat:
sys/ufs/ufs/ufs_quota2.c | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
diffs (84 lines):
diff -r 80e2347e7aed -r c8c18bb36731 sys/ufs/ufs/ufs_quota2.c
--- a/sys/ufs/ufs/ufs_quota2.c Thu Sep 27 00:44:59 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota2.c Thu Sep 27 07:47:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota2.c,v 1.34 2012/02/13 06:23:41 dholland Exp $ */
+/* $NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer 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.34 2012/02/13 06:23:41 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.35 2012/09/27 07:47:56 bouyer Exp $");
#include <sys/buf.h>
#include <sys/param.h>
@@ -290,8 +290,7 @@
}
static int
-quota2_q2ealloc(struct ufsmount *ump, int type, uid_t uid, struct dquot *dq,
- struct buf **bpp, struct quota2_entry **q2ep)
+quota2_q2ealloc(struct ufsmount *ump, int type, uid_t uid, struct dquot *dq)
{
int error, error2;
struct buf *hbp, *bp;
@@ -361,8 +360,7 @@
if (hbp != bp) {
bwrite(hbp);
}
- *q2ep = q2e;
- *bpp = bp;
+ bwrite(bp);
return 0;
}
@@ -416,18 +414,17 @@
}
/* need to alloc a new on-disk quot */
mutex_enter(&dqlock);
- error = quota2_q2ealloc(ump, i, ino_ids[i], dq,
- &bpp[i], &q2ep[i]);
+ error = quota2_q2ealloc(ump, i, ino_ids[i], dq);
mutex_exit(&dqlock);
if (error)
return error;
- } else {
- error = getq2e(ump, i, dq->dq2_lblkno,
- dq->dq2_blkoff, &bpp[i], &q2ep[i],
- modify ? B_MODIFY : 0);
- if (error)
- return error;
}
+ KASSERT(dq->dq2_lblkno != 0 || dq->dq2_blkoff != 0);
+ error = getq2e(ump, i, dq->dq2_lblkno,
+ dq->dq2_blkoff, &bpp[i], &q2ep[i],
+ modify ? B_MODIFY : 0);
+ if (error)
+ return error;
}
return 0;
}
@@ -622,13 +619,14 @@
if (dq->dq2_lblkno == 0 && dq->dq2_blkoff == 0) {
/* need to alloc a new on-disk quot */
mutex_enter(&dqlock);
- error = quota2_q2ealloc(ump, key->qk_idtype, key->qk_id, dq,
- &bp, &q2ep);
+ error = quota2_q2ealloc(ump, key->qk_idtype, key->qk_id, dq);
mutex_exit(&dqlock);
- } else {
- error = getq2e(ump, key->qk_idtype, dq->dq2_lblkno,
- dq->dq2_blkoff, &bp, &q2ep, B_MODIFY);
+ if (error)
+ goto out_il;
}
+ KASSERT(dq->dq2_lblkno != 0 || dq->dq2_blkoff != 0);
+ error = getq2e(ump, key->qk_idtype, dq->dq2_lblkno,
+ dq->dq2_blkoff, &bp, &q2ep, B_MODIFY);
if (error)
goto out_il;
Home |
Main Index |
Thread Index |
Old Index