From 7bd561996d5a32071942b598739b130e020f89ee Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 12 Mar 2012 13:15:14 +0530 Subject: locks: Fixed incorrect list ptr manipulation in clearing entrylks Avoided unwinding blocked entry lock frames inside pl_inode->mutex. Change-Id: I424c4a1762c889c1a567c588d4ca383a6c338886 BUG: 800412 Signed-off-by: Krishnan Parthasarathi Reviewed-on: http://review.gluster.com/2878 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/features/locks/src/clear.c | 42 +++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'xlators/features/locks/src') diff --git a/xlators/features/locks/src/clear.c b/xlators/features/locks/src/clear.c index d64a15b09..6c6afe008 100644 --- a/xlators/features/locks/src/clear.c +++ b/xlators/features/locks/src/clear.c @@ -310,11 +310,13 @@ clrlk_clear_entrylk (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *dom, { pl_entry_lock_t *elock = NULL; pl_entry_lock_t *tmp = NULL; - struct list_head removed = {0}; int bcount = 0; int gcount = 0; int ret = -1; + struct list_head removed; + struct list_head released; + INIT_LIST_HEAD (&released); if (args->kind & CLRLK_BLOCKED) goto blkd; @@ -326,21 +328,29 @@ blkd: { list_for_each_entry_safe (elock, tmp, &dom->blocked_entrylks, blocked_locks) { - if (args->opts && - strncmp (elock->basename, args->opts, - strlen (elock->basename))) - continue; + if (args->opts) { + if (!elock->basename || + strcmp (elock->basename, args->opts)) + continue; + } bcount++; - list_del_init (&elock->domain_list); - STACK_UNWIND_STRICT (entrylk, elock->frame, -1, - EAGAIN); - GF_FREE ((char *) elock->basename); - GF_FREE (elock); + list_del_init (&elock->blocked_locks); + list_add_tail (&elock->blocked_locks, &released); } } pthread_mutex_unlock (&pl_inode->mutex); + list_for_each_entry_safe (elock, tmp, &released, blocked_locks) { + list_del_init (&elock->blocked_locks); + entrylk_trace_out (this, elock->frame, elock->volume, NULL, NULL, + elock->basename, ENTRYLK_LOCK, elock->type, + -1, EAGAIN); + STACK_UNWIND_STRICT (entrylk, elock->frame, -1, EAGAIN); + GF_FREE ((char *) elock->basename); + GF_FREE (elock); + } + if (!(args->kind & CLRLK_GRANTED)) { ret = 0; goto out; @@ -352,13 +362,11 @@ granted: { list_for_each_entry_safe (elock, tmp, &dom->entrylk_list, domain_list) { - if (!elock->basename) - continue; - - if (args->opts && - strncmp (elock->basename, args->opts, - strlen (elock->basename))) - continue; + if (args->opts) { + if (!elock->basename || + strcmp (elock->basename, args->opts)) + continue; + } gcount++; list_del_init (&elock->domain_list); -- cgit