summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client.c
diff options
context:
space:
mode:
authorZhang Huan <zhanghuan@open-fs.com>2017-11-29 17:36:55 +0800
committerRaghavendra G <rgowdapp@redhat.com>2017-12-26 05:05:55 +0000
commitf13023862edc868d4da87609412341aecd041ed8 (patch)
treefd008b460ff368b1c9ba6e28633fcf0beb5b1241 /xlators/protocol/client/src/client.c
parent0bc22bef7f3c24663aadfb3548b348aa121e3047 (diff)
protocol/client: reduce lock contention
Current use of a per-client mutex to protect fdctx introduces lock contentions when there are dozens of file operations active. Use finer grain spinlock to reduce contention, and put retrieving fdctx out of lock. Change-Id: Iea3e2eb481e76a5d73a582ba81529180c5b88248 BUG: 1519598 Signed-off-by: Zhang Huan <zhanghuan@open-fs.com>
Diffstat (limited to 'xlators/protocol/client/src/client.c')
-rw-r--r--xlators/protocol/client/src/client.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 8ec9eae..955db86 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -49,6 +49,7 @@ client_fini_complete (xlator_t *this)
this->private = NULL;
+ pthread_spin_destroy (&conf->fd_lock);
pthread_mutex_destroy (&conf->lock);
GF_FREE (conf);
@@ -2243,14 +2244,14 @@ client_mark_fd_bad (xlator_t *this)
conf = this->private;
- pthread_mutex_lock (&conf->lock);
+ pthread_spin_lock (&conf->fd_lock);
{
list_for_each_entry_safe (fdctx, tmp, &conf->saved_fds,
sfd_pos) {
fdctx->remote_fd = -1;
}
}
- pthread_mutex_unlock (&conf->lock);
+ pthread_spin_unlock (&conf->fd_lock);
return 0;
}
@@ -2755,6 +2756,7 @@ init (xlator_t *this)
goto out;
pthread_mutex_init (&conf->lock, NULL);
+ pthread_spin_init (&conf->fd_lock, 0);
INIT_LIST_HEAD (&conf->saved_fds);
conf->child_up = _gf_false;
@@ -2909,12 +2911,14 @@ client_priv_dump (xlator_t *this)
gf_proc_dump_add_section(key_prefix);
+ pthread_spin_lock (&conf->fd_lock);
list_for_each_entry(tmp, &conf->saved_fds, sfd_pos) {
sprintf (key, "fd.%d.remote_fd", i);
gf_proc_dump_write(key, "%d", tmp->remote_fd);
client_fd_lk_ctx_dump (this, tmp->lk_ctx, i);
i++;
}
+ pthread_spin_unlock (&conf->fd_lock);
gf_proc_dump_write("connecting", "%d", conf->connecting);