Commit 1010682e authored by Vitaly Lipatov's avatar Vitaly Lipatov

grf: last resort

parent dc7188f1
...@@ -190,7 +190,7 @@ get_gfid() ...@@ -190,7 +190,7 @@ get_gfid()
#trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899 #trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899
# /var/local/eterglust/pub/.glusterfs/9d/d1/9dd12f56-4daa-42ff-94e1-03a4b0fb0899 # /var/local/eterglust/pub/.glusterfs/9d/d1/9dd12f56-4daa-42ff-94e1-03a4b0fb0899
gfid=$(sshopbrick "getfattr -d -m . -e hex" "$file" | grep ^trusted.gfid | sed -e "s|trusted.gfid=0x||g") gfid=$(sshopbrick "getfattr -h -d -m . -e hex" "$file" | grep ^trusted.gfid | sed -e "s|trusted.gfid=0x||g")
# if file exists, really # if file exists, really
if [ -n "$gfid" ] ; then if [ -n "$gfid" ] ; then
python -c "import uuid; x=uuid.UUID(hex='$gfid'); print x;" python -c "import uuid; x=uuid.UUID(hex='$gfid'); print x;"
...@@ -247,7 +247,7 @@ for brick in $LISTBRICKS ; do ...@@ -247,7 +247,7 @@ for brick in $LISTBRICKS ; do
[ -d "$sfile" ] && opbrick "ls -ld" "$file" [ -d "$sfile" ] && opbrick "ls -ld" "$file"
# FIXME: replace with get_gfid # FIXME: replace with get_gfid
sshopbrick "getfattr -d -m . -e hex" "$file" | tee $WORKDIR/getfattr sshopbrick "getfattr -h -P -d -m . -e hex" "$file" | tee $WORKDIR/getfattr
#trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899 #trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899
# /var/local/eterglust/pub/.glusterfs/9d/d1/9dd12f56-4daa-42ff-94e1-03a4b0fb0899 # /var/local/eterglust/pub/.glusterfs/9d/d1/9dd12f56-4daa-42ff-94e1-03a4b0fb0899
...@@ -255,16 +255,16 @@ for brick in $LISTBRICKS ; do ...@@ -255,16 +255,16 @@ for brick in $LISTBRICKS ; do
# if file exists, really # if file exists, really
if [ -n "$gfid" ] ; then if [ -n "$gfid" ] ; then
gfid=`python -c "import uuid; x=uuid.UUID(hex='$gfid'); print x;"` gfid=`python -c "import uuid; x=uuid.UUID(hex='$gfid'); print x;"`
echo gfid $gfid
fi fi
echo "gfid: $gfid"
# показываем информацию о файле или содержимом каталога # показываем информацию о файле или содержимом каталога
if opbrick "ls -l" "$file" ; then if opbrick "ls -l" "$file" ; then
if [ ! -L "$sfile" ] ; then if ! opbrick "test -L" "$file" ; then
sshopbrick md5sum "$file" sshopbrick md5sum "$file"
echo "$file" | grep -q rpm && sshopbrick "epm checkpkg" "$file" echo "$file" | grep -q rpm && sshopbrick "epm checkpkg" "$file"
else else
echo "skip md5, it is link" echo "$host: skip md5, it is link"
fi fi
fi fi
done done
...@@ -273,9 +273,9 @@ fi ...@@ -273,9 +273,9 @@ fi
if [ "$remove" = "--allremove" ] ; then if [ "$remove" = "--allremove" ] ; then
for brick in $LISTBRICKS ; do for brick in $LISTBRICKS ; do
set_host_path "$brick" set_host_path "$brick"
# удаляем локальные размещения opbrick "rm -v" "$file"
# пустых файлов gfid=$(get_gfid "$file")
opbrick "test -s" "$file" || opbrick rm -v "$file" [ -n "$gfid" ] && opbrick "rm -fv" "$(get_pgf_name $gfid)"
done done
fi fi
...@@ -283,10 +283,14 @@ OLDFILE= ...@@ -283,10 +283,14 @@ OLDFILE=
SELFILE= SELFILE=
SELHOST= SELHOST=
SELPATH= SELPATH=
ISDIR=
if [ "$restore" = "--restore" ] ; then if [ "$restore" = "--restore" ] ; then
COUNT=1 COUNT=1
FILNUM=0 FILNUM=0
rm -f $WORKDIR/* rm -f $WORKDIR/*
[ -d "$sfile" ] && [ ! -L "$sfile" ] && ISDIR=1
for i in $LISTBRICKS ; do for i in $LISTBRICKS ; do
set_host_path "$i" set_host_path "$i"
# Надо отличать, есть файл или ошибка с ним. Если файла вообще нет, надо удалять всё на томах # Надо отличать, есть файл или ошибка с ним. Если файла вообще нет, надо удалять всё на томах
...@@ -296,7 +300,7 @@ if [ "$restore" = "--restore" ] ; then ...@@ -296,7 +300,7 @@ if [ "$restore" = "--restore" ] ; then
FILNUM=$(($FILNUM+1)) FILNUM=$(($FILNUM+1))
touch -d "$FD" "$WORKDIR/$host-$COUNT" touch -d "$FD" "$WORKDIR/$host-$COUNT"
if [ -z "$OLDFILE" ] || [ "$OLDFILE" -nt "$WORKDIR/$host-$COUNT" ] ; then if [ -z "$OLDFILE" ] || [ "$OLDFILE" -nt "$WORKDIR/$host-$COUNT" ] ; then
if opbrick "test -s" "$file" ; then if opbrick "test -L" "$file" || opbrick "test -s" "$file" ; then
OLDFILE="$WORKDIR/$host-$COUNT" OLDFILE="$WORKDIR/$host-$COUNT"
SELFILE="$file" SELFILE="$file"
SELHOST=$host SELHOST=$host
...@@ -344,17 +348,23 @@ if [ "$restore" = "--restore" ] ; then ...@@ -344,17 +348,23 @@ if [ "$restore" = "--restore" ] ; then
# FIXME: Нельзя удалять, если OLDFILE на неактивном томе # FIXME: Нельзя удалять, если OLDFILE на неактивном томе
# TODO: обычно нет смысла удалять пару # TODO: обычно нет смысла удалять пару
# прежде удаляем из .glusterfs # прежде удаляем из .glusterfs
if opbrick "test -r" "$file" ; then if opbrick "test -r" "$file" || opbrick "test -L" "$file" ; then
gfid=$(get_gfid "$file") gfid=$(get_gfid "$file")
if [ "$gfid" != "$GENGFID" ] ; then if [ "$gfid" != "$GENGFID" ] ; then
echo "gfid mismatch!!!! ($gfid and $GENGFID)" echo "gfid mismatch!!!! ($gfid and $GENGFID)"
opbrick "rm -fv" "$(get_pgf_name $GENGFID)" [ -n "$GENGFID" ] && opbrick "rm -fv" "$(get_pgf_name $GENGFID)"
fi fi
[ -n "$gfid" ] && opbrick "rm -fv" "$(get_pgf_name $gfid)" [ -n "$gfid" ] && opbrick "rm -fv" "$(get_pgf_name $gfid)"
else else
opbrick "rm -fv" "$(get_pgf_name $GENGFID)" [ -n "$GENGFID" ] && opbrick "rm -fv" "$(get_pgf_name $GENGFID)"
fi
if [ -n "$ISDIR" ] ; then
opbrick "rmdir -v" "$file"
else
opbrick "rm -fv" "$file"
fi fi
opbrick "rm -fv" "$file"
echo "$path/$file ($host)" >>grf.removed.list echo "$path/$file ($host)" >>grf.removed.list
fi fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment