From c7838fbd6afd876c922e1ec681bbbcf73be653e5 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Thu, 23 May 2013 11:13:25 +0200 Subject: storage/posix: do not dereference gfid symlinks before posix_handle_mkdir_hashes() Whenever a new directory is created, its corresponding gfid file must also be created. This was done first calling MAKE_HANDLE_PATH() to get the path of the gfid file, then calling posix_handle_mkdir_hashes() to create the parent directories of the gfid, and finally creating the soft-link. In normal circumstances, the gfid we want to create won't exist and MAKE_HANDLE_PATH() will return a simple path to the new gfid. However if the volume is damaged and a self-heal is running, it is possible that we try to create an already existing gfid. In this case, MAKE_HANDLE_PATH() will return a path to the directory instead of the path to the gfid. To solve this problem, every time a path to a gfid is needed, a call to MAKE_HANDLE_ABSPATH() is made instead of the call to MAKE_HANDLE_PATH(). Change-Id: Ic319cc38c170434db8e86e2f89f0b8c28c0d611a BUG: 859581 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/5075 Tested-by: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Reviewed-by: Vijay Bellur --- tests/bugs/bug-859581.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 tests/bugs/bug-859581.t (limited to 'tests/bugs') diff --git a/tests/bugs/bug-859581.t b/tests/bugs/bug-859581.t new file mode 100755 index 00000000000..f31e8b311ef --- /dev/null +++ b/tests/bugs/bug-859581.t @@ -0,0 +1,47 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{1,2} +EXPECT 'Created' volinfo_field $V0 'Status'; +TEST $CLI volume start $V0 +EXPECT 'Started' volinfo_field $V0 'Status'; +# Needed to be sure self-heal daemon is running +sleep 5 + +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +mkdir -p $M0/dir1/dir2 + +TEST rm -f $(gf_get_gfid_backend_file_path $B0/${V0}1 "dir1") +TEST rmdir $B0/${V0}1/dir1/dir2 + +TEST $CLI volume heal $V0 full +sleep 5 + +TEST [ -d $B0/${V0}1/dir1/dir2 ] +TEST [ ! -d $(gf_get_gfid_backend_file_path $B0/${V0}1 "dir1") ] + +# Stop the volume to flush caches and force symlink recreation +TEST umount $M0 +TEST $CLI volume stop $V0 +EXPECT 'Stopped' volinfo_field $V0 'Status'; +TEST $CLI volume start $V0 +EXPECT 'Started' volinfo_field $V0 'Status'; +TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id $V0 $M0; + +ls -l $M0/ + +TEST [ -h $(gf_get_gfid_backend_file_path $B0/${V0}1 "dir1") ] + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0 + +cleanup + -- cgit