From 50cfb1365f74f67dd5d0fd84f4d674d167e725d2 Mon Sep 17 00:00:00 2001
From: Poornima G <pgurusid@redhat.com>
Date: Fri, 28 Oct 2016 15:27:15 +0530
Subject: [PATCH 181/206] afr,dht,ec: Replace GF_EVENT_CHILD_MODIFIED with
event SOME_DESCENDENT_DOWN/UP
Backport of http://review.gluster.org/#/c/15764/
Currently these are few events related to child_up/down:
GF_EVENT_CHILD_UP : Issued when any of the protocol client
connects.
GF_EVENT_CHILD_MODIFIED : Issued by afr/dht/ec
GF_EVENT_CHILD_DOWN : Issued when any of the protocol client
disconnects.
These events get modified at the dht/afr/ec layers. Here is a
brief on the same.
DHT:
- All the subvolumes reported once, and atleast one child came
up, then GF_EVENT_CHILD_UP is issued
- connect GF_EVENT_CHILD_UP is issued
- disconnect GF_EVENT_CHILD_MODIFIED is issued
- All the subvolumes disconnected, GF_EVENT_CHILD_DOWN is issued
AFR:
- First subvolume came up, then GF_EVENT_CHILD_UP is issued
- Subsequent subvolumes coming up, results in GF_EVENT_CHILD_MODIFIED
- Any of the subvolumes go down, then GF_EVENT_SOME_CHILD_DOWN is issued
- Last up subvolume goes down, then GF_EVENT_CHILD_DOWN is issued
Until the patch [1] introduced GF_EVENT_SOME_CHILD_UP,
GF_EVENT_CHILD_MODIFIED was issued by afr/dht when any of the subvolumes
go up or down.
Now with md-cache changes, there is a necessity to differentiate between
child up and down. Hence, introducing GF_EVENT_SOME_DESCENDENT_DOWN/UP and
getting rid of GF_EVENT_CHILD_MODIFIED.
[1] http://review.gluster.org/12573
>Reviewed-on: http://review.gluster.org/15764
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: N Balachandran <nbalacha@redhat.com>
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
>Signed-off-by: Poornima G <pgurusid@redhat.com>
Change-Id: I704140b6598f7ec705493251d2dbc4191c965a58
BUG: 1384993
Signed-off-by: Poornima G <pgurusid@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/90692
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
---
libglusterfs/src/defaults-tmpl.c | 1 -
rpc/xdr/src/glusterfs-fops.x | 9 ++++---
xlators/cluster/afr/src/afr-common.c | 38 ++++++++++++-----------------
xlators/cluster/dht/src/dht-common.c | 7 +++---
xlators/cluster/ec/src/ec.c | 6 ++++-
xlators/nfs/server/src/nfs.c | 3 ++-
xlators/performance/md-cache/src/md-cache.c | 8 ++----
7 files changed, 34 insertions(+), 38 deletions(-)
diff --git a/libglusterfs/src/defaults-tmpl.c b/libglusterfs/src/defaults-tmpl.c
index b42c377..5b7578b 100644
--- a/libglusterfs/src/defaults-tmpl.c
+++ b/libglusterfs/src/defaults-tmpl.c
@@ -132,7 +132,6 @@ default_notify (xlator_t *this, int32_t event, void *data, ...)
}
break;
case GF_EVENT_CHILD_CONNECTING:
- case GF_EVENT_CHILD_MODIFIED:
case GF_EVENT_CHILD_DOWN:
case GF_EVENT_CHILD_UP:
case GF_EVENT_AUTH_FAILED:
diff --git a/rpc/xdr/src/glusterfs-fops.x b/rpc/xdr/src/glusterfs-fops.x
index 4bfdd4b..c8f00f0 100644
--- a/rpc/xdr/src/glusterfs-fops.x
+++ b/rpc/xdr/src/glusterfs-fops.x
@@ -62,6 +62,9 @@ enum glusterfs_fop_t {
GF_FOP_MAXVALUE
};
+/* Note: Removed event GF_EVENT_CHILD_MODIFIED=8, hence
+ *to preserve backward compatibiliy, GF_EVENT_TRANSPORT_CLEANUP = 9
+ */
enum glusterfs_event_t {
GF_EVENT_PARENT_UP = 1,
GF_EVENT_POLLIN,
@@ -70,8 +73,7 @@ enum glusterfs_event_t {
GF_EVENT_CHILD_UP,
GF_EVENT_CHILD_DOWN,
GF_EVENT_CHILD_CONNECTING,
- GF_EVENT_CHILD_MODIFIED,
- GF_EVENT_TRANSPORT_CLEANUP,
+ GF_EVENT_TRANSPORT_CLEANUP = 9,
GF_EVENT_TRANSPORT_CONNECTED,
GF_EVENT_VOLFILE_MODIFIED,
GF_EVENT_GRAPH_NEW,
@@ -83,8 +85,9 @@ enum glusterfs_event_t {
GF_EVENT_VOLUME_BARRIER_OP,
GF_EVENT_UPCALL,
GF_EVENT_SCRUB_STATUS,
- GF_EVENT_SOME_CHILD_DOWN,
+ GF_EVENT_SOME_DESCENDENT_DOWN,
GF_EVENT_SCRUB_ONDEMAND,
+ GF_EVENT_SOME_DESCENDENT_UP,
GF_EVENT_MAXVAL
};
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index fe0dc2d..dec6026 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -4245,27 +4245,21 @@ __afr_transform_event_from_state (afr_private_t *priv)
return GF_EVENT_MAXVAL;
up_children = __afr_get_up_children_count (priv);
- if (up_children) {
- /* We received at least one child up and there are pending
- * notifications from some children. Treat these children as
- * having sent a GF_EVENT_CHILD_DOWN. i.e. set the event as
- * GF_EVENT_CHILD_MODIFIED, as done in afr_notify() */
- for (i = 0; i < priv->child_count; i++) {
- if (priv->last_event[i])
- continue;
- priv->last_event[i] = GF_EVENT_CHILD_MODIFIED;
- priv->child_up[i] = 0;
- }
+ /* Treat the children with pending notification, as having sent a
+ * GF_EVENT_CHILD_DOWN. i.e. set the event as GF_EVENT_SOME_DESCENDENT_DOWN,
+ * as done in afr_notify() */
+ for (i = 0; i < priv->child_count; i++) {
+ if (priv->last_event[i])
+ continue;
+ priv->last_event[i] = GF_EVENT_SOME_DESCENDENT_DOWN;
+ priv->child_up[i] = 0;
+ }
+
+ if (up_children)
+ /* We received at least one child up */
return GF_EVENT_CHILD_UP;
- } else {
- for (i = 0; i < priv->child_count; i++) {
- if (priv->last_event[i])
- continue;
- priv->last_event[i] = GF_EVENT_SOME_CHILD_DOWN;
- priv->child_up[i] = 0;
- }
+ else
return GF_EVENT_CHILD_DOWN;
- }
return GF_EVENT_MAXVAL;
}
@@ -4434,7 +4428,7 @@ afr_notify (xlator_t *this, int32_t event,
"subvol=%s", this->name);
} else {
- event = GF_EVENT_CHILD_MODIFIED;
+ event = GF_EVENT_SOME_DESCENDENT_UP;
}
priv->last_event[idx] = event;
@@ -4458,7 +4452,7 @@ afr_notify (xlator_t *this, int32_t event,
gf_event (EVENT_AFR_SUBVOLS_DOWN,
"subvol=%s", this->name);
} else {
- event = GF_EVENT_SOME_CHILD_DOWN;
+ event = GF_EVENT_SOME_DESCENDENT_DOWN;
}
priv->last_event[idx] = event;
@@ -4470,7 +4464,7 @@ afr_notify (xlator_t *this, int32_t event,
break;
- case GF_EVENT_SOME_CHILD_DOWN:
+ case GF_EVENT_SOME_DESCENDENT_DOWN:
priv->last_event[idx] = event;
break;
case GF_EVENT_UPCALL:
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index a2bd8b7..1594f62 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -8722,15 +8722,14 @@ dht_notify (xlator_t *this, int event, void *data, ...)
break;
- case GF_EVENT_CHILD_MODIFIED:
+ case GF_EVENT_SOME_DESCENDENT_UP:
subvol = data;
-
conf->gen++;
propagate = 1;
break;
- case GF_EVENT_SOME_CHILD_DOWN:
+ case GF_EVENT_SOME_DESCENDENT_DOWN:
subvol = data;
propagate = 1;
@@ -8775,7 +8774,7 @@ dht_notify (xlator_t *this, int event, void *data, ...)
for (i = 0; i < conf->subvolume_cnt; i++)
if (conf->last_event[i] != event)
- event = GF_EVENT_CHILD_MODIFIED;
+ event = GF_EVENT_SOME_DESCENDENT_DOWN;
break;
case GF_EVENT_CHILD_CONNECTING:
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
index 12c3de5..63fb0dc 100644
--- a/xlators/cluster/ec/src/ec.c
+++ b/xlators/cluster/ec/src/ec.c
@@ -454,6 +454,7 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2)
dict_t *input = NULL;
dict_t *output = NULL;
gf_boolean_t propagate = _gf_true;
+ int32_t orig_event = event;
gf_msg_trace (this->name, 0, "NOTIFY(%d): %p, %p",
event, data, data2);
@@ -512,7 +513,10 @@ ec_notify (xlator_t *this, int32_t event, void *data, void *data2)
if (event != GF_EVENT_MAXVAL) {
if (event == old_event) {
- event = GF_EVENT_CHILD_MODIFIED;
+ if (orig_event == GF_EVENT_CHILD_UP)
+ event = GF_EVENT_SOME_DESCENDENT_UP;
+ else /* orig_event has to be GF_EVENT_CHILD_DOWN */
+ event = GF_EVENT_SOME_DESCENDENT_DOWN;
}
} else {
propagate = _gf_false;
diff --git a/xlators/nfs/server/src/nfs.c b/xlators/nfs/server/src/nfs.c
index ddfa89d..3e7199c 100644
--- a/xlators/nfs/server/src/nfs.c
+++ b/xlators/nfs/server/src/nfs.c
@@ -1542,7 +1542,8 @@ notify (xlator_t *this, int32_t event, void *data, ...)
nfs_startup_subvolume (this, subvol);
break;
- case GF_EVENT_CHILD_MODIFIED:
+ case GF_EVENT_SOME_DESCENDENT_DOWN:
+ case GF_EVENT_SOME_DESCENDENT_UP:
priv = this->private;
++(priv->generation);
break;
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 603c81f..1e802c3 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -2915,7 +2915,7 @@ notify (xlator_t *this, int event, void *data, ...)
conf = this->private;
switch (event) {
case GF_EVENT_CHILD_DOWN:
- case GF_EVENT_SOME_CHILD_DOWN:
+ case GF_EVENT_SOME_DESCENDENT_DOWN:
time (&now);
mdc_update_child_down_time (this, &now);
break;
@@ -2923,12 +2923,8 @@ notify (xlator_t *this, int event, void *data, ...)
if (conf->mdc_invalidation)
ret = mdc_invalidate (this, data);
break;
- case GF_EVENT_CHILD_MODIFIED:
- time (&now);
- mdc_update_child_down_time (this, &now);
- ret = mdc_register_xattr_inval (this);
- break;
case GF_EVENT_CHILD_UP:
+ case GF_EVENT_SOME_DESCENDENT_UP:
ret = mdc_register_xattr_inval (this);
break;
default:
--
2.9.3