summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-04-23 10:49:02 +0530
committerAnand Avati <avati@redhat.com>2012-04-23 13:11:49 -0700
commiteb9003cdca755980da9ed5a3a3fb0fc52c750131 (patch)
tree7ed1f88457bfa0ed2cfdf2cb1ede2a50cc966b59
parentfc024df2b6f9307f23a4a0800103555708036b17 (diff)
libglusterfs: Never block syncproc
Change-Id: I64cd8a2ef37926173c19a33df0716183530e22bf BUG: 814074 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/3194 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--libglusterfs/src/syncop.c2
-rw-r--r--libglusterfs/src/syncop.h42
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-syncop.h6
3 files changed, 9 insertions, 41 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index da0444a109a..45416c6e75f 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -115,7 +115,6 @@ synctask_wake (struct synctask *task)
pthread_cond_broadcast (&env->cond);
}
-
void
synctask_wrap (struct synctask *old_task)
{
@@ -322,7 +321,6 @@ synctask_switchto (struct synctask *task)
pthread_mutex_unlock (&env->mutex);
}
-
void *
syncenv_processor (void *thdata)
{
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index f095319c4d9..12a00d58acc 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -64,7 +64,6 @@ struct synctask {
void *stack;
int woken;
int slept;
- int complete;
int ret;
ucontext_t ctx;
@@ -120,54 +119,22 @@ struct syncargs {
dict_t *dict;
/* do not touch */
- pthread_mutex_t mutex;
- char complete;
- pthread_cond_t cond;
struct synctask *task;
};
-
-#define __yield(args) do { \
- if (args->task) { \
- synctask_yield (args->task); \
- } else { \
- pthread_mutex_lock (&args->mutex); \
- { \
- while (!args->complete) \
- pthread_cond_wait (&args->cond, \
- &args->mutex); \
- } \
- pthread_mutex_unlock (&args->mutex); \
- \
- pthread_mutex_destroy (&args->mutex); \
- pthread_cond_destroy (&args->cond); \
- } \
- } while (0)
-
-
-#define __wake(args) do { \
- if (args->task) { \
- synctask_wake (args->task); \
- } else { \
- pthread_mutex_lock (&args->mutex); \
- { \
- args->complete = 1; \
- pthread_cond_broadcast (&args->cond); \
- } \
- pthread_mutex_unlock (&args->mutex); \
- } \
- } while (0)
+#define __wake(args) synctask_wake(args->task)
#define SYNCOP(subvol, stb, cbk, op, params ...) do { \
struct synctask *task = NULL; \
\
task = synctask_get (); \
+ stb->task = task; \
\
STACK_WIND_COOKIE (task->opframe, cbk, (void *)stb, \
subvol, op, params); \
- __yield (stb); \
- STACK_RESET (task->opframe->root); \
+ synctask_yield (stb->task); \
+ STACK_RESET (task->opframe->root); \
} while (0)
@@ -178,7 +145,6 @@ void syncenv_destroy (struct syncenv *);
void syncenv_scale (struct syncenv *env);
int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, call_frame_t* frame, void *);
-void synctask_zzzz (struct synctask *task);
void synctask_wake (struct synctask *task);
void synctask_yield (struct synctask *task);
diff --git a/xlators/mgmt/glusterd/src/glusterd-syncop.h b/xlators/mgmt/glusterd/src/glusterd-syncop.h
index 44f983c2979..a3cc0ab47e0 100644
--- a/xlators/mgmt/glusterd/src/glusterd-syncop.h
+++ b/xlators/mgmt/glusterd/src/glusterd-syncop.h
@@ -28,11 +28,15 @@
/* gd_syncop_* */
#define GD_SYNCOP(rpc, stb, cbk, req, prog, procnum, xdrproc) do { \
int ret = 0; \
+ struct synctask *task = NULL; \
+ task = synctask_get (); \
+ stb->task = task; \
+ \
ret = gd_syncop_submit_request (rpc, req, stb, \
prog, procnum, cbk, \
(xdrproc_t)xdrproc); \
if (!ret) \
- __yield (stb); \
+ synctask_yield (stb->task); \
} while (0)