summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-name.c
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-09-20 12:16:06 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2017-10-09 06:23:08 +0000
commit20fa80057eb430fd72b4fa31b9b65598b8ec1265 (patch)
tree3e1dd8c0cb7a394ebcdc7004ccaddb935c67e4d6 /xlators/cluster/afr/src/afr-self-heal-name.c
parent938addeb7ec634e431c2c8c0a768a2a9ed056c0d (diff)
afr: heal gfid as a part of entry heal
Problem: If a brick crashes after an entry (file or dir) is created but before gfid is assigned, the good bricks will have pending entry heal xattrs but the heal won't complete because afr_selfheal_recreate_entry() tries to create the entry again and it fails with EEXIST. Fix: We could have fixed posx_mknod/mkdir etc to assign the gfid if the file already exists but the right thing to do seems to be to trigger a lookup on the bad brick and let it heal the gfid instead of winding an mknod/mkdir in the first place. Change-Id: I82f76665a7541f1893ef8d847b78af6466aff1ff BUG: 1493415 Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-name.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c64
1 files changed, 4 insertions, 60 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
index 2aad4c75bee..352d151207e 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -18,50 +18,18 @@ int
__afr_selfheal_assign_gfid (xlator_t *this, inode_t *parent, uuid_t pargfid,
const char *bname, inode_t *inode,
struct afr_reply *replies, void *gfid,
- unsigned char *locked_on,
+ unsigned char *locked_on, int source,
gf_boolean_t is_gfid_absent)
{
int ret = 0;
int up_count = 0;
int locked_count = 0;
- int i = 0;
afr_private_t *priv = NULL;
- dict_t *xdata = NULL;
- loc_t loc = {0, };
- call_frame_t *new_frame = NULL;
- afr_local_t *new_local = NULL;
- unsigned char *wind_on = NULL;
priv = this->private;
- wind_on = alloca0 (priv->child_count);
-
- new_frame = afr_frame_create (this);
- if (!new_frame) {
- ret = -ENOMEM;
- goto out;
- }
-
- new_local = new_frame->local;
gf_uuid_copy (parent->gfid, pargfid);
- xdata = dict_new ();
- if (!xdata) {
- ret = -ENOMEM;
- goto out;
- }
-
- ret = dict_set_static_bin (xdata, "gfid-req", gfid, 16);
- if (ret) {
- ret = -ENOMEM;
- goto out;
- }
-
- loc.parent = inode_ref (parent);
- loc.inode = inode_ref (inode);
- gf_uuid_copy (loc.pargfid, pargfid);
- loc.name = bname;
-
if (is_gfid_absent) {
/* Ensure all children of AFR are up before performing gfid heal, to
* guard against the possibility of gfid split brain. */
@@ -79,34 +47,10 @@ __afr_selfheal_assign_gfid (xlator_t *this, inode_t *parent, uuid_t pargfid,
}
}
- /* gfid heal on those subvolumes that do not have gfid associated
- * with the inode and update those replies.
- */
- for (i = 0; i < priv->child_count; i++) {
- if (replies[i].valid && replies[i].op_ret == 0 &&
- !gf_uuid_is_null (replies[i].poststat.ia_gfid) &&
- !gf_uuid_compare (replies[i].poststat.ia_gfid, gfid))
- continue;
- wind_on[i] = 1;
- }
-
- AFR_ONLIST (wind_on, new_frame, afr_selfheal_discover_cbk, lookup,
- &loc, xdata);
-
- for (i = 0; i < priv->child_count; i++) {
- if (!wind_on[i])
- continue;
- afr_reply_wipe (&replies[i]);
- afr_reply_copy (&replies[i], &new_local->replies[i]);
- }
+ afr_lookup_and_heal_gfid (this, parent, bname, inode, replies, source,
+ gfid);
out:
- loc_wipe (&loc);
- if (xdata)
- dict_unref (xdata);
- if (new_frame)
- AFR_STACK_DESTROY (new_frame);
-
return ret;
}
@@ -481,7 +425,7 @@ __afr_selfheal_name_do (call_frame_t *frame, xlator_t *this, inode_t *parent,
is_gfid_absent = (gfid_idx == -1) ? _gf_true : _gf_false;
ret = __afr_selfheal_assign_gfid (this, parent, pargfid, bname, inode,
- replies, gfid, locked_on,
+ replies, gfid, locked_on, source,
is_gfid_absent);
if (ret)
return ret;