From 76ed61bb5e3fefb3e4071a24f6dd26f37c950c77 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 25 Mar 2016 18:48:30 +0530 Subject: afr: add mtime based split-brain resolution to CLI Backport of http://review.gluster.org/#/c/13828/ Extended the CLI to include support for split-brain resolution based on mtime. The command syntax is: $:gluster volume heal split-brain latest-mtime where can be either the full file name as seen from the root of the volume (or) the gfid-string representation of the file. Change-Id: I7a16f72ff1a4495aa69f43f22758a9404e958b4f BUG: 1321748 Signed-off-by: Ravishankar N Reviewed-on: http://review.gluster.org/13838 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Anuradha Talur CentOS-regression: Gluster Build System Reviewed-by: Pranith Kumar Karampuri --- tests/basic/afr/split-brain-healing.t | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/basic/afr') diff --git a/tests/basic/afr/split-brain-healing.t b/tests/basic/afr/split-brain-healing.t index 4132d327511..2171de3029d 100644 --- a/tests/basic/afr/split-brain-healing.t +++ b/tests/basic/afr/split-brain-healing.t @@ -148,6 +148,49 @@ fi EXPECT "0" echo $? EXPECT $SMALLER_FILE_SIZE stat -c %s file4 +################ Heal file5 using the latest-mtime option ############## +subvolume=$(get_replicate_subvol_number file5) +if [ $subvolume == 0 ] +then + mtime1=$(stat -c %Y $B0/${V0}1/file5) + mtime2=$(stat -c %Y $B0/${V0}2/file5) + LATEST_MTIME=$(($mtime1 > $mtime2 ? $mtime1:$mtime2)) +elif [ $subvolume == 1 ] +then + mtime1=$(stat -c %Y $B0/${V0}3/file5) + mtime2=$(stat -c %Y $B0/${V0}4/file5) + LATEST_MTIME=$(($mtime1 > $mtime2 ? $mtime1:$mtime2)) +fi +$CLI volume heal $V0 split-brain latest-mtime /file5 +EXPECT "0" echo $? + +#TODO: Uncomment the below after posix_do_utimes() supports utimensat(2) accuracy +#TEST [ $LATEST_MTIME -eq $mtime1 ] +#TEST [ $LATEST_MTIME -eq $mtime2 ] + +################ Heal file6 using the latest-mtime option and its gfid ############## +subvolume=$(get_replicate_subvol_number file6) +if [ $subvolume == 0 ] +then + GFID=$(gf_get_gfid_xattr $B0/${V0}1/file6) + mtime1=$(stat -c %Y $B0/${V0}1/file6) + mtime2=$(stat -c %Y $B0/${V0}2/file6) + LATEST_MTIME=$(($mtime1 > $mtime2 ? $mtime1:$mtime2)) +elif [ $subvolume == 1 ] +then + GFID=$(gf_get_gfid_xattr $B0/${V0}3/file6) + mtime1=$(stat -c %Y $B0/${V0}3/file6) + mtime2=$(stat -c %Y $B0/${V0}4/file6) + LATEST_MTIME=$(($mtime1 > $mtime2 ? $mtime1:$mtime2)) +fi +GFIDSTR="gfid:$(gf_gfid_xattr_to_str $GFID)" +$CLI volume heal $V0 split-brain latest-mtime $GFIDSTR +EXPECT "0" echo $? + +#TODO: Uncomment the below after posix_do_utimes() supports utimensat(2) accuracy +#TEST [ $LATEST_MTIME -eq $mtime1 ] +#TEST [ $LATEST_MTIME -eq $mtime2 ] + ################ Heal remaining SB'ed files of replica_0 using B1 as source ############## $CLI volume heal $V0 split-brain source-brick $H0:$B0/${V0}1 EXPECT "0" echo $? -- cgit