|
|
256ebe |
From 9fd966aa6879ac9867381629f82eca24b950d731 Mon Sep 17 00:00:00 2001
|
|
|
256ebe |
From: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
256ebe |
Date: Sun, 2 Jun 2019 01:36:33 +0530
|
|
|
256ebe |
Subject: [PATCH 175/178] ec/fini: Fix race between xlator cleanup and on going
|
|
|
256ebe |
async fop
|
|
|
256ebe |
|
|
|
256ebe |
Problem:
|
|
|
256ebe |
While we process a cleanup, there is a chance for a race between
|
|
|
256ebe |
async operations, for example ec_launch_replace_heal. So this can
|
|
|
256ebe |
lead to invalid mem access.
|
|
|
256ebe |
|
|
|
256ebe |
Solution:
|
|
|
256ebe |
Just like we track on going heal fops, we can also track fops like
|
|
|
256ebe |
ec_launch_replace_heal, so that we can decide when to send a
|
|
|
256ebe |
PARENT_DOWN request.
|
|
|
256ebe |
|
|
|
256ebe |
> upstream patch : https://review.gluster.org/#/c/glusterfs/+/22798/
|
|
|
256ebe |
|
|
|
256ebe |
>Change-Id: I055391c5c6c34d58aef7336847f3b570cb831298
|
|
|
256ebe |
>fixes: bz#1703948
|
|
|
256ebe |
>Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
256ebe |
|
|
|
256ebe |
Change-Id: I055391c5c6c34d58aef7336847f3b570cb831298
|
|
|
256ebe |
BUG: 1714588
|
|
|
256ebe |
Signed-off-by: Mohammed Rafi KC <rkavunga@redhat.com>
|
|
|
256ebe |
Reviewed-on: https://code.engineering.redhat.com/gerrit/172801
|
|
|
256ebe |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
256ebe |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
256ebe |
---
|
|
|
256ebe |
xlators/cluster/ec/src/ec-common.c | 10 ++++++++++
|
|
|
256ebe |
xlators/cluster/ec/src/ec-common.h | 2 ++
|
|
|
256ebe |
xlators/cluster/ec/src/ec-data.c | 4 +++-
|
|
|
256ebe |
xlators/cluster/ec/src/ec-heal.c | 17 +++++++++++++++--
|
|
|
256ebe |
xlators/cluster/ec/src/ec-types.h | 1 +
|
|
|
256ebe |
xlators/cluster/ec/src/ec.c | 37 +++++++++++++++++++++++++------------
|
|
|
256ebe |
6 files changed, 56 insertions(+), 15 deletions(-)
|
|
|
256ebe |
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
|
|
|
256ebe |
index e85aa8b..9cc6395 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec-common.c
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec-common.c
|
|
|
256ebe |
@@ -2955,3 +2955,13 @@ ec_manager(ec_fop_data_t *fop, int32_t error)
|
|
|
256ebe |
|
|
|
256ebe |
__ec_manager(fop, error);
|
|
|
256ebe |
}
|
|
|
256ebe |
+
|
|
|
256ebe |
+gf_boolean_t
|
|
|
256ebe |
+__ec_is_last_fop(ec_t *ec)
|
|
|
256ebe |
+{
|
|
|
256ebe |
+ if ((list_empty(&ec->pending_fops)) &&
|
|
|
256ebe |
+ (GF_ATOMIC_GET(ec->async_fop_count) == 0)) {
|
|
|
256ebe |
+ return _gf_true;
|
|
|
256ebe |
+ }
|
|
|
256ebe |
+ return _gf_false;
|
|
|
256ebe |
+}
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec-common.h b/xlators/cluster/ec/src/ec-common.h
|
|
|
256ebe |
index e948342..bf6c97d 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec-common.h
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec-common.h
|
|
|
256ebe |
@@ -204,4 +204,6 @@ void
|
|
|
256ebe |
ec_reset_entry_healing(ec_fop_data_t *fop);
|
|
|
256ebe |
char *
|
|
|
256ebe |
ec_msg_str(ec_fop_data_t *fop);
|
|
|
256ebe |
+gf_boolean_t
|
|
|
256ebe |
+__ec_is_last_fop(ec_t *ec);
|
|
|
256ebe |
#endif /* __EC_COMMON_H__ */
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec-data.c b/xlators/cluster/ec/src/ec-data.c
|
|
|
256ebe |
index 6ef9340..8d2d9a1 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec-data.c
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec-data.c
|
|
|
256ebe |
@@ -202,11 +202,13 @@ ec_handle_last_pending_fop_completion(ec_fop_data_t *fop, gf_boolean_t *notify)
|
|
|
256ebe |
{
|
|
|
256ebe |
ec_t *ec = fop->xl->private;
|
|
|
256ebe |
|
|
|
256ebe |
+ *notify = _gf_false;
|
|
|
256ebe |
+
|
|
|
256ebe |
if (!list_empty(&fop->pending_list)) {
|
|
|
256ebe |
LOCK(&ec->lock);
|
|
|
256ebe |
{
|
|
|
256ebe |
list_del_init(&fop->pending_list);
|
|
|
256ebe |
- *notify = list_empty(&ec->pending_fops);
|
|
|
256ebe |
+ *notify = __ec_is_last_fop(ec);
|
|
|
256ebe |
}
|
|
|
256ebe |
UNLOCK(&ec->lock);
|
|
|
256ebe |
}
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c
|
|
|
256ebe |
index 8844c29..237fea2 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec-heal.c
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec-heal.c
|
|
|
256ebe |
@@ -2814,8 +2814,20 @@ int
|
|
|
256ebe |
ec_replace_heal_done(int ret, call_frame_t *heal, void *opaque)
|
|
|
256ebe |
{
|
|
|
256ebe |
ec_t *ec = opaque;
|
|
|
256ebe |
+ gf_boolean_t last_fop = _gf_false;
|
|
|
256ebe |
|
|
|
256ebe |
+ if (GF_ATOMIC_DEC(ec->async_fop_count) == 0) {
|
|
|
256ebe |
+ LOCK(&ec->lock);
|
|
|
256ebe |
+ {
|
|
|
256ebe |
+ last_fop = __ec_is_last_fop(ec);
|
|
|
256ebe |
+ }
|
|
|
256ebe |
+ UNLOCK(&ec->lock);
|
|
|
256ebe |
+ }
|
|
|
256ebe |
gf_msg_debug(ec->xl->name, 0, "getxattr on bricks is done ret %d", ret);
|
|
|
256ebe |
+
|
|
|
256ebe |
+ if (last_fop)
|
|
|
256ebe |
+ ec_pending_fops_completed(ec);
|
|
|
256ebe |
+
|
|
|
256ebe |
return 0;
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
@@ -2869,14 +2881,15 @@ ec_launch_replace_heal(ec_t *ec)
|
|
|
256ebe |
{
|
|
|
256ebe |
int ret = -1;
|
|
|
256ebe |
|
|
|
256ebe |
- if (!ec)
|
|
|
256ebe |
- return ret;
|
|
|
256ebe |
ret = synctask_new(ec->xl->ctx->env, ec_replace_brick_heal_wrap,
|
|
|
256ebe |
ec_replace_heal_done, NULL, ec);
|
|
|
256ebe |
+
|
|
|
256ebe |
if (ret < 0) {
|
|
|
256ebe |
gf_msg_debug(ec->xl->name, 0, "Heal failed for replace brick ret = %d",
|
|
|
256ebe |
ret);
|
|
|
256ebe |
+ ec_replace_heal_done(-1, NULL, ec);
|
|
|
256ebe |
}
|
|
|
256ebe |
+
|
|
|
256ebe |
return ret;
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec-types.h b/xlators/cluster/ec/src/ec-types.h
|
|
|
256ebe |
index 1c295c0..4dbf4a3 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec-types.h
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec-types.h
|
|
|
256ebe |
@@ -643,6 +643,7 @@ struct _ec {
|
|
|
256ebe |
uintptr_t xl_notify; /* Bit flag representing
|
|
|
256ebe |
notification for bricks. */
|
|
|
256ebe |
uintptr_t node_mask;
|
|
|
256ebe |
+ gf_atomic_t async_fop_count; /* Number of on going asynchronous fops. */
|
|
|
256ebe |
xlator_t **xl_list;
|
|
|
256ebe |
gf_lock_t lock;
|
|
|
256ebe |
gf_timer_t *timer;
|
|
|
256ebe |
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
|
|
|
256ebe |
index df5912c..f0d58c0 100644
|
|
|
256ebe |
--- a/xlators/cluster/ec/src/ec.c
|
|
|
256ebe |
+++ b/xlators/cluster/ec/src/ec.c
|
|
|
256ebe |
@@ -355,6 +355,7 @@ ec_notify_cbk(void *data)
|
|
|
256ebe |
ec_t *ec = data;
|
|
|
256ebe |
glusterfs_event_t event = GF_EVENT_MAXVAL;
|
|
|
256ebe |
gf_boolean_t propagate = _gf_false;
|
|
|
256ebe |
+ gf_boolean_t launch_heal = _gf_false;
|
|
|
256ebe |
|
|
|
256ebe |
LOCK(&ec->lock);
|
|
|
256ebe |
{
|
|
|
256ebe |
@@ -384,6 +385,11 @@ ec_notify_cbk(void *data)
|
|
|
256ebe |
* still bricks DOWN, they will be healed when they
|
|
|
256ebe |
* come up. */
|
|
|
256ebe |
ec_up(ec->xl, ec);
|
|
|
256ebe |
+
|
|
|
256ebe |
+ if (ec->shd.iamshd && !ec->shutdown) {
|
|
|
256ebe |
+ launch_heal = _gf_true;
|
|
|
256ebe |
+ GF_ATOMIC_INC(ec->async_fop_count);
|
|
|
256ebe |
+ }
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
propagate = _gf_true;
|
|
|
256ebe |
@@ -391,13 +397,12 @@ ec_notify_cbk(void *data)
|
|
|
256ebe |
unlock:
|
|
|
256ebe |
UNLOCK(&ec->lock);
|
|
|
256ebe |
|
|
|
256ebe |
+ if (launch_heal) {
|
|
|
256ebe |
+ /* We have just brought the volume UP, so we trigger
|
|
|
256ebe |
+ * a self-heal check on the root directory. */
|
|
|
256ebe |
+ ec_launch_replace_heal(ec);
|
|
|
256ebe |
+ }
|
|
|
256ebe |
if (propagate) {
|
|
|
256ebe |
- if ((event == GF_EVENT_CHILD_UP) && ec->shd.iamshd) {
|
|
|
256ebe |
- /* We have just brought the volume UP, so we trigger
|
|
|
256ebe |
- * a self-heal check on the root directory. */
|
|
|
256ebe |
- ec_launch_replace_heal(ec);
|
|
|
256ebe |
- }
|
|
|
256ebe |
-
|
|
|
256ebe |
default_notify(ec->xl, event, NULL);
|
|
|
256ebe |
}
|
|
|
256ebe |
}
|
|
|
256ebe |
@@ -425,7 +430,7 @@ ec_disable_delays(ec_t *ec)
|
|
|
256ebe |
{
|
|
|
256ebe |
ec->shutdown = _gf_true;
|
|
|
256ebe |
|
|
|
256ebe |
- return list_empty(&ec->pending_fops);
|
|
|
256ebe |
+ return __ec_is_last_fop(ec);
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
void
|
|
|
256ebe |
@@ -603,7 +608,10 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2)
|
|
|
256ebe |
if (event == GF_EVENT_CHILD_UP) {
|
|
|
256ebe |
/* We need to trigger a selfheal if a brick changes
|
|
|
256ebe |
* to UP state. */
|
|
|
256ebe |
- needs_shd_check = ec_set_up_state(ec, mask, mask);
|
|
|
256ebe |
+ if (ec_set_up_state(ec, mask, mask) && ec->shd.iamshd &&
|
|
|
256ebe |
+ !ec->shutdown) {
|
|
|
256ebe |
+ needs_shd_check = _gf_true;
|
|
|
256ebe |
+ }
|
|
|
256ebe |
} else if (event == GF_EVENT_CHILD_DOWN) {
|
|
|
256ebe |
ec_set_up_state(ec, mask, 0);
|
|
|
256ebe |
}
|
|
|
256ebe |
@@ -633,17 +641,21 @@ ec_notify(xlator_t *this, int32_t event, void *data, void *data2)
|
|
|
256ebe |
}
|
|
|
256ebe |
} else {
|
|
|
256ebe |
propagate = _gf_false;
|
|
|
256ebe |
+ needs_shd_check = _gf_false;
|
|
|
256ebe |
+ }
|
|
|
256ebe |
+
|
|
|
256ebe |
+ if (needs_shd_check) {
|
|
|
256ebe |
+ GF_ATOMIC_INC(ec->async_fop_count);
|
|
|
256ebe |
}
|
|
|
256ebe |
}
|
|
|
256ebe |
unlock:
|
|
|
256ebe |
UNLOCK(&ec->lock);
|
|
|
256ebe |
|
|
|
256ebe |
done:
|
|
|
256ebe |
+ if (needs_shd_check) {
|
|
|
256ebe |
+ ec_launch_replace_heal(ec);
|
|
|
256ebe |
+ }
|
|
|
256ebe |
if (propagate) {
|
|
|
256ebe |
- if (needs_shd_check && ec->shd.iamshd) {
|
|
|
256ebe |
- ec_launch_replace_heal(ec);
|
|
|
256ebe |
- }
|
|
|
256ebe |
-
|
|
|
256ebe |
error = default_notify(this, event, data);
|
|
|
256ebe |
}
|
|
|
256ebe |
|
|
|
256ebe |
@@ -705,6 +717,7 @@ init(xlator_t *this)
|
|
|
256ebe |
ec->xl = this;
|
|
|
256ebe |
LOCK_INIT(&ec->lock);
|
|
|
256ebe |
|
|
|
256ebe |
+ GF_ATOMIC_INIT(ec->async_fop_count, 0);
|
|
|
256ebe |
INIT_LIST_HEAD(&ec->pending_fops);
|
|
|
256ebe |
INIT_LIST_HEAD(&ec->heal_waiting);
|
|
|
256ebe |
INIT_LIST_HEAD(&ec->healing);
|
|
|
256ebe |
--
|
|
|
256ebe |
1.8.3.1
|
|
|
256ebe |
|