summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client-rpc-fops.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-rpc-fops.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-rpc-fops.c')
-rw-r--r--xlators/protocol/client/src/client-rpc-fops.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c
index 30e0699d446..c8d1cc14f77 100644
--- a/xlators/protocol/client/src/client-rpc-fops.c
+++ b/xlators/protocol/client/src/client-rpc-fops.c
@@ -371,11 +371,11 @@ client_add_fd_to_saved_fds (xlator_t *this, fd_t *fd, loc_t *loc, int32_t flags,
this_fd_set_ctx (fd, this, loc, fdctx);
- pthread_mutex_lock (&conf->lock);
+ pthread_spin_lock (&conf->fd_lock);
{
list_add_tail (&fdctx->sfd_pos, &conf->saved_fds);
}
- pthread_mutex_unlock (&conf->lock);
+ pthread_spin_unlock (&conf->fd_lock);
out:
return ret;
}
@@ -3268,10 +3268,10 @@ client_fdctx_destroy (xlator_t *this, clnt_fd_ctx_t *fdctx)
pthread_mutex_lock (&conf->lock);
{
parent_down = conf->parent_down;
- lk_ctx = fdctx->lk_ctx;
- fdctx->lk_ctx = NULL;
}
pthread_mutex_unlock (&conf->lock);
+ lk_ctx = fdctx->lk_ctx;
+ fdctx->lk_ctx = NULL;
if (lk_ctx)
fd_lk_ctx_unref (lk_ctx);
@@ -3336,10 +3336,10 @@ client3_3_releasedir (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- pthread_mutex_lock (&conf->lock);
- {
- fdctx = this_fd_del_ctx (args->fd, this);
- if (fdctx != NULL) {
+ fdctx = this_fd_del_ctx (args->fd, this);
+ if (fdctx != NULL) {
+ pthread_spin_lock (&conf->fd_lock);
+ {
remote_fd = fdctx->remote_fd;
/* fdctx->remote_fd == -1 indicates a reopen attempt
@@ -3354,8 +3354,8 @@ client3_3_releasedir (call_frame_t *frame, xlator_t *this,
destroy = _gf_true;
}
}
+ pthread_spin_unlock (&conf->fd_lock);
}
- pthread_mutex_unlock (&conf->lock);
if (destroy)
client_fdctx_destroy (this, fdctx);
@@ -3382,10 +3382,10 @@ client3_3_release (call_frame_t *frame, xlator_t *this,
args = data;
conf = this->private;
- pthread_mutex_lock (&conf->lock);
- {
- fdctx = this_fd_del_ctx (args->fd, this);
- if (fdctx != NULL) {
+ fdctx = this_fd_del_ctx (args->fd, this);
+ if (fdctx != NULL) {
+ pthread_spin_lock (&conf->fd_lock);
+ {
remote_fd = fdctx->remote_fd;
lk_heal_state = fdctx->lk_heal_state;
@@ -3400,8 +3400,8 @@ client3_3_release (call_frame_t *frame, xlator_t *this,
destroy = _gf_true;
}
}
+ pthread_spin_unlock (&conf->fd_lock);
}
- pthread_mutex_unlock (&conf->lock);
if (destroy)
client_fdctx_destroy (this, fdctx);