From 804a65f07ea8e2093f781807651d0d07513b2627 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Sat, 4 Mar 2017 01:04:10 +0530 Subject: 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. Change-Id: Id8da885fc93fdf65c2f4bae2af3605b146ac1f16 BUG: 1429198 Signed-off-by: Ravishankar N Reviewed-on: https://review.gluster.org/16844 Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/cluster/afr/src/afr-self-heal-data.c | 56 +++------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) (limited to 'xlators/cluster/afr/src/afr-self-heal-data.c') diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 6388ece18cb..de527dbf51a 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -48,33 +48,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, @@ -308,7 +281,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) @@ -319,27 +293,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) @@ -444,7 +397,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) @@ -783,7 +737,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) { -- cgit