From 82b24d64b9dc89672e6a298648f0e3959b62b1c0 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Thu, 18 Sep 2014 17:12:33 +0530 Subject: snapview-server: register a callback with glusterd to get notifications * As of now snapview-server is polling (sending rpc requests to glusterd) to get the latest list of snapshots at some regular time intervals (non configurable). Instead of that register a callback with glusterd so that glusterd sends notifications to snapd whenever a snapshot is created/deleted and snapview-server can configure itself. rebase of the patch http://review.gluster.org/#/c/8150/ Change-Id: Iee2582b1a823d50c79233a41cf2106f458b40691 BUG: 1143961 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.org/8767 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mgmt/glusterd/src/glusterd-snapshot.c | 4 +++ xlators/mgmt/glusterd/src/glusterd.c | 37 +++++++++++++++++++++++++++ xlators/mgmt/glusterd/src/glusterd.h | 3 +++ 3 files changed, 44 insertions(+) (limited to 'xlators/mgmt') diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c index 58e611d20dc..148acec8882 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c @@ -6259,6 +6259,7 @@ glusterd_snapshot_status_commit (dict_t *dict, char **op_errstr, } } ret = 0; + out: return ret; } @@ -7111,6 +7112,7 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr, "post-validation failed"); goto out; } + glusterd_fetchsnap_notify (this); break; case GF_SNAP_OPTION_TYPE_DELETE: if (op_ret) { @@ -7128,6 +7130,7 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr, "update missed snaps list"); goto out; } + glusterd_fetchsnap_notify (this); break; case GF_SNAP_OPTION_TYPE_RESTORE: ret = glusterd_snapshot_update_snaps_post_validate (dict, @@ -7146,6 +7149,7 @@ glusterd_snapshot_postvalidate (dict_t *dict, int32_t op_ret, char **op_errstr, "perform snapshot restore post-op"); goto out; } + glusterd_fetchsnap_notify (this); break; case GF_SNAP_OPTION_TYPE_ACTIVATE: case GF_SNAP_OPTION_TYPE_DEACTIVATE: diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 559b39d8d84..5a6e55ef39e 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -227,6 +227,7 @@ set: out: return 0; } + int glusterd_fetchspec_notify (xlator_t *this) { @@ -251,6 +252,42 @@ glusterd_fetchspec_notify (xlator_t *this) return ret; } +int +glusterd_fetchsnap_notify (xlator_t *this) +{ + int ret = -1; + glusterd_conf_t *priv = NULL; + rpc_transport_t *trans = NULL; + + priv = this->private; + + /* + * TODO: As of now, the identification of the rpc clients in the + * handshake protocol is not there. So among so many glusterfs processes + * registered with glusterd, it is hard to identify one particular + * process (in this particular case, the snap daemon). So the callback + * notification is sent to all the transports from the transport list. + * Only those processes which have a rpc client registered for this + * callback will respond to the notification. Once the identification + * of the rpc clients becomes possible, the below section can be changed + * to send callback notification to only those rpc clients, which have + * registered. + */ + pthread_mutex_lock (&priv->xprt_lock); + { + list_for_each_entry (trans, &priv->xprt_list, list) { + rpcsvc_callback_submit (priv->rpc, trans, + &glusterd_cbk_prog, + GF_CBK_GET_SNAPS, NULL, 0); + } + } + pthread_mutex_unlock (&priv->xprt_lock); + + ret = 0; + + return ret; +} + int glusterd_priv (xlator_t *this) { diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index f2f7a0a277c..9f26e7508ad 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -834,6 +834,9 @@ glusterd_xfer_cli_deprobe_resp (rpcsvc_request_t *req, int32_t op_ret, int glusterd_fetchspec_notify (xlator_t *this); +int +glusterd_fetchsnap_notify (xlator_t *this); + int glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, dict_t *volumes, int count); -- cgit