diff options
| author | Venky Shankar <vshankar@redhat.com> | 2015-02-25 22:21:32 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vbellur@redhat.com> | 2015-03-24 06:33:32 -0700 | 
| commit | 9f5addd987861d0a3a1144d576221a7f93af0970 (patch) | |
| tree | a6723ef501fd481da76e830a88dcad0f3a119ab7 | |
| parent | 470d5c4af7f85809997a77af187c8f430b0354c8 (diff) | |
features/changelog: Make use of IPC fop
Translators which wish to send event notifications can send
"down" an IPC FOP with op_type as GF_IPC_TARGET_CHANGELOG
and xdata carrying event structures (changelog_event_t).
Change-Id: I0e5f8c9170161c186f0e58d07105813e34e18786
BUG: 1170075
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/9775
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
| -rw-r--r-- | libglusterfs/src/common-utils.h | 5 | ||||
| -rw-r--r-- | xlators/features/changelog/src/changelog.c | 46 | 
2 files changed, 51 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index f76059b3082..5f67a162d59 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -119,8 +119,13 @@ enum _gf_client_pid          GF_CLIENT_PID_GLFS_HEAL         = -7,  }; +enum _gf_xlator_ipc_targets { +        GF_IPC_TARGET_CHANGELOG = 0, +}; +  typedef enum _gf_boolean gf_boolean_t;  typedef enum _gf_client_pid gf_client_pid_t; +typedef enum _gf_xlator_ipc_targets _gf_xlator_ipc_targets_t;  typedef int (*gf_cmp) (void *, void *);  void gf_global_variable_init(void); diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index e7d8522ae8c..bb9c51a2a0b 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -1714,6 +1714,51 @@ changelog_open (call_frame_t *frame, xlator_t *this,  /* {{{ */ + +/* }}} */ + +int32_t +_changelog_generic_dispatcher (dict_t *dict, +                               char *key, data_t *value, void *data) +{ +        xlator_t *this = NULL; +        changelog_priv_t *priv = NULL; + +        this = data; +        priv = this->private; + +        changelog_dispatch_event (this, priv, (changelog_event_t *)value->data); +        return 0; +} + +/** + * changelog ipc dispatches events, pointers of which are passed in + * @xdata. Dispatching is orderless (whatever order dict_foreach() + * traverses the dictionary). + */ +int32_t +changelog_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata) +{ +        if (op != GF_IPC_TARGET_CHANGELOG) +                goto wind; + +        /* it's for us, do the job */ +        if (xdata) +                (void) dict_foreach (xdata, +                                     _changelog_generic_dispatcher, this); + +        STACK_UNWIND_STRICT (ipc, frame, 0, 0, NULL); +        return 0; + + wind: +        STACK_WIND (frame, default_ipc_cbk, FIRST_CHILD (this), +                    FIRST_CHILD (this)->fops->ipc, op, xdata); +        return 0; +} + + +/* {{{ */ +  int32_t  changelog_release (xlator_t *this, fd_t *fd)  { @@ -2621,6 +2666,7 @@ struct xlator_fops fops = {          .fsetxattr    = changelog_fsetxattr,          .removexattr  = changelog_removexattr,          .fremovexattr = changelog_fremovexattr, +        .ipc          = changelog_ipc,  };  struct xlator_cbks cbks = {  | 
