17b94a
From b528c21e6fedc9ac841942828b82e0c808da5efb Mon Sep 17 00:00:00 2001
17b94a
From: Sheetal Pamecha <spamecha@redhat.com>
17b94a
Date: Thu, 2 Jan 2020 12:05:12 +0530
17b94a
Subject: [PATCH 393/449] afr: restore timestamp of files during metadata heal
17b94a
17b94a
For files: During metadata heal, we restore timestamps
17b94a
only for non-regular (char, block etc.) files.
17b94a
Extenting it for regular files as timestamp is updated
17b94a
via touch command also
17b94a
17b94a
> upstream patch link: https://review.gluster.org/#/c/glusterfs/+/23953/
17b94a
> fixes: bz#1787274
17b94a
> Change-Id: I26fe4fb6dff679422ba4698a7f828bf62ca7ca18
17b94a
> Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
17b94a
17b94a
BUG: 1761531
17b94a
Change-Id: I26fe4fb6dff679422ba4698a7f828bf62ca7ca18
17b94a
Signed-off-by: Sheetal Pamecha <spamecha@redhat.com>
17b94a
Reviewed-on: https://code.engineering.redhat.com/gerrit/202332
17b94a
Tested-by: RHGS Build Bot <nigelb@redhat.com>
17b94a
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
17b94a
---
17b94a
 .../bug-1761531-metadata-heal-restore-time.t       | 74 ++++++++++++++++++++++
17b94a
 xlators/cluster/afr/src/afr-self-heal-metadata.c   |  8 +--
17b94a
 2 files changed, 76 insertions(+), 6 deletions(-)
17b94a
 create mode 100644 tests/bugs/replicate/bug-1761531-metadata-heal-restore-time.t
17b94a
17b94a
diff --git a/tests/bugs/replicate/bug-1761531-metadata-heal-restore-time.t b/tests/bugs/replicate/bug-1761531-metadata-heal-restore-time.t
17b94a
new file mode 100644
17b94a
index 0000000..7e24eae
17b94a
--- /dev/null
17b94a
+++ b/tests/bugs/replicate/bug-1761531-metadata-heal-restore-time.t
17b94a
@@ -0,0 +1,74 @@
17b94a
+#!/bin/bash
17b94a
+
17b94a
+. $(dirname $0)/../../include.rc
17b94a
+. $(dirname $0)/../../volume.rc
17b94a
+. $(dirname $0)/../../afr.rc
17b94a
+cleanup
17b94a
+
17b94a
+GET_MDATA_PATH=$(dirname $0)/../../utils
17b94a
+build_tester $GET_MDATA_PATH/get-mdata-xattr.c
17b94a
+
17b94a
+TEST glusterd
17b94a
+TEST pidof glusterd
17b94a
+TEST $CLI volume create $V0 replica 3 $H0:$B0/brick{0..2}
17b94a
+TEST $CLI volume start $V0
17b94a
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 2
17b94a
+
17b94a
+TEST touch $M0/a
17b94a
+sleep 1
17b94a
+TEST kill_brick $V0 $H0 $B0/brick0
17b94a
+TEST touch $M0/a
17b94a
+
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^2$" get_pending_heal_count $V0
17b94a
+
17b94a
+TEST $CLI volume start $V0 force
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2
17b94a
+
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+mtime0=$(get_mtime $B0/brick0/a)
17b94a
+mtime1=$(get_mtime $B0/brick1/a)
17b94a
+TEST [ $mtime0 -eq $mtime1 ]
17b94a
+
17b94a
+ctime0=$(get_ctime $B0/brick0/a)
17b94a
+ctime1=$(get_ctime $B0/brick1/a)
17b94a
+TEST [ $ctime0 -eq $ctime1 ]
17b94a
+
17b94a
+###############################################################################
17b94a
+# Repeat the test with ctime feature disabled.
17b94a
+TEST $CLI volume set $V0 features.ctime off
17b94a
+
17b94a
+TEST touch $M0/b
17b94a
+sleep 1
17b94a
+TEST kill_brick $V0 $H0 $B0/brick0
17b94a
+TEST touch $M0/b
17b94a
+
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^2$" get_pending_heal_count $V0
17b94a
+
17b94a
+TEST $CLI volume start $V0 force
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1
17b94a
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1
17b94a
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2
17b94a
+
17b94a
+EXPECT_WITHIN $HEAL_TIMEOUT "^0$" get_pending_heal_count $V0
17b94a
+
17b94a
+mtime2=$(get_mtime $B0/brick0/b)
17b94a
+mtime3=$(get_mtime $B0/brick1/b)
17b94a
+TEST [ $mtime2 -eq $mtime3 ]
17b94a
+
17b94a
+TEST rm $GET_MDATA_PATH/get-mdata-xattr
17b94a
+
17b94a
+TEST force_umount $M0
17b94a
+TEST $CLI volume stop $V0
17b94a
+TEST $CLI volume delete $V0
17b94a
+
17b94a
+cleanup
17b94a
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
17b94a
index ecfa791..f4e31b6 100644
17b94a
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
17b94a
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
17b94a
@@ -421,12 +421,8 @@ afr_selfheal_metadata(call_frame_t *frame, xlator_t *this, inode_t *inode)
17b94a
         if (ret)
17b94a
             goto unlock;
17b94a
 
17b94a
-        /* Restore atime/mtime for files that don't need data heal as
17b94a
-         * restoring timestamps happens only as a part of data-heal.
17b94a
-         */
17b94a
-        if (!IA_ISREG(locked_replies[source].poststat.ia_type))
17b94a
-            afr_selfheal_restore_time(frame, this, inode, source, healed_sinks,
17b94a
-                                      locked_replies);
17b94a
+        afr_selfheal_restore_time(frame, this, inode, source, healed_sinks,
17b94a
+                                  locked_replies);
17b94a
 
17b94a
         ret = afr_selfheal_undo_pending(
17b94a
             frame, this, inode, sources, sinks, healed_sinks, undid_pending,
17b94a
-- 
17b94a
1.8.3.1
17b94a