summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaghavendra Bhat <raghavendra@redhat.com>2012-08-09 13:12:31 +0530
committerAnand Avati <avati@redhat.com>2012-08-19 23:54:53 -0700
commit99f0daf2f46d56b78adfe1a3df1195e1388feaab (patch)
treee5066b14fc5f943645de23316df5979939e84a59
parentb757819289b014dbf706b26ca17f6cb584301ffc (diff)
performance/write-behind: avoid deadlock while taking the statedump of fds
* Provide a hook for forget Change-Id: Ide7ea6d4c6a7d0d93b81570cb544f2bbda526eeb BUG: 846916 Signed-off-by: Raghavendra Bhat <raghavendra@redhat.com> Reviewed-on: http://review.gluster.org/3795 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/performance/write-behind/src/write-behind.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 4082ffa9cc9..ad1e5f03111 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -162,7 +162,7 @@ __wb_fd_ctx_get (xlator_t *this, fd_t *fd)
wb_file_t *wb_file = NULL;
uint64_t value = 0;
- fd_ctx_get (fd, this, &value);
+ __fd_ctx_get (fd, this, &value);
wb_file = (wb_file_t *)(unsigned long)value;
return wb_file;
@@ -3079,20 +3079,30 @@ wb_fd_dump (xlator_t *this, fd_t *fd)
wb_file_t *wb_file = NULL;
char *path = NULL;
char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
+ int ret = -1;
+ gf_boolean_t section_added = _gf_false;
+
+ gf_proc_dump_build_key (key_prefix, "xlator.performance.write-behind",
+ "wb_file");
if ((fd == NULL) || (this == NULL)) {
goto out;
}
- wb_file = wb_fd_ctx_get (this, fd);
- if (wb_file == NULL) {
+ ret = TRY_LOCK(&fd->lock);
+ if (ret)
goto out;
+ {
+ wb_file = __wb_fd_ctx_get (this, fd);
}
+ UNLOCK(&fd->lock);
- gf_proc_dump_build_key (key_prefix, "xlator.performance.write-behind",
- "wb_file");
+ if (wb_file == NULL) {
+ goto out;
+ }
gf_proc_dump_add_section (key_prefix);
+ section_added = _gf_true;
__inode_path (fd->inode, NULL, &path);
if (path != NULL) {
@@ -3111,6 +3121,13 @@ wb_fd_dump (xlator_t *this, fd_t *fd)
gf_proc_dump_write ("disabled", "%d", wb_file->disabled);
out:
+ if (ret && fd && this) {
+ if (_gf_false == section_added)
+ gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_write ("Unable to dump the fd",
+ "(Lock acquisition failed) %s",
+ uuid_utoa (fd->inode->gfid));
+ }
return 0;
}
@@ -3265,7 +3282,8 @@ struct xlator_fops fops = {
};
struct xlator_cbks cbks = {
- .release = wb_release
+ .forget = wb_forget,
+ .release = wb_release,
};
struct xlator_dumpops dumpops = {