From b25b822d2c3ec4b99a15a1d6d444d36f98bfab1c Mon Sep 17 00:00:00 2001 From: Mohammed Rafi KC Date: Thu, 4 May 2017 20:56:43 +0530 Subject: [PATCH 418/426] snapview-server : Refresh the snapshot list during each reconnect Currently we are refreshing the snapshot list either when there is a request from glusterd or the very first initialization. But if anything changed after when glusterd is down then there is no mechanism to refresh the snashot dentries. This patch will refresh snapshot list during each reconnect Backport of> >Change-Id: I3ed655572d777f60d57dd479d190f75553591267 >BUG: 1448150 >Signed-off-by: Mohammed Rafi KC >Reviewed-on: https://review.gluster.org/17178 >Smoke: Gluster Build System >NetBSD-regression: NetBSD Build System >Reviewed-by: Amar Tumballi >CentOS-regression: Gluster Build System >Reviewed-by: Atin Mukherjee >Reviewed-by: Raghavendra Bhat Change-Id: I3ed655572d777f60d57dd479d190f75553591267 BUG: 1165648 Signed-off-by: Mohammed Rafi KC Reviewed-on: https://code.engineering.redhat.com/gerrit/105517 Reviewed-by: Atin Mukherjee --- .../snapview-server/src/snapview-server-mgmt.c | 32 ++++++++++++++++++++++ .../mgmt/glusterd/src/glusterd-snapshot-utils.c | 1 + 2 files changed, 33 insertions(+) diff --git a/xlators/features/snapview-server/src/snapview-server-mgmt.c b/xlators/features/snapview-server/src/snapview-server-mgmt.c index fc2ff2a..18c902d 100644 --- a/xlators/features/snapview-server/src/snapview-server-mgmt.c +++ b/xlators/features/snapview-server/src/snapview-server-mgmt.c @@ -49,6 +49,31 @@ rpc_clnt_prog_t svs_clnt_handshake_prog = { .procnames = clnt_handshake_procs, }; +static int +svs_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, + void *data) +{ + xlator_t *this = NULL; + int ret = 0; + + this = mydata; + + switch (event) { + case RPC_CLNT_CONNECT: + ret = svs_get_snapshot_list (this); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "Error in refreshing the snaplist " + "infrastructure"); + ret = -1; + } + break; + default: + break; + } + return ret; +} + int svs_mgmt_init (xlator_t *this) { @@ -86,6 +111,13 @@ svs_mgmt_init (xlator_t *this) goto out; } + ret = rpc_clnt_register_notify (priv->rpc, svs_rpc_notify, this); + if (ret) { + gf_log (this->name, GF_LOG_WARNING, + "failed to register notify function"); + goto out; + } + ret = rpcclnt_cbk_program_register (priv->rpc, &svs_cbk_prog, this); if (ret) { diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index c4cfc84..e833cc9 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -1705,6 +1705,7 @@ glusterd_import_friend_snap (dict_t *peer_data, int32_t snap_count, "object %s", peer_snap_name); goto out; } + glusterd_fetchsnap_notify (this); out: if (ret) -- 1.8.3.1