diff options
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-entry.c')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 73 |
1 files changed, 19 insertions, 54 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index cb682a7dccc..0cf65009c5f 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -69,7 +69,8 @@ afr_selfheal_entry_delete (xlator_t *this, inode_t *dir, const char *name, int afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir, const char *name, inode_t *inode, - struct afr_reply *replies) + struct afr_reply *replies, + unsigned char *newentry) { int ret = 0; loc_t loc = {0,}; @@ -80,7 +81,6 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir, char *linkname = NULL; mode_t mode = 0; struct iatt newent = {0,}; - priv = this->private; xdata = dict_new(); @@ -111,6 +111,8 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir, switch (iatt->ia_type) { case IA_IFDIR: ret = syncop_mkdir (priv->children[dst], &loc, mode, xdata, 0); + if (ret == 0) + newentry[dst] = 1; break; case IA_IFLNK: ret = syncop_lookup (priv->children[dst], &srcloc, 0, 0, 0, 0); @@ -123,7 +125,9 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir, goto out; ret = syncop_symlink (priv->children[dst], &loc, linkname, xdata, NULL); - } + if (ret == 0) + newentry[dst] = 1; + } break; default: ret = dict_set_int32 (xdata, GLUSTERFS_INTERNAL_FOP_KEY, 1); @@ -131,9 +135,9 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir, goto out; ret = syncop_mknod (priv->children[dst], &loc, mode, iatt->ia_rdev, xdata, &newent); - if (ret == 0 && iatt->ia_size && !newent.ia_size) { + if (ret == 0 && newent.ia_nlink == 1) { /* New entry created. Mark @dst pending on all sources */ - ret = 1; + newentry[dst] = 1; } break; } @@ -148,49 +152,6 @@ out: static int -afr_selfheal_newentry_mark (call_frame_t *frame, xlator_t *this, inode_t *inode, - int source, struct afr_reply *replies, - unsigned char *sources, unsigned char *newentry) -{ - int ret = 0; - int i = 0; - afr_private_t *priv = NULL; - dict_t *xattr = NULL; - int **changelog = NULL; - int idx = 0; - - priv = this->private; - - idx = afr_index_for_transaction_type (AFR_DATA_TRANSACTION); - - uuid_copy (inode->gfid, replies[source].poststat.ia_gfid); - - changelog = afr_matrix_create (priv->child_count, AFR_NUM_CHANGE_LOGS); - - xattr = dict_new(); - if (!xattr) - return -ENOMEM; - - for (i = 0; i < priv->child_count; i++) { - if (!newentry[i]) - continue; - changelog[i][idx] = hton32(1); - } - - afr_set_pending_dict (priv, xattr, changelog); - - for (i = 0; i < priv->child_count; i++) { - if (!sources[i]) - continue; - afr_selfheal_post_op (frame, this, inode, i, xattr); - } - - dict_unref (xattr); - return ret; -} - - -static int __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, char *name, inode_t *inode, int source, unsigned char *sources, unsigned char *healed_sinks, @@ -202,6 +163,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, unsigned char *newentry = NULL; priv = this->private; + newentry = alloca0 (priv->child_count); if (!replies[source].valid) @@ -221,11 +183,7 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = afr_selfheal_recreate_entry (this, i, source, fd->inode, name, inode, - replies); - if (ret > 0) { - newentry[i] = 1; - ret = 0; - } + replies, newentry); } if (ret < 0) break; @@ -248,9 +206,12 @@ __afr_selfheal_merge_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, afr_private_t *priv = NULL; int i = 0; int source = -1; + unsigned char *newentry = NULL; priv = this->private; + newentry = alloca0 (priv->child_count); + for (i = 0; i < priv->child_count; i++) { if (replies[i].valid && replies[i].op_ret == 0) { source = i; @@ -271,9 +232,13 @@ __afr_selfheal_merge_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd, continue; ret = afr_selfheal_recreate_entry (this, i, source, fd->inode, - name, inode, replies); + name, inode, replies, + newentry); } + if (AFR_COUNT (newentry, priv->child_count)) + afr_selfheal_newentry_mark (frame, this, inode, source, replies, + sources, newentry); return ret; } |