diff options
author | Soumya Koduri <skoduri@redhat.com> | 2018-11-18 23:38:08 +0530 |
---|---|---|
committer | Soumya Koduri <skoduri@redhat.com> | 2019-01-03 15:08:16 +0530 |
commit | ad1de8c31348f6864bd9b40292df8dfd1376c0a3 (patch) | |
tree | 46861de2b704b5ceedfc2506530c388a09f40b6e /api/src | |
parent | 1651c8c3546777ef3072ae83127f5aa47bb160b5 (diff) | |
download | glusterfs-ad1de8c31348f6864bd9b40292df8dfd1376c0a3.tar.gz glusterfs-ad1de8c31348f6864bd9b40292df8dfd1376c0a3.tar.xz glusterfs-ad1de8c31348f6864bd9b40292df8dfd1376c0a3.zip |
gfapi: Offload callback notifications to synctask
Upcall notifications are received from server via epoll
and same thread is used to forward these notifications
to the application. This may lead to deadlock and hang
in the following scenario.
Consider if as part of handling these callbacks,
application has to do some operations which involve
sending I/Os to gfapi stack which inturn have to wait for
epoll threads to receive repsonse. Thus this may lead to
deadlock if all the epoll threads are waiting to complete
these callback notifications.
To address it, instead of using epoll thread itself,
make use of synctask to send those notificaitons to the
application.
Change-Id: If614e0d09246e4279b9d1f40d883a32a39c8fd90
updates: bz#1655532
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/gfapi-messages.h | 3 | ||||
-rw-r--r-- | api/src/glfs-fops.c | 55 |
2 files changed, 47 insertions, 11 deletions
diff --git a/api/src/gfapi-messages.h b/api/src/gfapi-messages.h index 4d9dff7196..07cdb06779 100644 --- a/api/src/gfapi-messages.h +++ b/api/src/gfapi-messages.h @@ -77,7 +77,8 @@ GLFS_MSGID(API, API_MSG_LOCK_INSERT_MERGE_FAILED, API_MSG_SETTING_LOCK_TYPE_FAILED, API_MSG_INODE_FIND_FAILED, - API_MSG_FDCTX_SET_FAILED + API_MSG_FDCTX_SET_FAILED, + API_MSG_UPCALL_SYNCOP_FAILED ); #endif /* !_GFAPI_MESSAGES_H__ */ diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index 50f32fae6f..4e349b3ddb 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -31,6 +31,11 @@ #define GF_NAME_MAX 255 #endif +struct upcall_syncop_args { + struct glfs *fs; + struct gf_upcall *upcall_data; +}; + #define READDIRBUF_SIZE (sizeof(struct dirent) + GF_NAME_MAX + 1) typedef void (*glfs_io_cbk34) (glfs_fd_t *fd, ssize_t ret, void *data); @@ -4859,19 +4864,17 @@ out: return ret; } -static void -glfs_cbk_upcall_data (struct glfs *fs, struct gf_upcall *upcall_data) +static int +glfs_cbk_upcall_syncop(void *opaque) { + struct upcall_syncop_args *args = opaque; int ret = -1; struct glfs_upcall *up_arg = NULL; + struct glfs *fs; + struct gf_upcall *upcall_data; - if (!fs || !upcall_data) - goto out; - - if (!(fs->upcall_events & upcall_data->event_type)) { - /* ignore events which application hasn't registered*/ - goto out; - } + fs = args->fs; + upcall_data = args->upcall_data; up_arg = GLFS_CALLOC (1, sizeof (struct gf_upcall), glfs_release_upcall, @@ -4921,7 +4924,39 @@ out: GLFS_FREE (up_arg); } - return; + return ret; +} + +static void +glfs_cbk_upcall_data(struct glfs *fs, struct gf_upcall *upcall_data) +{ + struct upcall_syncop_args args = { + 0, + }; + int ret = -1; + + if (!fs || !upcall_data) + goto out; + + if (!(fs->upcall_events & upcall_data->event_type)) { + /* ignore events which application hasn't registered*/ + goto out; + } + + args.fs = fs; + args.upcall_data = upcall_data; + + ret = synctask_new(THIS->ctx->env, glfs_cbk_upcall_syncop, NULL, NULL, + &args); + /* should we retry incase of failure? */ + if (ret) { + gf_msg(THIS->name, GF_LOG_ERROR, errno, API_MSG_UPCALL_SYNCOP_FAILED, + "Synctak for Upcall event_type(%d) and gfid(%s) failed", + upcall_data->event_type, (char *)(upcall_data->gfid)); + } + +out: + return; } /* |