From e292ba487ed880409d86376f0c7712bd14d1b289 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Wed, 11 Apr 2012 09:13:49 +0000 Subject: [PATCH] VFS: more three-level-lock sanity checking --- servers/vfs/tll.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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