summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-20 00:23:04 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-20 09:46:08 -0700
commit00b18468235259e7813be53d758facf55c4ee28b (patch)
tree228121f55a9007c3541fbf12233181efe856e7fe /extras
parentd257c6ba46bfb874961124cd02a526a2cd969347 (diff)
'gluster volume defrag' related bug fixes
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1073 ('gluster defrag <VOLNAME>' fails in mainline) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1073
Diffstat (limited to 'extras')
-rw-r--r--extras/glusterfs-defrag.in19
1 files changed, 14 insertions, 5 deletions
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