summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-inode-fd-ops.c
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawal@redhat.com>2020-03-12 21:12:13 +0530
committerMOHIT AGRAWAL <moagrawa@redhat.com>2020-03-20 04:08:42 +0000
commitfb20713b380e1df8d7f9e9df96563be2f9144fd6 (patch)
treecd61da00b382c7b805e74d5e9370e11df2718f49 /xlators/storage/posix/src/posix-inode-fd-ops.c
parent5410cc35ea09b1932c8eae4933fbf84f462e61ea (diff)
Posix: Use simple approach to close fd
Problem: posix_release(dir) functions add the fd's into a ctx->janitor_fds and janitor thread closes the fd's.In brick_mux environment it is difficult to handle race condition in janitor threads because brick spawns a single janitor thread for all bricks. Solution: Use synctask to execute posix_release(dir) functions instead of using background a thread to close fds. Credits: Pranith Karampuri <pkarampu@redhat.com> Change-Id: Iffb031f0695a7da83d5a2f6bac8863dad225317e Fixes: bz#1811631 Signed-off-by: Mohit Agrawal <moagrawal@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.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index a6c2b512ef1..439a4362fc6 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -1366,7 +1366,6 @@ posix_releasedir(xlator_t *this, fd_t *fd)
struct posix_fd *pfd = NULL;
uint64_t tmp_pfd = 0;
int ret = 0;
- glusterfs_ctx_t *ctx = NULL;
VALIDATE_OR_GOTO(this, out);
VALIDATE_OR_GOTO(fd, out);
@@ -1384,21 +1383,11 @@ posix_releasedir(xlator_t *this, fd_t *fd)
goto out;
}
- ctx = THIS->ctx;
-
- pthread_mutex_lock(&ctx->janitor_lock);
- {
- INIT_LIST_HEAD(&pfd->list);
- list_add_tail(&pfd->list, &ctx->janitor_fds);
- pthread_cond_signal(&ctx->janitor_cond);
- }
- pthread_mutex_unlock(&ctx->janitor_lock);
-
- /*gf_msg_debug(this->name, 0, "janitor: closing dir fd=%p", pfd->dir);
+ gf_msg_debug(this->name, 0, "janitor: closing dir fd=%p", pfd->dir);
sys_closedir(pfd->dir);
GF_FREE(pfd);
- */
+
out:
return 0;
}
@@ -2525,13 +2514,11 @@ 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) {
@@ -2546,13 +2533,10 @@ posix_release(xlator_t *this, fd_t *fd)
"pfd->dir is %p (not NULL) for file fd=%p", pfd->dir, fd);
}
- pthread_mutex_lock(&ctx->janitor_lock);
- {
- INIT_LIST_HEAD(&pfd->list);
- list_add_tail(&pfd->list, &ctx->janitor_fds);
- pthread_cond_signal(&ctx->janitor_cond);
- }
- pthread_mutex_unlock(&ctx->janitor_lock);
+ gf_msg_debug(this->name, 0, "janitor: closing dir fd=%p", pfd->dir);
+
+ sys_close(pfd->fd);
+ GF_FREE(pfd);
if (!priv)
goto out;