I think you identified the occurring deadlock in your other
reply correctly by the way. Seems it's a bit more complicated to
use syncops correctly than I originally assumed, I'll probably
go back to STACK_WIND / UNWIND chains even if the resulting code
is quite messy.
Date: Mon, 29 Apr 2013 14:30:50 +0530
From:
kparthas@xxxxxxxxxx
To:
fog_is_my_name@xxxxxxxxxxx
CC:
gluster-devel@xxxxxxxxxx
Subject: Re: rpc problems when using syncops
in callbacks
Fog,
On 04/29/2013 01:57 PM, fog - wrote:
Hello Avati,
I am wrapping the syncop call in a synctask_new (otherwise
glusterFS will run into a null pointer @ synctask_get in
the SYNCOP macro & crash). Below is some code to show
how I do it currently to test the syncops.
typedef struct{
xlator_t *this; loc_t *loc; dict_t *dic;
}syncstore_args;
int32_t __xattr_store_sync(void* data)
{
syncstore_args *args = (syncstore_args*)data;
return syncop_setxattr(FIRST_CHILD(args->this),
args->loc, args->dic, 0);
}
int32_t xattr_store_sync(xlator_t *this, call_frame_t
*frame, loc_t *loc, dict_t *dic)
{
syncstore_args args = {this, loc, dic};
return synctask_new(this->ctx->env,
__xattr_store_sync, NULL, NULL, &args);
If you don't provide a synctask_cbk_t to synctask_new, you are
using synctask in a 'blocking' mode.
That is, the thread calling synctask_new would block until the
synctask_fn_t function (ie, __xattr_store_sync) returns.
An alternative way to do this would be,
int32_t xattr_store_sync(xlator_t *this, call_frame_t *frame,
loc_t *loc, dict_t *dic)
{
syncstore_args args = {this, loc, dic};
return synctask_new(this->ctx->env,
__xattr_store_sync, __xattr_store_sync_cbk, NULL, &args);
}
int32_t __xattr_store_sync_cbk (int ret, /*and the other
args*/)
{
// Your code goes here
return ret;
}
Now, all file operations performed using syncop_* inside
__xattr_store_sync would have the synchronous flavour, while
leaving the calling thread (thread calling xattr_store_sync
fn) 'free'. This should avoid the hang issue.
HTH,
krish
}
Date: Mon, 29 Apr 2013 00:19:11
-0700
Subject: Re: rpc problems when using
syncops in callbacks
From:
anand.avati@xxxxxxxxx
To:
fog_is_my_name@xxxxxxxxxxx
CC:
gluster-devel@xxxxxxxxxx
Note that you need to place your syncop
code in a synctask function strictly within a syncenv
(by calling synctask_new(). You're probably calling
syncop_XXX() directly in your xlator code?
Avati
_______________________________________________
Gluster-devel mailing list
Gluster-devel@xxxxxxxxxx
https://lists.nongnu.org/mailman/listinfo/gluster-devel