LGTM, thanks

On Wed, Feb 19, 2014 at 6:07 PM, Klaus Aehlig <[email protected]> wrote:

> Disallow requests for an exclusive lock, if the owner already
> holds a shared (and only shared) lock on a group lock that lock
> belongs to.
>
> Signed-off-by: Klaus Aehlig <[email protected]>
> ---
>  src/Ganeti/Locking/Allocation.hs | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/Ganeti/Locking/Allocation.hs
> b/src/Ganeti/Locking/Allocation.hs
> index f73280d..3b03f1d 100644
> --- a/src/Ganeti/Locking/Allocation.hs
> +++ b/src/Ganeti/Locking/Allocation.hs
> @@ -236,6 +236,17 @@ updateLocks owner reqs state = genericResult ((,)
> state . Bad) (second Ok) $ do
>                                         , (lock, OwnExclusive)]
>          -> orderViolation lock
>        _ -> Ok ()
> +  let sharedsHeld = M.keysSet $ M.filter (== OwnShared) current
> +      exclusivesRequested = map lockAffected
> +                            . filter ((== Just OwnExclusive) .
> lockRequestType)
> +                            $ reqs
> +  runListHead (return ()) fail $ do
> +    x <- exclusivesRequested
> +    i <- lockImplications x
> +    guard $ S.member i sharedsHeld
> +    return $ "Order violation: requesting exclusively " ++ show x
> +              ++ " while holding a shared lock on the group lock " ++
> show i
> +              ++ " it belongs to."
>    let blockedOn (LockRequest  _ Nothing) = S.empty
>        blockedOn (LockRequest lock (Just OwnExclusive)) =
>          case M.lookup lock (laLocks state) of
> --
> 1.9.0.rc1.175.g0b1dcb5
>
>


-- 
-- 
Helga Velroyen | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to