From: Thomas Veerman Date: Wed, 11 Apr 2012 09:13:49 +0000 (+0000) Subject: VFS: more three-level-lock sanity checking X-Git-Tag: v3.2.1~592 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/invmod.png?a=commitdiff_plain;h=e292ba487ed880409d86376f0c7712bd14d1b289;p=minix.git VFS: more three-level-lock sanity checking --- diff --git a/servers/vfs/tll.c b/servers/vfs/tll.c index ca69163ae..68843dd47 100644 --- a/servers/vfs/tll.c +++ b/servers/vfs/tll.c @@ -48,7 +48,8 @@ static int tll_append(tll_t *tllp, tll_access_t locktype) if (tllp->t_current == TLL_READ) { tllp->t_readonly++; tllp->t_owner = NULL; - } + } else if (tllp->t_current == TLL_WRITE) + assert(tllp->t_readonly == 0); /* Due to the way upgrading and downgrading works, read-only requests are * scheduled to run after a downgraded lock is released (because they are @@ -164,6 +165,8 @@ int tll_lock(tll_t *tllp, tll_access_t locktype) else { /* Record owner if locktype is read-serialized or write-only */ tllp->t_owner = self; } + if (tllp->t_current == TLL_WRITE) + assert(tllp->t_readonly == 0); return(OK); } @@ -240,6 +243,9 @@ int tll_unlock(tll_t *tllp) signal_owner = 1; } + if (tllp->t_owner == self && tllp->t_current == TLL_WRITE) + assert(tllp->t_readonly == 0); + if(tllp->t_owner == self || (tllp->t_owner == NULL && tllp->t_readonly == 0)){ /* Let another read-serialized or write-only request obtain access. * Write-only has priority, but only after the last read-only access