From 916bfe080520bdfb9a8d4e35ce7095c5b632f4eb Mon Sep 17 00:00:00 2001 From: Mikhal Pershin Date: Sat, 2 Dec 2017 11:42:11 +0300 Subject: [PATCH] LU-10269 ldlm: allow trybits in waiting queue Lock trybits can be kept while lock is waiting and each new lock filters trybits of locks in the waiting queue. When lock if granted finally remaining trybits are added to the granted bits. Therefore trybits can be granted for blocking lock if no other locks take these bits while lock is waiting. Test-Parameters: mdscount=1 mdtcount=1 testlist=racer,racer,racer,racer Signed-off-by: Mikhal Pershin Change-Id: I775f776f4cf8b581e32e4a1585e862e1764b5bed Reviewed-on: https://review.whamcloud.com/30343 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_inodebits.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lustre/ldlm/ldlm_inodebits.c b/lustre/ldlm/ldlm_inodebits.c index 85c4e31..0c51ab7 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -133,17 +133,22 @@ ldlm_inodebits_compat_queue(struct list_head *queue, struct ldlm_lock *req, struct ldlm_lock, l_sl_policy)->l_res_link; - /* no locks with trybits in either queues */ - LASSERT(lock->l_policy_data.l_inodebits.try_bits == 0); - /* New lock's try_bits are filtered out by ibits * of all locks in both granted and waiting queues. */ - *try_bits &= ~lock->l_policy_data.l_inodebits.bits; + *try_bits &= ~(lock->l_policy_data.l_inodebits.bits | + lock->l_policy_data.l_inodebits.try_bits); if ((req_bits | *try_bits) == 0) RETURN(0); + /* The new lock ibits is more preferable than try_bits + * of waiting locks so drop conflicting try_bits in + * the waiting queue. + * Notice that try_bits of granted locks must be zero. + */ + lock->l_policy_data.l_inodebits.try_bits &= ~req_bits; + /* Locks with overlapping bits conflict. */ if (lock->l_policy_data.l_inodebits.bits & req_bits) { /* COS lock mode has a special compatibility @@ -155,12 +160,6 @@ ldlm_inodebits_compat_queue(struct list_head *queue, struct ldlm_lock *req, lock->l_client_cookie == req->l_client_cookie) goto not_conflicting; - /* The conflicting lock will keep only mandatory - * ibits and zero trybits in waiting queue. - * All actual trybits are cleared. - */ - *try_bits = 0; - /* Found a conflicting policy group. */ if (!work_list) RETURN(0); -- 1.8.3.1