diff options
author | Poornima G <pgurusid@redhat.com> | 2018-08-16 16:36:08 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-12-19 14:36:52 +0000 |
commit | 2af8fca492f3e1152177641b5e6ab9ea59ec0acd (patch) | |
tree | 65dfe1889f015c72f8dcad045bebc2a2197102d0 /xlators/storage/posix/src/posix-inode-fd-ops.c | |
parent | e3ec41af9a9f4d906dd7b512b3f4f91a6f338f4b (diff) |
posix: use synctask for janitor
With brick mux, the number of threads increases as the number of
bricks increases. As an initiative to reduce the number of
threads in brick mux scenario, replacing janitor thread to use
synctask infra.
Now close() and closedir() handle by separate janitor
thread which is linked with glusterfs_ctx.
Updates #475
Change-Id: I0c4aaf728125ab7264442fde59f3d08542785f73
Signed-off-by: Poornima G <pgurusid@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-inode-fd-ops.c')
-rw-r--r-- | xlators/storage/posix/src/posix-inode-fd-ops.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index dafd1855ef9..d2324823592 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -1236,8 +1236,7 @@ posix_releasedir(xlator_t *this, fd_t *fd) struct posix_fd *pfd = NULL; uint64_t tmp_pfd = 0; int ret = 0; - - struct posix_private *priv = NULL; + glusterfs_ctx_t *ctx = NULL; VALIDATE_OR_GOTO(this, out); VALIDATE_OR_GOTO(fd, out); @@ -1255,18 +1254,21 @@ posix_releasedir(xlator_t *this, fd_t *fd) goto out; } - priv = this->private; - if (!priv) - goto out; + ctx = THIS->ctx; - pthread_mutex_lock(&priv->janitor_lock); + pthread_mutex_lock(&ctx->janitor_lock); { INIT_LIST_HEAD(&pfd->list); - list_add_tail(&pfd->list, &priv->janitor_fds); - pthread_cond_signal(&priv->janitor_cond); + list_add_tail(&pfd->list, &ctx->janitor_fds); + pthread_cond_signal(&ctx->janitor_cond); } - pthread_mutex_unlock(&priv->janitor_lock); + pthread_mutex_unlock(&ctx->janitor_lock); + + /*gf_msg_debug(this->name, 0, "janitor: closing dir fd=%p", pfd->dir); + sys_closedir(pfd->dir); + GF_FREE(pfd); + */ out: return 0; } @@ -2337,11 +2339,13 @@ posix_release(xlator_t *this, fd_t *fd) struct posix_fd *pfd = NULL; int ret = -1; uint64_t tmp_pfd = 0; + glusterfs_ctx_t *ctx = NULL; VALIDATE_OR_GOTO(this, out); VALIDATE_OR_GOTO(fd, out); priv = this->private; + ctx = THIS->ctx; ret = fd_ctx_del(fd, this, &tmp_pfd); if (ret < 0) { @@ -2349,22 +2353,23 @@ posix_release(xlator_t *this, fd_t *fd) "pfd is NULL from fd=%p", fd); goto out; } - pfd = (struct posix_fd *)(long)tmp_pfd; + pfd = (struct posix_fd *)(long)tmp_pfd; if (pfd->dir) { gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_DIR_NOT_NULL, "pfd->dir is %p (not NULL) for file fd=%p", pfd->dir, fd); } - if (!priv) - goto out; - pthread_mutex_lock(&priv->janitor_lock); + pthread_mutex_lock(&ctx->janitor_lock); { INIT_LIST_HEAD(&pfd->list); - list_add_tail(&pfd->list, &priv->janitor_fds); - pthread_cond_signal(&priv->janitor_cond); + list_add_tail(&pfd->list, &ctx->janitor_fds); + pthread_cond_signal(&ctx->janitor_cond); } - pthread_mutex_unlock(&priv->janitor_lock); + pthread_mutex_unlock(&ctx->janitor_lock); + + if (!priv) + goto out; LOCK(&priv->lock); { |