Date: Wed, 22 Feb 2012 20:03:51 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r232003 - head/sys/ufs/ufs Message-ID: <201202222003.q1MK3pfl066609@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Wed Feb 22 20:03:51 2012 New Revision: 232003 URL: http://svn.freebsd.org/changeset/base/232003 Log: Properly lock DQREF() with dqhlock. Missed locking caused counter corruption. Assert that the dq reference value is sane before decrementing it. Reported and tested by: pho MFC after: 1 week Modified: head/sys/ufs/ufs/ufs_quota.c Modified: head/sys/ufs/ufs/ufs_quota.c ============================================================================== --- head/sys/ufs/ufs/ufs_quota.c Wed Feb 22 20:01:38 2012 (r232002) +++ head/sys/ufs/ufs/ufs_quota.c Wed Feb 22 20:03:51 2012 (r232003) @@ -1469,6 +1469,7 @@ dqrele(struct vnode *vp, struct dquot *d if (dq == NODQUOT) return; DQH_LOCK(); + KASSERT(dq->dq_cnt > 0, ("Lost dq %p reference 1", dq)); if (dq->dq_cnt > 1) { dq->dq_cnt--; DQH_UNLOCK(); @@ -1479,6 +1480,7 @@ sync: (void) dqsync(vp, dq); DQH_LOCK(); + KASSERT(dq->dq_cnt > 0, ("Lost dq %p reference 2", dq)); if (--dq->dq_cnt > 0) { DQH_UNLOCK(); @@ -1658,6 +1660,7 @@ quotaref(vp, qrp) */ found = 0; ip = VTOI(vp); + mtx_lock(&dqhlock); for (i = 0; i < MAXQUOTAS; i++) { if ((dq = ip->i_dquot[i]) == NODQUOT) continue; @@ -1665,6 +1668,7 @@ quotaref(vp, qrp) qrp[i] = dq; found++; } + mtx_unlock(&dqhlock); return (found); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202222003.q1MK3pfl066609>