From 00b18468235259e7813be53d758facf55c4ee28b Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 20 Jul 2010 00:23:04 +0000 Subject: 'gluster volume defrag' related bug fixes Signed-off-by: Amar Tumballi Signed-off-by: Anand V. Avati BUG: 1073 ('gluster defrag ' fails in mainline) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1073 --- extras/glusterfs-defrag.in | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'extras') diff --git a/extras/glusterfs-defrag.in b/extras/glusterfs-defrag.in index 982878bdbe9..8bdaf3d8252 100644 --- a/extras/glusterfs-defrag.in +++ b/extras/glusterfs-defrag.in @@ -46,24 +46,33 @@ rsync_filename() relocate_file() { path=$1; + + # Make sure we don't 'defrag' valid file. stat_info=$(stat -c '%a' "$path"); if [ $stat_info -lt 1000 ] ; then return; fi - flag=0; - linknode=$(getfattr --only-values -n trusted.distribute.linkinfo $path 2>/dev/null); - if [ -z $linknode ] ; then - return; - fi + # If there are some entries in added_bricks, then check + # if the link file is present on those nodes, if not, + # set flag=1, so full defrag happens + flag=0; for bricks in ${added_bricks}; do + linknode=$(getfattr --only-values -n trusted.distribute.linkinfo $path 2>/dev/null); + if [ -z $linknode ] ; then + return; + fi current_brick=${linknode:0:${#bricks}}; if [ "${bricks}" == "${current_brick}" ]; then flag=1; fi done + if [ -z ${added_bricks} ] ; then + flag=1; + fi + if [ $flag -ne 1 ]; then return; fi -- cgit