From 84fe7114833aed4efc31a1beaf7fcff0124c0ab4 Mon Sep 17 00:00:00 2001 From: Krishnan P Date: Thu, 16 Jun 2011 01:26:00 +0000 Subject: syncop: Modified to accept one 'non-frame' arg. Earlier syncops used to accept one argument which was a call frame to carry out the fops synchronously. Now we have two args passed to synctask function, one call frame and another void pointer. Signed-off-by: Krishnan Parthasarathi Signed-off-by: Anand Avati BUG: 3033 (Changes to replace-brick and syntask interface.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=3033 --- libglusterfs/src/syncop.c | 45 +++++++++++++++++++++++++++++++++++++----- libglusterfs/src/syncop.h | 6 ++++-- xlators/cluster/afr/src/pump.c | 8 +++----- 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c index 267e4b3a2..938fa3585 100644 --- a/libglusterfs/src/syncop.c +++ b/libglusterfs/src/syncop.c @@ -28,12 +28,12 @@ call_frame_t * syncop_create_frame () { struct synctask *task = NULL; - struct call_frame_t *frame = NULL; + call_frame_t *frame = NULL; task = synctask_get (); if (task) { - frame = task->opaque; + frame = task->frame; } return (call_frame_t *)frame; @@ -102,7 +102,7 @@ synctask_wrap (struct synctask *task) int ret; ret = task->syncfn (task->opaque); - task->synccbk (ret, task->opaque); + task->synccbk (ret, task->frame, task->opaque); /* cannot destroy @task right here as we are in the execution stack of @task itself @@ -128,19 +128,26 @@ synctask_destroy (struct synctask *task) int synctask_new (struct syncenv *env, synctask_fn_t fn, synctask_cbk_t cbk, - void *opaque) + call_frame_t *frame, void *opaque) { struct synctask *newtask = NULL; + xlator_t *this = THIS; + + VALIDATE_OR_GOTO (env, err); + VALIDATE_OR_GOTO (fn, err); + VALIDATE_OR_GOTO (cbk, err); + VALIDATE_OR_GOTO (frame, err); newtask = CALLOC (1, sizeof (*newtask)); if (!newtask) return -ENOMEM; newtask->env = env; - newtask->xl = THIS; + newtask->xl = this; newtask->syncfn = fn; newtask->synccbk = cbk; newtask->opaque = opaque; + newtask->frame = frame; INIT_LIST_HEAD (&newtask->all_tasks); @@ -429,6 +436,34 @@ syncop_opendir (xlator_t *subvol, } +int +syncop_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno) +{ + struct syncargs *args = NULL; + + args = cookie; + + args->op_ret = op_ret; + args->op_errno = op_errno; + + __wake (args); + + return 0; +} + +int +syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name) +{ + struct syncargs args = {0, }; + + SYNCOP (subvol, (&args), syncop_removexattr_cbk, subvol->fops->removexattr, + loc, name); + + errno = args.op_errno; + return args.op_ret; +} + int syncop_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno) diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h index 6954bfc68..ac913c870 100644 --- a/libglusterfs/src/syncop.h +++ b/libglusterfs/src/syncop.h @@ -35,7 +35,7 @@ struct synctask; struct syncenv; -typedef int (*synctask_cbk_t) (int ret, void *opaque); +typedef int (*synctask_cbk_t) (int ret, call_frame_t *frame, void *opaque); typedef int (*synctask_fn_t) (void *opaque); @@ -45,6 +45,7 @@ struct synctask { struct list_head all_tasks; struct syncenv *env; xlator_t *xl; + call_frame_t *frame; synctask_cbk_t synccbk; synctask_fn_t syncfn; void *opaque; @@ -149,7 +150,7 @@ struct syncargs { struct syncenv * syncenv_new (); void syncenv_destroy (struct syncenv *); -int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, void *); +int synctask_new (struct syncenv *, synctask_fn_t, synctask_cbk_t, call_frame_t* frame, void *); void synctask_zzzz (struct synctask *task); void synctask_yawn (struct synctask *task); void synctask_wake (struct synctask *task); @@ -172,5 +173,6 @@ int syncop_setattr (xlator_t *subvol, loc_t *loc, struct iatt *iatt, int valid, int syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf); int syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags); +int syncop_removexattr (xlator_t *subvol, loc_t *loc, const char *name); #endif /* _SYNCOP_H */ diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c index 99d57f2a5..5497bddff 100644 --- a/xlators/cluster/afr/src/pump.c +++ b/xlators/cluster/afr/src/pump.c @@ -739,21 +739,19 @@ out: static int -pump_task_completion (int ret, void *data) +pump_task_completion (int ret, call_frame_t *sync_frame, void *data) { xlator_t *this = NULL; - call_frame_t *frame = NULL; afr_private_t *priv = NULL; pump_private_t *pump_priv = NULL; this = THIS; - frame = (call_frame_t *) data; - priv = this->private; pump_priv = priv->pump_private; inode_unref (priv->root_inode); + STACK_DESTROY (sync_frame->root); gf_log (this->name, GF_LOG_DEBUG, "Pump xlator exiting"); @@ -776,7 +774,7 @@ pump_start (call_frame_t *pump_frame, xlator_t *this) ret = synctask_new (pump_priv->env, pump_task, pump_task_completion, - pump_frame); + pump_frame, NULL); if (ret == -1) { gf_log (this->name, GF_LOG_DEBUG, "starting pump failed"); -- cgit