diff options
author | Zhang Huan <zhanghuan@open-fs.com> | 2017-11-29 17:36:55 +0800 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2017-12-26 05:05:55 +0000 |
commit | f13023862edc868d4da87609412341aecd041ed8 (patch) | |
tree | fd008b460ff368b1c9ba6e28633fcf0beb5b1241 /xlators/protocol/client/src/client-helpers.c | |
parent | 0bc22bef7f3c24663aadfb3548b348aa121e3047 (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-helpers.c')
-rw-r--r-- | xlators/protocol/client/src/client-helpers.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index f9d5c2c8b12..c078b88b84d 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -299,18 +299,20 @@ client_get_remote_fd (xlator_t *this, fd_t *fd, int flags, int64_t *remote_fd) GF_VALIDATE_OR_GOTO (this->name, fd, out); GF_VALIDATE_OR_GOTO (this->name, remote_fd, out); - conf = this->private; - pthread_mutex_lock (&conf->lock); - { - fdctx = this_fd_get_ctx (fd, this); - if (!fdctx) - *remote_fd = GF_ANON_FD_NO; - else if (__is_fd_reopen_in_progress (fdctx)) - *remote_fd = -1; - else - *remote_fd = fdctx->remote_fd; + fdctx = this_fd_get_ctx (fd, this); + if (!fdctx) { + *remote_fd = GF_ANON_FD_NO; + } else { + conf = this->private; + pthread_spin_lock (&conf->fd_lock); + { + if (__is_fd_reopen_in_progress (fdctx)) + *remote_fd = -1; + else + *remote_fd = fdctx->remote_fd; + } + pthread_spin_unlock (&conf->fd_lock); } - pthread_mutex_unlock (&conf->lock); if ((flags & FALLBACK_TO_ANON_FD) && (*remote_fd == -1)) *remote_fd = GF_ANON_FD_NO; |