summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorKevin Vigor <kvigor@fb.com>2017-03-16 10:35:25 -0700
committerKevin Vigor <kvigor@fb.com>2017-03-16 10:35:25 -0700
commitae361e8339cc51966ebd222d7fb9046e936d56f5 (patch)
tree9c893ed88dc4086238e90e59c6ab37aee6cd308a /xlators/cluster
parent35cfc2853a617a8ee8ed499b6c989b5bed41b2b7 (diff)
parent68d5c0ef243a9f27939128d1d12d519167ad988a (diff)
Merge remote-tracking branch 'origin/release-3.8' into merge-3.8
Change-Id: Ib336c2ada491c2d2fcbbbe6865f9eb975a405b36
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c60
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c56
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c56
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c7
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c19
-rw-r--r--xlators/cluster/afr/src/afr-self-heal.h17
-rw-r--r--xlators/cluster/dht/src/dht-common.c19
-rw-r--r--xlators/cluster/ec/src/ec-common.c15
8 files changed, 141 insertions, 108 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index bc3a3ee5ca1..549c3c1ba71 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -26,6 +26,8 @@ afr_selfheal_post_op_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
+ local->op_ret = op_ret;
+ local->op_errno = op_errno;
syncbarrier_wake (&local->barrier);
return 0;
@@ -39,6 +41,7 @@ afr_selfheal_post_op (call_frame_t *frame, xlator_t *this, inode_t *inode,
afr_private_t *priv = NULL;
afr_local_t *local = NULL;
loc_t loc = {0, };
+ int ret = 0;
priv = this->private;
local = frame->local;
@@ -46,15 +49,20 @@ afr_selfheal_post_op (call_frame_t *frame, xlator_t *this, inode_t *inode,
loc.inode = inode_ref (inode);
gf_uuid_copy (loc.gfid, inode->gfid);
+ local->op_ret = 0;
+
STACK_WIND (frame, afr_selfheal_post_op_cbk, priv->children[subvol],
priv->children[subvol]->fops->xattrop, &loc,
GF_XATTROP_ADD_ARRAY, xattr, xdata);
syncbarrier_wait (&local->barrier, 1);
+ if (local->op_ret < 0)
+ ret = -local->op_errno;
loc_wipe (&loc);
+ local->op_ret = 0;
- return 0;
+ return ret;
}
int
@@ -78,6 +86,49 @@ afr_check_stale_error (struct afr_reply *replies, afr_private_t *priv)
return -op_errno;
}
+int
+afr_sh_generic_fop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, struct iatt *pre, struct iatt *post,
+ dict_t *xdata)
+{
+ int i = (long) cookie;
+ afr_local_t *local = NULL;
+
+ local = frame->local;
+
+ local->replies[i].valid = 1;
+ local->replies[i].op_ret = op_ret;
+ local->replies[i].op_errno = op_errno;
+ if (pre)
+ local->replies[i].prestat = *pre;
+ if (post)
+ local->replies[i].poststat = *post;
+ if (xdata)
+ local->replies[i].xdata = dict_ref (xdata);
+
+ syncbarrier_wake (&local->barrier);
+
+ return 0;
+}
+
+int
+afr_selfheal_restore_time (call_frame_t *frame, xlator_t *this, inode_t *inode,
+ int source, unsigned char *healed_sinks,
+ struct afr_reply *replies)
+{
+ loc_t loc = {0, };
+
+ loc.inode = inode_ref (inode);
+ gf_uuid_copy (loc.gfid, inode->gfid);
+
+ AFR_ONLIST (healed_sinks, frame, afr_sh_generic_fop_cbk, setattr, &loc,
+ &replies[source].poststat,
+ (GF_SET_ATTR_ATIME|GF_SET_ATTR_MTIME), NULL);
+
+ loc_wipe (&loc);
+
+ return 0;
+}
dict_t *
afr_selfheal_output_xattr (xlator_t *this, gf_boolean_t is_full_crawl,
@@ -1937,8 +1988,10 @@ afr_selfheal_newentry_mark (call_frame_t *frame, xlator_t *this, inode_t *inode,
changelog = afr_mark_pending_changelog (priv, newentry, xattr,
replies[source].poststat.ia_type);
- if (!changelog)
+ if (!changelog) {
+ ret = -ENOMEM;
goto out;
+ }
/* Pre-compute how many sources we have, if we made it in here
* without any sources defined, we are doing a conservative
@@ -1958,7 +2011,8 @@ afr_selfheal_newentry_mark (call_frame_t *frame, xlator_t *this, inode_t *inode,
if (!sources[i] && source_count) {
continue;
}
- afr_selfheal_post_op (frame, this, inode, i, xattr, NULL);
+ ret |= afr_selfheal_post_op (frame, this, inode, i, xattr,
+ NULL);
}
out:
if (changelog)
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 9c12e433097..98ee8059640 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -47,33 +47,6 @@ __checksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
return 0;
}
-
-static int
-attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, struct iatt *pre, struct iatt *post,
- dict_t *xdata)
-{
- int i = (long) cookie;
- afr_local_t *local = NULL;
-
- local = frame->local;
-
- local->replies[i].valid = 1;
- local->replies[i].op_ret = op_ret;
- local->replies[i].op_errno = op_errno;
- if (pre)
- local->replies[i].prestat = *pre;
- if (post)
- local->replies[i].poststat = *post;
- if (xdata)
- local->replies[i].xdata = dict_ref (xdata);
-
- syncbarrier_wake (&local->barrier);
-
- return 0;
-}
-
-
static gf_boolean_t
__afr_can_skip_data_block_heal (call_frame_t *frame, xlator_t *this, fd_t *fd,
int source, unsigned char *healed_sinks,
@@ -307,7 +280,8 @@ afr_selfheal_data_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (!priv->ensure_durability)
return 0;
- AFR_ONLIST (healed_sinks, frame, attr_cbk, fsync, fd, 0, NULL);
+ AFR_ONLIST (healed_sinks, frame, afr_sh_generic_fop_cbk, fsync, fd, 0,
+ NULL);
for (i = 0; i < priv->child_count; i++)
if (healed_sinks[i] && local->replies[i].op_ret != 0)
@@ -318,27 +292,6 @@ afr_selfheal_data_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd,
return 0;
}
-
-static int
-afr_selfheal_data_restore_time (call_frame_t *frame, xlator_t *this,
- inode_t *inode, int source,
- unsigned char *healed_sinks,
- struct afr_reply *replies)
-{
- loc_t loc = {0, };
-
- loc.inode = inode_ref (inode);
- gf_uuid_copy (loc.gfid, inode->gfid);
-
- AFR_ONLIST (healed_sinks, frame, attr_cbk, setattr, &loc,
- &replies[source].poststat,
- (GF_SET_ATTR_ATIME|GF_SET_ATTR_MTIME), NULL);
-
- loc_wipe (&loc);
-
- return 0;
-}
-
static int
afr_data_self_heal_type_get (afr_private_t *priv, unsigned char *healed_sinks,
int source, struct afr_reply *replies)
@@ -443,7 +396,8 @@ __afr_selfheal_truncate_sinks (call_frame_t *frame, xlator_t *this,
healed_sinks[ARBITER_BRICK_INDEX] = 0;
}
- AFR_ONLIST (healed_sinks, frame, attr_cbk, ftruncate, fd, size, NULL);
+ AFR_ONLIST (healed_sinks, frame, afr_sh_generic_fop_cbk, ftruncate, fd,
+ size, NULL);
for (i = 0; i < priv->child_count; i++)
if (healed_sinks[i] && local->replies[i].op_ret == -1)
@@ -780,7 +734,7 @@ unlock:
if (ret)
goto out;
restore_time:
- afr_selfheal_data_restore_time (frame, this, fd->inode, source,
+ afr_selfheal_restore_time (frame, this, fd->inode, source,
healed_sinks, locked_replies);
if (!is_arbiter_the_only_sink) {
diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c
index 12a5940e7cd..09f26690588 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -75,26 +75,29 @@ 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,
+afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
+ unsigned char *sources, inode_t *dir,
const char *name, inode_t *inode,
- struct afr_reply *replies,
- unsigned char *newentry)
+ struct afr_reply *replies)
{
int ret = 0;
loc_t loc = {0,};
loc_t srcloc = {0,};
+ xlator_t *this = frame->this;
afr_private_t *priv = NULL;
dict_t *xdata = NULL;
struct iatt *iatt = NULL;
char *linkname = NULL;
mode_t mode = 0;
struct iatt newent = {0,};
- priv = this->private;
+ unsigned char *newentry = NULL;
+ priv = this->private;
xdata = dict_new();
if (!xdata)
return -ENOMEM;
+ newentry = alloca0 (priv->child_count);
loc.parent = inode_ref (dir);
gf_uuid_copy (loc.pargfid, dir->gfid);
loc.name = name;
@@ -113,6 +116,15 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir,
srcloc.inode = inode_ref (inode);
gf_uuid_copy (srcloc.gfid, iatt->ia_gfid);
+ if (iatt->ia_type != IA_IFDIR)
+ ret = syncop_lookup (priv->children[dst], &srcloc, 0, 0, 0, 0);
+ if (iatt->ia_type == IA_IFDIR || ret == -ENOENT || ret == -ESTALE) {
+ newentry[dst] = 1;
+ ret = afr_selfheal_newentry_mark (frame, this, inode, source,
+ replies, sources, newentry);
+ if (ret)
+ goto out;
+ }
mode = st_mode_from_ia (iatt->ia_prot, iatt->ia_type);
@@ -120,12 +132,9 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir,
case IA_IFDIR:
ret = syncop_mkdir (priv->children[dst], &loc, mode, 0,
xdata, NULL);
- if (ret == 0)
- newentry[dst] = 1;
break;
case IA_IFLNK:
- ret = syncop_lookup (priv->children[dst], &srcloc, 0, 0, 0, 0);
- if (ret == 0) {
+ if (!newentry[dst]) {
ret = syncop_link (priv->children[dst], &srcloc, &loc,
&newent, NULL, NULL);
} else {
@@ -135,8 +144,6 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir,
goto out;
ret = syncop_symlink (priv->children[dst], &loc,
linkname, NULL, xdata, NULL);
- if (ret == 0)
- newentry[dst] = 1;
}
break;
default:
@@ -146,10 +153,6 @@ afr_selfheal_recreate_entry (xlator_t *this, int dst, int source, inode_t *dir,
ret = syncop_mknod (priv->children[dst], &loc, mode,
makedev (ia_major(iatt->ia_rdev), ia_minor (iatt->ia_rdev)),
&newent, xdata, NULL);
- if (ret == 0 && newent.ia_nlink == 1) {
- /* New entry created. Mark @dst pending on all sources */
- newentry[dst] = 1;
- }
break;
}
@@ -172,12 +175,9 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = 0;
afr_private_t *priv = NULL;
int i = 0;
- unsigned char *newentry = NULL;
priv = this->private;
- newentry = alloca0 (priv->child_count);
-
if (!replies[source].valid)
return -EIO;
@@ -200,17 +200,15 @@ __afr_selfheal_heal_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
replies[source].poststat.ia_gfid))
continue;
- ret = afr_selfheal_recreate_entry (this, i, source,
- fd->inode, name, inode,
- replies, newentry);
+ ret = afr_selfheal_recreate_entry (frame, i, source,
+ sources, fd->inode,
+ name, inode,
+ replies);
}
if (ret < 0)
break;
}
- if (AFR_COUNT (newentry, priv->child_count))
- afr_selfheal_newentry_mark (frame, this, inode, source, replies,
- sources, newentry);
return ret;
}
@@ -278,13 +276,10 @@ __afr_selfheal_merge_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
int ret = 0;
int i = 0;
int source = -1;
- unsigned char *newentry = NULL;
afr_private_t *priv = 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;
@@ -319,14 +314,11 @@ __afr_selfheal_merge_dirent (call_frame_t *frame, xlator_t *this, fd_t *fd,
if (replies[i].op_errno != ENOENT)
continue;
- ret = afr_selfheal_recreate_entry (this, i, source, fd->inode,
- name, inode, replies,
- newentry);
+ ret = afr_selfheal_recreate_entry (frame, i, source, sources,
+ fd->inode, name, inode,
+ replies);
}
- if (AFR_COUNT (newentry, priv->child_count))
- afr_selfheal_newentry_mark (frame, this, inode, source, replies,
- sources, newentry);
return ret;
}
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index a67717bf9d4..d5d95ef8852 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -427,6 +427,13 @@ afr_selfheal_metadata (call_frame_t *frame, xlator_t *this, inode_t *inode)
if (ret)
goto unlock;
+ /* Restore atime/mtime for files that don't need data heal as
+ * restoring timestamps happens only as a part of data-heal.
+ */
+ if (!IA_ISREG (locked_replies[source].poststat.ia_type))
+ afr_selfheal_restore_time (frame, this, inode, source,
+ healed_sinks, locked_replies);
+
ret = afr_selfheal_undo_pending (frame, this, inode, sources,
sinks, healed_sinks,
undid_pending,
diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c
index 3445ecccf9c..b28ce4170f1 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -109,12 +109,10 @@ __afr_selfheal_name_impunge (call_frame_t *frame, xlator_t *this,
int i = 0;
afr_private_t *priv = NULL;
int ret = 0;
- unsigned char *newentry = NULL;
unsigned char *sources = NULL;
priv = this->private;
- newentry = alloca0 (priv->child_count);
sources = alloca0 (priv->child_count);
gf_uuid_copy (parent->gfid, pargfid);
@@ -128,15 +126,17 @@ __afr_selfheal_name_impunge (call_frame_t *frame, xlator_t *this,
sources[i] = 1;
continue;
}
+ }
+
+ for (i = 0; i < priv->child_count; i++) {
+ if (sources[i])
+ continue;
- ret |= afr_selfheal_recreate_entry (this, i, gfid_idx, parent,
- bname, inode, replies,
- newentry);
+ ret |= afr_selfheal_recreate_entry (frame, i, gfid_idx, sources,
+ parent, bname, inode,
+ replies);
}
- if (AFR_COUNT (newentry, priv->child_count))
- afr_selfheal_newentry_mark (frame, this, inode, gfid_idx, replies,
- sources, newentry);
return ret;
}
@@ -457,8 +457,7 @@ __afr_selfheal_name_do (call_frame_t *frame, xlator_t *this, inode_t *parent,
}
ret = __afr_selfheal_name_impunge (frame, this, parent, pargfid,
- bname, inode,
- replies, gfid_idx);
+ bname, inode, replies, gfid_idx);
if (ret == -EIO)
ret = -1;
diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h
index a33905033cc..0a3d6482ca3 100644
--- a/xlators/cluster/afr/src/afr-self-heal.h
+++ b/xlators/cluster/afr/src/afr-self-heal.h
@@ -166,6 +166,15 @@ afr_selfheal_extract_xattr (xlator_t *this, struct afr_reply *replies,
afr_transaction_type type, int *dirty, int **matrix);
int
+afr_sh_generic_fop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata);
+
+int
+afr_selfheal_restore_time (call_frame_t *frame, xlator_t *this, inode_t *inode,
+ int source, unsigned char *healed_sinks,
+ struct afr_reply *replies);
+int
afr_selfheal_undo_pending (call_frame_t *frame, xlator_t *this, inode_t *inode,
unsigned char *sources, unsigned char *sinks,
unsigned char *healed_sinks,
@@ -174,10 +183,10 @@ afr_selfheal_undo_pending (call_frame_t *frame, xlator_t *this, inode_t *inode,
unsigned char *locked_on);
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,
- unsigned char *newentry);
+afr_selfheal_recreate_entry (call_frame_t *frame, int dst, int source,
+ unsigned char *sources,
+ inode_t *dir, const char *name, inode_t *inode,
+ struct afr_reply *replies);
int
afr_selfheal_post_op (call_frame_t *frame, xlator_t *this, inode_t *inode,
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index a97d03bb055..81f7a8a40e6 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -3929,6 +3929,7 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
goto err;
local = frame->local;
+ op_errno = local->op_errno;
if (we_are_not_migrating (ret)) {
/* This dht xlator is not migrating the file. Unwind and
@@ -3943,7 +3944,6 @@ dht_setxattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame, int ret)
if (subvol == NULL)
goto err;
- op_errno = local->op_errno;
local->call_cnt = 2; /* This is the second attempt */
@@ -3968,6 +3968,15 @@ err:
}
int
+dht_nuke_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
+{
+ STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL);
+ return 0;
+}
+
+int
dht_nuke_dir (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *tmp)
{
if (!IA_ISDIR(loc->inode->ia_type)) {
@@ -3998,7 +4007,7 @@ dht_nuke_dir (call_frame_t *frame, xlator_t *this, loc_t *loc, data_t *tmp)
* obscure the fact that we came in via this path instead of a genuine
* rmdir. That makes debugging just a tiny bit easier.
*/
- STACK_WIND (frame, default_rmdir_cbk, this, this->fops->rmdir,
+ STACK_WIND (frame, dht_nuke_dir_cbk, this, this->fops->rmdir,
loc, 1, NULL);
return 0;
@@ -4351,10 +4360,11 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame,
dht_local_t *local = NULL;
int op_errno = EINVAL;
- if (!frame || !frame->local || !subvol)
+ if (!frame || !frame->local)
goto err;
local = frame->local;
+ op_errno = local->op_errno;
local->call_cnt = 2; /* This is the second attempt */
@@ -4369,6 +4379,9 @@ dht_removexattr2 (xlator_t *this, xlator_t *subvol, call_frame_t *frame,
return 0;
}
+ if (subvol == NULL)
+ goto err;
+
if (local->fop == GF_FOP_REMOVEXATTR) {
STACK_WIND (frame, dht_file_removexattr_cbk, subvol,
subvol->fops->removexattr, &local->loc,
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index 2b4cec406a9..8a5d0eb74e8 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -93,6 +93,7 @@ void ec_check_status(ec_fop_data_t * fop)
{
ec_t * ec = fop->xl->private;
int32_t partial = 0;
+ char str1[32], str2[32], str3[32], str4[32], str5[32];
if (!ec_fop_needs_heal(fop)) {
return;
@@ -109,11 +110,15 @@ void ec_check_status(ec_fop_data_t * fop)
gf_msg (fop->xl->name, GF_LOG_WARNING, 0,
EC_MSG_OP_FAIL_ON_SUBVOLS,
- "Operation failed on some "
- "subvolumes (up=%lX, mask=%lX, "
- "remaining=%lX, good=%lX, bad=%lX)",
- ec->xl_up, fop->mask, fop->remaining, fop->good,
- ec->xl_up & ~(fop->remaining | fop->good));
+ "Operation failed on %d of %d subvolumes.(up=%s, mask=%s, "
+ "remaining=%s, good=%s, bad=%s)",
+ gf_bits_count(ec->xl_up & ~(fop->remaining | fop->good)), ec->nodes,
+ ec_bin(str1, sizeof(str1), ec->xl_up, ec->nodes),
+ ec_bin(str2, sizeof(str2), fop->mask, ec->nodes),
+ ec_bin(str3, sizeof(str3), fop->remaining, ec->nodes),
+ ec_bin(str4, sizeof(str4), fop->good, ec->nodes),
+ ec_bin(str5, sizeof(str5),
+ ec->xl_up & ~(fop->remaining | fop->good), ec->nodes));
if (fop->use_fd)
{