summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2017-03-04 01:04:10 +0530
committerNiels de Vos <ndevos@redhat.com>2017-03-10 18:14:10 -0500
commita671a19d660dabad4292a2fbb190ee26a13a1532 (patch)
tree6411e0d307c9eb1eb0edc6fcd8bdd29814638086
parent2b65e69bf7adcd6176c24ef1439bd06aa445deae (diff)
afr: restore atime/mtime for non-regular files
AFR restores atime/mtime only as a part of data heal. For non-regular files (dirs, symlinks, char/block/socket files etc) which do not undergo data-heal, atime/mtime is not restored. This patch restores atime/mtime as a part of metadata heal for such files. > Reviewed-on: https://review.gluster.org/16844 > Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> > Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> > Smoke: Gluster Build System <jenkins@build.gluster.org> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> (cherry picked from commit 804a65f07ea8e2093f781807651d0d07513b2627) Change-Id: Id8da885fc93fdf65c2f4bae2af3605b146ac1f16 BUG: 1429405 Signed-off-by: Ravishankar N <ravishankar@redhat.com> Reviewed-on: https://review.gluster.org/16852 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com>
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c43
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c56
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c7
-rw-r--r--xlators/cluster/afr/src/afr-self-heal.h9
4 files changed, 64 insertions, 51 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index c11ca11fdd9..a70833174c0 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -78,6 +78,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,
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 1b3b1ca0af1..b025c0e9781 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)
@@ -441,7 +394,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)
@@ -778,7 +732,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-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.h b/xlators/cluster/afr/src/afr-self-heal.h
index a33905033cc..c7092c7a7da 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,