diff options
Diffstat (limited to 'xlators/features/locks')
-rw-r--r-- | xlators/features/locks/src/clear.c | 36 | ||||
-rw-r--r-- | xlators/features/locks/src/entrylk.c | 40 | ||||
-rw-r--r-- | xlators/features/locks/src/inodelk.c | 38 | ||||
-rw-r--r-- | xlators/features/locks/src/posix.c | 38 |
4 files changed, 86 insertions, 66 deletions
diff --git a/xlators/features/locks/src/clear.c b/xlators/features/locks/src/clear.c index fbd17942c6c..578d6d18666 100644 --- a/xlators/features/locks/src/clear.c +++ b/xlators/features/locks/src/clear.c @@ -254,14 +254,16 @@ blkd: } pthread_mutex_unlock(&pl_inode->mutex); - list_for_each_entry_safe(ilock, tmp, &released, blocked_locks) - { - list_del_init(&ilock->blocked_locks); - pl_trace_out(this, ilock->frame, NULL, NULL, F_SETLKW, - &ilock->user_flock, -1, EAGAIN, ilock->volume); - STACK_UNWIND_STRICT(inodelk, ilock->frame, -1, EAGAIN, NULL); - // No need to take lock as the locks are only in one list - __pl_inodelk_unref(ilock); + if (!list_empty(&released)) { + list_for_each_entry_safe(ilock, tmp, &released, blocked_locks) + { + list_del_init(&ilock->blocked_locks); + pl_trace_out(this, ilock->frame, NULL, NULL, F_SETLKW, + &ilock->user_flock, -1, EAGAIN, ilock->volume); + STACK_UNWIND_STRICT(inodelk, ilock->frame, -1, EAGAIN, NULL); + // No need to take lock as the locks are only in one list + __pl_inodelk_unref(ilock); + } } if (!(args->kind & CLRLK_GRANTED)) { @@ -357,15 +359,17 @@ blkd: } 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, NULL); + if (!list_empty(&released)) { + 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, NULL); - __pl_entrylk_unref(elock); + __pl_entrylk_unref(elock); + } } if (!(args->kind & CLRLK_GRANTED)) { diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c index d4135542cc9..8aa12831609 100644 --- a/xlators/features/locks/src/entrylk.c +++ b/xlators/features/locks/src/entrylk.c @@ -1072,32 +1072,36 @@ pl_entrylk_client_cleanup(xlator_t *this, pl_ctx_t *ctx) } pthread_mutex_unlock(&ctx->lock); - list_for_each_entry_safe(l, tmp, &unwind, client_list) - { - list_del_init(&l->client_list); + if (!list_empty(&unwind)) { + list_for_each_entry_safe(l, tmp, &unwind, client_list) + { + list_del_init(&l->client_list); - if (l->frame) - STACK_UNWIND_STRICT(entrylk, l->frame, -1, EAGAIN, NULL); - list_add_tail(&l->client_list, &released); + if (l->frame) + STACK_UNWIND_STRICT(entrylk, l->frame, -1, EAGAIN, NULL); + list_add_tail(&l->client_list, &released); + } } - list_for_each_entry_safe(l, tmp, &released, client_list) - { - list_del_init(&l->client_list); + if (!list_empty(&released)) { + list_for_each_entry_safe(l, tmp, &released, client_list) + { + list_del_init(&l->client_list); - pinode = l->pinode; + pinode = l->pinode; - dom = get_domain(pinode, l->volume); + dom = get_domain(pinode, l->volume); - grant_blocked_entry_locks(this, pinode, dom, &now, pcontend); + grant_blocked_entry_locks(this, pinode, dom, &now, pcontend); - pthread_mutex_lock(&pinode->mutex); - { - __pl_entrylk_unref(l); - } - pthread_mutex_unlock(&pinode->mutex); + pthread_mutex_lock(&pinode->mutex); + { + __pl_entrylk_unref(l); + } + pthread_mutex_unlock(&pinode->mutex); - inode_unref(pinode->inode); + inode_unref(pinode->inode); + } } if (pcontend != NULL) { diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c index 19b6f739f28..98367831dcf 100644 --- a/xlators/features/locks/src/inodelk.c +++ b/xlators/features/locks/src/inodelk.c @@ -691,31 +691,35 @@ pl_inodelk_client_cleanup(xlator_t *this, pl_ctx_t *ctx) } pthread_mutex_unlock(&ctx->lock); - list_for_each_entry_safe(l, tmp, &unwind, client_list) - { - list_del_init(&l->client_list); + if (!list_empty(&unwind)) { + list_for_each_entry_safe(l, tmp, &unwind, client_list) + { + list_del_init(&l->client_list); - if (l->frame) - STACK_UNWIND_STRICT(inodelk, l->frame, -1, EAGAIN, NULL); - list_add_tail(&l->client_list, &released); + if (l->frame) + STACK_UNWIND_STRICT(inodelk, l->frame, -1, EAGAIN, NULL); + list_add_tail(&l->client_list, &released); + } } - list_for_each_entry_safe(l, tmp, &released, client_list) - { - list_del_init(&l->client_list); + if (!list_empty(&released)) { + list_for_each_entry_safe(l, tmp, &released, client_list) + { + list_del_init(&l->client_list); - pl_inode = l->pl_inode; + pl_inode = l->pl_inode; - dom = get_domain(pl_inode, l->volume); + dom = get_domain(pl_inode, l->volume); - grant_blocked_inode_locks(this, pl_inode, dom, &now, pcontend); + grant_blocked_inode_locks(this, pl_inode, dom, &now, pcontend); - pthread_mutex_lock(&pl_inode->mutex); - { - __pl_inodelk_unref(l); + pthread_mutex_lock(&pl_inode->mutex); + { + __pl_inodelk_unref(l); + } + pthread_mutex_unlock(&pl_inode->mutex); + inode_unref(pl_inode->inode); } - pthread_mutex_unlock(&pl_inode->mutex); - inode_unref(pl_inode->inode); } if (pcontend != NULL) { diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c index ce6b6f9fbfc..2d7fd112c8d 100644 --- a/xlators/features/locks/src/posix.c +++ b/xlators/features/locks/src/posix.c @@ -2562,25 +2562,33 @@ pl_forget(xlator_t *this, inode_t *inode) } pthread_mutex_unlock(&pl_inode->mutex); - list_for_each_entry_safe(ext_l, ext_tmp, &posixlks_released, list) - { - STACK_UNWIND_STRICT(lk, ext_l->frame, -1, 0, &ext_l->user_flock, NULL); - __destroy_lock(ext_l); + if (!list_empty(&posixlks_released)) { + list_for_each_entry_safe(ext_l, ext_tmp, &posixlks_released, list) + { + STACK_UNWIND_STRICT(lk, ext_l->frame, -1, 0, &ext_l->user_flock, + NULL); + __destroy_lock(ext_l); + } } - list_for_each_entry_safe(ino_l, ino_tmp, &inodelks_released, blocked_locks) - { - STACK_UNWIND_STRICT(inodelk, ino_l->frame, -1, 0, NULL); - __pl_inodelk_unref(ino_l); + if (!list_empty(&inodelks_released)) { + list_for_each_entry_safe(ino_l, ino_tmp, &inodelks_released, + blocked_locks) + { + STACK_UNWIND_STRICT(inodelk, ino_l->frame, -1, 0, NULL); + __pl_inodelk_unref(ino_l); + } } - list_for_each_entry_safe(entry_l, entry_tmp, &entrylks_released, - blocked_locks) - { - STACK_UNWIND_STRICT(entrylk, entry_l->frame, -1, 0, NULL); - GF_FREE((char *)entry_l->basename); - GF_FREE(entry_l->connection_id); - GF_FREE(entry_l); + if (!list_empty(&entrylks_released)) { + list_for_each_entry_safe(entry_l, entry_tmp, &entrylks_released, + blocked_locks) + { + STACK_UNWIND_STRICT(entrylk, entry_l->frame, -1, 0, NULL); + GF_FREE((char *)entry_l->basename); + GF_FREE(entry_l->connection_id); + GF_FREE(entry_l); + } } pthread_mutex_destroy(&pl_inode->mutex); |