X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fldlm%2Fldlm_inodebits.c;fp=lustre%2Fldlm%2Fldlm_inodebits.c;h=d6ededf3249e3f152f1507d0695ac9dc578722f1;hp=c5d5d5aafa6504c6afeb42117db2967d3b4be18b;hb=954cc6754b19a5eb4b9f717f79037c40baa87f3f;hpb=8733d5d764531621dc3e064dfb922e49373f7946 diff --git a/lustre/ldlm/ldlm_inodebits.c b/lustre/ldlm/ldlm_inodebits.c index c5d5d5a..d6ededf 100644 --- a/lustre/ldlm/ldlm_inodebits.c +++ b/lustre/ldlm/ldlm_inodebits.c @@ -57,6 +57,42 @@ #include "ldlm_internal.h" #ifdef HAVE_SERVER_SUPPORT +/* + * local lock will be canceled after use, and it should run blocking ast only + * when it should trigger Commit-on-Sharing, otherwise if the blocking ast + * is run and does nothing, it will prevent subsequent operations to trigger + * Commit-on-Sharing, see LU-11102. + */ +static bool ldlm_should_run_bl_ast(const struct ldlm_lock *lock, + const struct ldlm_lock *req) +{ + /* no blocking ast */ + if (!lock->l_blocking_ast) + return false; + + /* not local lock */ + if (!ldlm_is_local(lock)) + return true; + + /* should trigger Commit-on-Sharing */ + if ((lock->l_req_mode & LCK_COS)) + return true; + + /* local read lock will be canceld after use */ + if (!(lock->l_req_mode & (LCK_PW | LCK_EX))) + return false; + + /* if CoS enabled, check if @req is from different client */ + if (ldlm_is_cos_enabled(req)) + return lock->l_client_cookie != req->l_client_cookie; + + /* check if @req is COS incompatible */ + if (ldlm_is_cos_incompat(req)) + return true; + + return false; +} + /** * Determine if the lock is compatible with all locks on the queue. * @@ -168,12 +204,12 @@ ldlm_inodebits_compat_queue(struct list_head *queue, struct ldlm_lock *req, /* Add locks of the policy group to @work_list * as blocking locks for @req */ - if (lock->l_blocking_ast) + if (ldlm_should_run_bl_ast(lock, req)) ldlm_add_ast_work_item(lock, req, work_list); head = &lock->l_sl_policy; list_for_each_entry(lock, head, l_sl_policy) - if (lock->l_blocking_ast) + if (ldlm_should_run_bl_ast(lock, req)) ldlm_add_ast_work_item(lock, req, work_list); }