From 9b3def01e4b6c7c3e6899e4ad52ee64440285f54 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Mon, 30 Apr 2012 07:29:16 +0530 Subject: libgluster: Fix counting, synctask state errors When a synctask is executed in synctask_switchto, if by the time it goes to check the woken/sleep part a reply already comes and __wake is called, already running task is going to be put in runq this generates a false warning "re-running already running task". If the reply does not come before the woken/sleep check, then the running task is put in waitq which decrements env->runcount even when the task is not in runq, this leads to -ve runcount everytime a task goes from runq->switchto->waitq. This patch fixes both of them by introducing a new state for the task called SYNCTASK_SUSPEND just when the task is suspended before yeild in SYNCOP. Change-Id: Ib82182cf950f9d85b5656f6243541489a104ca3d BUG: 816551 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.com/3249 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- libglusterfs/src/syncop.c | 2 ++ libglusterfs/src/syncop.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 45416c6e7..cf92d9ad1 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -34,6 +34,7 @@ __run (struct synctask *task) list_del_init (&task->all_tasks); switch (task->state) { case SYNCTASK_INIT: + case SYNCTASK_SUSPEND: break; case SYNCTASK_RUN: gf_log (task->xl->name, GF_LOG_WARNING, @@ -65,6 +66,7 @@ __wait (struct synctask *task) list_del_init (&task->all_tasks); switch (task->state) { case SYNCTASK_INIT: + case SYNCTASK_SUSPEND: break; case SYNCTASK_RUN: env->runcount--; diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index 12a00d58a..3e7264d4f 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -46,6 +46,7 @@ typedef int (*synctask_fn_t) (void *opaque); typedef enum { SYNCTASK_INIT = 0, SYNCTASK_RUN, + SYNCTASK_SUSPEND, SYNCTASK_WAIT, SYNCTASK_DONE, } synctask_state_t; @@ -133,6 +134,7 @@ struct syncargs { \ STACK_WIND_COOKIE (task->opframe, cbk, (void *)stb, \ subvol, op, params); \ + task->state = SYNCTASK_SUSPEND; \ synctask_yield (stb->task); \ STACK_RESET (task->opframe->root); \ } while (0) -- cgit