|
|
3604df |
From 547bd2260fba782cb0a7a54589f9b6f75226776a Mon Sep 17 00:00:00 2001
|
|
|
3604df |
From: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Date: Mon, 5 Dec 2016 13:20:51 +0530
|
|
|
3604df |
Subject: [PATCH 232/235] cluster/afr: Remove backward compatibility for locks
|
|
|
3604df |
with v1
|
|
|
3604df |
|
|
|
3604df |
When we have cascading locks with same lk-owner there is a possibility for
|
|
|
3604df |
a deadlock to happen. One example is as follows:
|
|
|
3604df |
|
|
|
3604df |
self-heal takes a lock in data-domain for big name with 256 chars of "aaaa...a"
|
|
|
3604df |
and starts heal in a 3-way replication when brick-0 is offline and healing from
|
|
|
3604df |
brick-1 to brick-2 is in progress. So this lock is active on brick-1 and
|
|
|
3604df |
brick-2. Now brick-0 comes online and an operation wants to take full lock and
|
|
|
3604df |
the lock is granted at brick-0 and it is waiting for lock on brick-1. As part
|
|
|
3604df |
of entry healing it takes full locks on all the available bricks and then
|
|
|
3604df |
proceeds with healing the entry. Now this lock will start waiting on brick-0
|
|
|
3604df |
because some other operation already has a granted lock on it. This leads to a
|
|
|
3604df |
deadlock. Operation is waiting for unlock on "aaaa..." by heal where as heal is
|
|
|
3604df |
waiting for the operation to unlock on brick-0. Initially I thought this is
|
|
|
3604df |
happening because healing is trying to take a lock on all the available bricks
|
|
|
3604df |
instead of just the bricks that are participating in heal. But later realized
|
|
|
3604df |
that same kind of deadlock can happen if a brick goes down after the heal
|
|
|
3604df |
starts but comes back before it completes. So the essential problem is the
|
|
|
3604df |
cascading locks with same lk-owner which were added for backward compatibility
|
|
|
3604df |
with afr-v1 which can be safely removed now that versions with afr-v1 are
|
|
|
3604df |
already EOL. This patch removes the compatibility with v1 which requires
|
|
|
3604df |
cascading locks with same lk-owner.
|
|
|
3604df |
|
|
|
3604df |
In the next version we can make locking-scheme option a dummy and switch
|
|
|
3604df |
completely to v2.
|
|
|
3604df |
|
|
|
3604df |
>BUG: 1401404
|
|
|
3604df |
>Change-Id: Ic9afab8260f5ff4dff5329eb0429811bcb879079
|
|
|
3604df |
>Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
>Reviewed-on: http://review.gluster.org/16024
|
|
|
3604df |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>Reviewed-by: Ravishankar N <ravishankar@redhat.com>
|
|
|
3604df |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
3604df |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
3604df |
|
|
|
3604df |
BUG: 1398188
|
|
|
3604df |
Change-Id: Iae73b761f8247af1bb46f2ab82d5c7f7e86b8c17
|
|
|
3604df |
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
|
|
|
3604df |
Reviewed-on: https://code.engineering.redhat.com/gerrit/92520
|
|
|
3604df |
---
|
|
|
3604df |
xlators/cluster/afr/src/afr-common.c | 48 +++++++--------------------
|
|
|
3604df |
xlators/cluster/afr/src/afr-self-heal-entry.c | 34 +------------------
|
|
|
3604df |
2 files changed, 13 insertions(+), 69 deletions(-)
|
|
|
3604df |
|
|
|
3604df |
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
|
|
|
3604df |
index 55f10e7..b825b19 100644
|
|
|
3604df |
--- a/xlators/cluster/afr/src/afr-common.c
|
|
|
3604df |
+++ b/xlators/cluster/afr/src/afr-common.c
|
|
|
3604df |
@@ -5218,7 +5218,6 @@ afr_selfheal_locked_data_inspect (call_frame_t *frame, xlator_t *this,
|
|
|
3604df |
gf_boolean_t *pflag)
|
|
|
3604df |
{
|
|
|
3604df |
int ret = -1;
|
|
|
3604df |
- unsigned char *locked_on = NULL;
|
|
|
3604df |
unsigned char *data_lock = NULL;
|
|
|
3604df |
unsigned char *sources = NULL;
|
|
|
3604df |
unsigned char *sinks = NULL;
|
|
|
3604df |
@@ -5227,12 +5226,8 @@ afr_selfheal_locked_data_inspect (call_frame_t *frame, xlator_t *this,
|
|
|
3604df |
afr_private_t *priv = NULL;
|
|
|
3604df |
fd_t *fd = NULL;
|
|
|
3604df |
struct afr_reply *locked_replies = NULL;
|
|
|
3604df |
- gf_boolean_t granular_locks = _gf_false;
|
|
|
3604df |
|
|
|
3604df |
priv = this->private;
|
|
|
3604df |
- if (strcmp ("granular", priv->locking_scheme) == 0)
|
|
|
3604df |
- granular_locks = _gf_true;
|
|
|
3604df |
- locked_on = alloca0 (priv->child_count);
|
|
|
3604df |
data_lock = alloca0 (priv->child_count);
|
|
|
3604df |
sources = alloca0 (priv->child_count);
|
|
|
3604df |
sinks = alloca0 (priv->child_count);
|
|
|
3604df |
@@ -5253,42 +5248,23 @@ afr_selfheal_locked_data_inspect (call_frame_t *frame, xlator_t *this,
|
|
|
3604df |
|
|
|
3604df |
locked_replies = alloca0 (sizeof (*locked_replies) * priv->child_count);
|
|
|
3604df |
|
|
|
3604df |
- if (!granular_locks) {
|
|
|
3604df |
- ret = afr_selfheal_tryinodelk (frame, this, inode,
|
|
|
3604df |
- priv->sh_domain, 0, 0, locked_on);
|
|
|
3604df |
- }
|
|
|
3604df |
+ ret = afr_selfheal_inodelk (frame, this, inode, this->name,
|
|
|
3604df |
+ 0, 0, data_lock);
|
|
|
3604df |
{
|
|
|
3604df |
- if (!granular_locks && (ret == 0)) {
|
|
|
3604df |
+ if (ret == 0) {
|
|
|
3604df |
ret = -afr_final_errno (frame->local, priv);
|
|
|
3604df |
if (ret == 0)
|
|
|
3604df |
- ret = -ENOTCONN;/* all invalid responses */
|
|
|
3604df |
+ ret = -ENOTCONN; /* all invalid responses */
|
|
|
3604df |
goto out;
|
|
|
3604df |
}
|
|
|
3604df |
- ret = afr_selfheal_inodelk (frame, this, inode, this->name,
|
|
|
3604df |
- 0, 0, data_lock);
|
|
|
3604df |
- {
|
|
|
3604df |
- if (ret == 0) {
|
|
|
3604df |
- ret = -afr_final_errno (frame->local, priv);
|
|
|
3604df |
- if (ret == 0)
|
|
|
3604df |
- ret = -ENOTCONN;
|
|
|
3604df |
- /* all invalid responses */
|
|
|
3604df |
- goto unlock;
|
|
|
3604df |
- }
|
|
|
3604df |
- ret = __afr_selfheal_data_prepare (frame, this, inode,
|
|
|
3604df |
- data_lock, sources,
|
|
|
3604df |
- sinks, healed_sinks,
|
|
|
3604df |
- undid_pending,
|
|
|
3604df |
- locked_replies,
|
|
|
3604df |
- pflag);
|
|
|
3604df |
- *dsh = afr_decide_heal_info (priv, sources, ret);
|
|
|
3604df |
- }
|
|
|
3604df |
- afr_selfheal_uninodelk (frame, this, inode, this->name, 0, 0,
|
|
|
3604df |
- data_lock);
|
|
|
3604df |
- }
|
|
|
3604df |
-unlock:
|
|
|
3604df |
- if (!granular_locks)
|
|
|
3604df |
- afr_selfheal_uninodelk (frame, this, inode, priv->sh_domain, 0,
|
|
|
3604df |
- 0, locked_on);
|
|
|
3604df |
+ ret = __afr_selfheal_data_prepare (frame, this, inode,
|
|
|
3604df |
+ data_lock, sources, sinks,
|
|
|
3604df |
+ healed_sinks, undid_pending,
|
|
|
3604df |
+ locked_replies, pflag);
|
|
|
3604df |
+ *dsh = afr_decide_heal_info (priv, sources, ret);
|
|
|
3604df |
+ }
|
|
|
3604df |
+ afr_selfheal_uninodelk (frame, this, inode, this->name, 0, 0,
|
|
|
3604df |
+ data_lock);
|
|
|
3604df |
out:
|
|
|
3604df |
if (locked_replies)
|
|
|
3604df |
afr_replies_wipe (locked_replies, priv->child_count);
|
|
|
3604df |
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
|
|
|
3604df |
index 6b5340a..2efeedf 100644
|
|
|
3604df |
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
|
|
|
3604df |
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
|
|
|
3604df |
@@ -21,11 +21,6 @@
|
|
|
3604df |
* this name can ever come, entry-lock with this name is going to prevent
|
|
|
3604df |
* self-heals from older versions while the granular entry-self-heal is going
|
|
|
3604df |
* on in newer version.*/
|
|
|
3604df |
-#define LONG_FILENAME "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
|
|
|
3604df |
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
|
|
|
3604df |
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
|
|
|
3604df |
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"\
|
|
|
3604df |
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
|
|
3604df |
|
|
|
3604df |
static int
|
|
|
3604df |
afr_selfheal_entry_delete (xlator_t *this, inode_t *dir, const char *name,
|
|
|
3604df |
@@ -1051,21 +1046,16 @@ afr_selfheal_entry (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
3604df |
{
|
|
|
3604df |
afr_private_t *priv = NULL;
|
|
|
3604df |
unsigned char *locked_on = NULL;
|
|
|
3604df |
- unsigned char *long_name_locked = NULL;
|
|
|
3604df |
fd_t *fd = NULL;
|
|
|
3604df |
int ret = 0;
|
|
|
3604df |
- gf_boolean_t granular_locks = _gf_false;
|
|
|
3604df |
|
|
|
3604df |
priv = this->private;
|
|
|
3604df |
- if (strcmp ("granular", priv->locking_scheme) == 0)
|
|
|
3604df |
- granular_locks = _gf_true;
|
|
|
3604df |
|
|
|
3604df |
fd = afr_selfheal_data_opendir (this, inode);
|
|
|
3604df |
if (!fd)
|
|
|
3604df |
return -EIO;
|
|
|
3604df |
|
|
|
3604df |
locked_on = alloca0 (priv->child_count);
|
|
|
3604df |
- long_name_locked = alloca0 (priv->child_count);
|
|
|
3604df |
|
|
|
3604df |
ret = afr_selfheal_tie_breaker_entrylk (frame, this, inode,
|
|
|
3604df |
priv->sh_domain, NULL,
|
|
|
3604df |
@@ -1085,29 +1075,7 @@ afr_selfheal_entry (call_frame_t *frame, xlator_t *this, inode_t *inode)
|
|
|
3604df |
goto unlock;
|
|
|
3604df |
}
|
|
|
3604df |
|
|
|
3604df |
- if (!granular_locks) {
|
|
|
3604df |
- ret = afr_selfheal_tryentrylk (frame, this, inode,
|
|
|
3604df |
- this->name, LONG_FILENAME,
|
|
|
3604df |
- long_name_locked);
|
|
|
3604df |
- }
|
|
|
3604df |
- {
|
|
|
3604df |
- if (!granular_locks && ret < 1) {
|
|
|
3604df |
- gf_msg_debug (this->name, 0, "%s: Skipping"
|
|
|
3604df |
- " entry self-heal as only %d "
|
|
|
3604df |
- "sub-volumes could be "
|
|
|
3604df |
- "locked in special-filename "
|
|
|
3604df |
- "domain",
|
|
|
3604df |
- uuid_utoa (fd->inode->gfid),
|
|
|
3604df |
- ret);
|
|
|
3604df |
- ret = -ENOTCONN;
|
|
|
3604df |
- goto unlock;
|
|
|
3604df |
- }
|
|
|
3604df |
- ret = __afr_selfheal_entry (frame, this, fd, locked_on);
|
|
|
3604df |
- }
|
|
|
3604df |
- if (!granular_locks)
|
|
|
3604df |
- afr_selfheal_unentrylk (frame, this, inode, this->name,
|
|
|
3604df |
- LONG_FILENAME, long_name_locked,
|
|
|
3604df |
- NULL);
|
|
|
3604df |
+ ret = __afr_selfheal_entry (frame, this, fd, locked_on);
|
|
|
3604df |
}
|
|
|
3604df |
unlock:
|
|
|
3604df |
afr_selfheal_unentrylk (frame, this, inode, priv->sh_domain, NULL,
|
|
|
3604df |
--
|
|
|
3604df |
2.9.3
|
|
|
3604df |
|