From e098653b73c7b379b2ad6bf7878bac65147f7ebe Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Thu, 18 Nov 2010 05:38:59 +0000 Subject: features/locks: Send prelock unlock only if it is not grantable and is a blocking lock call. Signed-off-by: Pavan Vilas Sondur Signed-off-by: Anand V. Avati BUG: 1017 (Locking deadlock when upgrading lock) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1017 --- xlators/features/locks/src/common.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c index e295e4fd518..ade440a7d0d 100644 --- a/xlators/features/locks/src/common.c +++ b/xlators/features/locks/src/common.c @@ -985,15 +985,20 @@ pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock, { /* Send unlock before the actual lock to prevent lock upgrade / downgrade - problems + problems only if: + - it is a blocking call + - it has other conflicting locks */ - ret = pl_send_prelock_unlock (this, pl_inode, - lock); - if (ret) - gf_log (this->name, GF_LOG_DEBUG, + if (can_block && + !(__is_lock_grantable (pl_inode, lock))) { + ret = pl_send_prelock_unlock (this, pl_inode, + lock); + if (ret) + gf_log (this->name, GF_LOG_DEBUG, "Could not send pre-lock " - "unlock"); + "unlock"); + } if (__is_lock_grantable (pl_inode, lock)) { gf_log (this->name, GF_LOG_TRACE, -- cgit