From 322ed6812d9a5b3c975b5c949ff5adfd16d40eb4 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 5 Apr 2011 04:00:26 +0000 Subject: protocol/client: make sure to send only genuine events up to parent that way parent notify logic is fine. also, remove 'xlator_notify()' call in code, instead use 'default_notify()' Signed-off-by: Amar Tumballi Signed-off-by: Vijay Bellur BUG: 2584 (Inode number changes on a directory when one of subvolumes is down in replicate) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2584 --- xlators/protocol/client/src/client.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'xlators/protocol/client/src/client.c') diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 22394f59fcd..ee8aecc2264 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1859,10 +1859,14 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, "handshake msg returned %d", ret); } else { //conf->rpc->connected = 1; - ret = default_notify (this, GF_EVENT_CHILD_UP, NULL); - if (ret) - gf_log (this->name, GF_LOG_WARNING, - "default notify failed"); + if (conf->last_sent_event != GF_EVENT_CHILD_UP) { + ret = default_notify (this, GF_EVENT_CHILD_UP, + NULL); + if (ret) + gf_log (this->name, GF_LOG_INFO, + "CHILD_UP notify failed"); + conf->last_sent_event = GF_EVENT_CHILD_UP; + } } break; } @@ -1874,7 +1878,20 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, if (conf->connected) gf_log (this->name, GF_LOG_NORMAL, "disconnected"); - default_notify (this, GF_EVENT_CHILD_DOWN, NULL); + + /* If the CHILD_DOWN event goes to parent xlator + multiple times, the logic of parent xlator notify + may get screwed up.. (eg. CHILD_MODIFIED event in + replicate), hence make sure events which are passed + to parent are genuine */ + if (conf->last_sent_event != GF_EVENT_CHILD_DOWN) { + ret = default_notify (this, GF_EVENT_CHILD_DOWN, + NULL); + if (ret) + gf_log (this->name, GF_LOG_INFO, + "CHILD_DOWN notify failed"); + conf->last_sent_event = GF_EVENT_CHILD_DOWN; + } } else { if (conf->connected) gf_log (this->name, GF_LOG_DEBUG, @@ -1923,6 +1940,7 @@ notify (xlator_t *this, int32_t event, void *data, ...) "got %d, calling default_notify ()", event); default_notify (this, event, data); + conf->last_sent_event = event; break; } @@ -2241,6 +2259,8 @@ init (xlator_t *this) LOCK_INIT (&conf->rec_lock); + conf->last_sent_event = -1; /* To start with we don't have any events */ + this->private = conf; /* If it returns -1, then its a failure, if it returns +1 we need @@ -2258,6 +2278,7 @@ init (xlator_t *this) goto out; } + ret = client_init_rpc (this); out: if (ret) -- cgit