diff options
author | Krishnan Parthasarathi <kparthas@redhat.com> | 2015-06-05 10:33:11 +0530 |
---|---|---|
committer | Pranith Kumar Karampuri <pkarampu@redhat.com> | 2015-07-01 04:18:13 -0700 |
commit | 8ad92bbde3a17ce9aa44e32ae42df5db259fa2ce (patch) | |
tree | dab3aeb34f2e45a70b1730fc21bbca0f2a8c1bb6 /xlators | |
parent | c0ff88a6f2ac836cc4e0716be8fc0247b62e9a57 (diff) |
stack: use list_head for managing frames
PROBLEM
--------
statedump requests that traverse call frames of all call stacks in
execution may race with a STACK_RESET on a stack. This could crash the
corresponding glusterfs process. For e.g, recently we observed this in a
regression test case tests/basic/afr/sparse-self-heal.t.
FIX
---
gf_proc_dump_pending_frames takes a (TRY_LOCK) call_pool->lock before
iterating through call frames of all call stacks in progress. With this
fix, STACK_RESET removes its call frames under the same lock.
Additional info
----------------
This fix makes call_stack_t to use struct list_head in place of custom
doubly-linked list implementation. This makes call_frame_t manipulation
easier to maintain in the context of STACK_WIND et al.
BUG: 1234408
Change-Id: I7e43bccd3994cd9184ab982dba3dbc10618f0d94
Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com>
Reviewed-on: http://review.gluster.org/11095
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
(cherry picked from commit 79e4c7b2fad6db15863efb4e979525b1bd4862ea)
Reviewed-on: http://review.gluster.org/11352
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/protect/src/prot_client.c | 7 | ||||
-rw-r--r-- | xlators/meta/src/frames-file.c | 6 |
2 files changed, 6 insertions, 7 deletions
diff --git a/xlators/features/protect/src/prot_client.c b/xlators/features/protect/src/prot_client.c index 500c772bedd..33c2b5af427 100644 --- a/xlators/features/protect/src/prot_client.c +++ b/xlators/features/protect/src/prot_client.c @@ -40,10 +40,9 @@ pcli_print_trace (char *name, call_frame_t *frame) int i; gf_log (name, GF_LOG_INFO, "Translator stack:"); - while (frame) { + list_for_each_entry (frame, &frame->root->myframes, frames) { gf_log (name, GF_LOG_INFO, "%s (%s)", frame->wind_from, frame->this->name); - frame = frame->next; } size = backtrace (frames, NUM_FRAMES); @@ -82,7 +81,7 @@ pcli_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, if (value != PROT_ACT_NONE) { gf_log (this->name, GF_LOG_WARNING, "got rename for protected %s", oldloc->path); - pcli_print_trace (this->name, frame->next); + pcli_print_trace (this->name, frame); if (value == PROT_ACT_REJECT) { STACK_UNWIND_STRICT (rename, frame, -1, EPERM, NULL, NULL, NULL, NULL, NULL, @@ -166,7 +165,7 @@ pcli_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag, if (value != PROT_ACT_NONE) { gf_log (this->name, GF_LOG_WARNING, "got unlink for protected %s", loc->path); - pcli_print_trace(this->name,frame->next); + pcli_print_trace(this->name, frame); if (value == PROT_ACT_REJECT) { STACK_UNWIND_STRICT (unlink, frame, -1, EPERM, NULL, NULL, NULL); diff --git a/xlators/meta/src/frames-file.c b/xlators/meta/src/frames-file.c index 0e9777c9da2..b81e5c7413b 100644 --- a/xlators/meta/src/frames-file.c +++ b/xlators/meta/src/frames-file.c @@ -44,8 +44,7 @@ frames_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd) strprintf (strfd, "\t\t\"Number\": %d,\n", ++i); strprintf (strfd, "\t\t\"Frame\": [\n"); j = 1; - for (frame = &stack->frames; frame; - frame = frame->next) { + list_for_each_entry (frame, &stack->myframes, frames) { strprintf (strfd, "\t\t {\n"); strprintf (strfd, "\t\t\t\"Number\": %d,\n", j++); @@ -76,7 +75,8 @@ frames_file_fill (xlator_t *this, inode_t *file, strfd_t *strfd) frame->unwind_to); strprintf (strfd, "\t\t\t\"Complete\": %d\n", frame->complete); - if (frame->next == NULL) + if (list_is_last (&frame->frames, + &stack->myframes)) strprintf (strfd, "\t\t }\n"); else strprintf (strfd, "\t\t },\n"); |