Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
672d0b47
Commit
672d0b47
authored
Feb 26, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
grf: get gfid and remove it too
parent
befbc7f7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
12 deletions
+69
-12
grf
gluster/grf
+69
-12
No files found.
gluster/grf
View file @
672d0b47
...
...
@@ -55,7 +55,7 @@ opbrick()
sshopbrick
()
{
ssh
$host
$1
$path$2
ssh
$host
$1
$path
/
$2
#$1 "$MOUNTDIR//$host/$path/$2"
}
...
...
@@ -143,6 +143,12 @@ else
exit
1
fi
get_pgf_name
()
{
local
rfile
=
"
$1
"
echo
".glusterfs/
$(
echo
$rfile
|
cut
-b1-2
)
/
$(
echo
$rfile
|
cut
-b3-4
)
/
$rfile
"
}
tr_gfid_to_rpath
()
{
local
rfile rpath file
...
...
@@ -159,7 +165,7 @@ tr_gfid_to_rpath()
file
=
"
$(
echo
"
$sfile
"
|
sed
-e
"s|
$FTPROOT
/||g"
)
"
rfile
=
$(
echo
$file
|
sed
-e
"s|[<>]||g"
)
rfile
=
.glusterfs/
$(
echo
$rfile
|
cut
-b1-2
)
/
$(
echo
$rfile
|
cut
-b3-4
)
/
$rfile
rfile
=
$(
get_pgf_name
$rfile
)
rpath
=
$path
rfile
=
$(
opbrick
"realpath"
"
$rfile
"
)
&&
break
done
...
...
@@ -174,6 +180,20 @@ tr_gfid_to_rpath()
fi
}
get_gfid
()
{
local
file
=
"
$1
"
#trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899
# /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"
)
# if file exists, really
if
[
-n
"
$gfid
"
]
;
then
python
-c
"import uuid; x=uuid.UUID(hex='
$gfid
'); print x;"
fi
}
test_file
()
{
local
sfile
=
"
$1
"
...
...
@@ -188,14 +208,17 @@ echo "mounted info for $sfile:"
if
[
-z
"
$restore
"
]
;
then
md5sum
"
$sfile
"
fi
FLAGBROKENFILE
=
stat
"
$sfile
"
>
/dev/null
||
FLAGBROKENFILE
=
1
if
!
stat
"
$sfile
"
>
/dev/null
;
then
sleep
1
stat
"
$sfile
"
>
/dev/null
||
FLAGBROKENFILE
=
1
fi
if
[
-n
"
$restore
"
]
&&
[
-z
"
$FLAGBROKENFILE
"
]
&&
[
-z
"
$force
"
]
;
then
PERM
=
$(
stat
-c
"%a"
"
$sfile
"
)
if
[
"
$PERM
"
!=
"1000"
]
;
then
# skipping, file metainfo is readable
return
0
if
[
"
$PERM
"
=
"1000"
]
;
then
FLAGBROKENFILE
=
1
fi
fi
...
...
@@ -219,7 +242,17 @@ for brick in $LISTBRICKS ; do
# если каталог, показываем также информацию о самом каталоге
[
-d
"
$sfile
"
]
&&
opbrick
"ls -ld"
"
$file
"
sshopbrick
"getfattr -d -m . -e hex"
"
$file
"
# FIXME: replace with get_gfid
sshopbrick
"getfattr -d -m . -e hex"
"
$file
"
|
tee
$WORKDIR
/getfattr
#trusted.gfid=0x9dd12f564daa42ff94e103a4b0fb0899
# /var/local/eterglust/pub/.glusterfs/9d/d1/9dd12f56-4daa-42ff-94e1-03a4b0fb0899
gfid
=
$(
cat
$WORKDIR
/getfattr |
grep
^trusted.gfid |
sed
-e
"s|trusted.gfid=0x||g"
)
# if file exists, really
if
[
-n
"
$gfid
"
]
;
then
gfid
=
`
python
-c
"import uuid; x=uuid.UUID(hex='
$gfid
'); print x;"
`
echo
gfid
$gfid
fi
# показываем информацию о файле или содержимом каталога
if
opbrick
"ls -l"
"
$file
"
;
then
...
...
@@ -243,20 +276,26 @@ if [ "$remove" = "--allremove" ] ; then
fi
OLDFILE
=
SELFILE
=
if
[
"
$restore
"
=
"--restore"
]
;
then
COUNT
=
1
FILNUM
=
0
rm
-f
$WORKDIR
/
*
for
i
in
$LISTBRICKS
;
do
set_host_path
"
$i
"
# Надо отличать, есть файл или ошибка с ним. Если файла вообще нет, надо удалять всё на томах
FD
=
$(
opbrick
'stat -c %z'
"
$file
"
)
FD
=
$(
opbrick
'stat -c %z'
"
$file
"
2>/dev/null
)
echo
$FD
if
[
-n
"
$FD
"
]
;
then
FILNUM
=
$((
$FILNUM
+
1
))
touch
-d
"
$FD
"
"
$WORKDIR
/
$host
-
$COUNT
"
if
[
-z
"
$OLDFILE
"
]
||
[
"
$OLDFILE
"
-nt
"
$WORKDIR
/
$host
-
$COUNT
"
]
;
then
if
opbrick
"test -s"
"
$file
"
;
then
OLDFILE
=
"
$WORKDIR
/
$host
-
$COUNT
"
echo
"Select OLDFILE:
$OLDFILE
"
SELFILE
=
"
$file
"
# FIXME: overhead, but we need host and path vars
GENGFID
=
$(
get_gfid
"
$SELFILE
"
)
echo
"Select OLDFILE:
$OLDFILE
(
$file
)"
fi
fi
fi
...
...
@@ -276,9 +315,14 @@ if [ "$restore" = "--restore" ] ; then
COUNT
=
$((
$COUNT
+
1
))
done
ls
-l
$WORKDIR
echo
"FILNUM:
$FILNUM
OLD:
$OLDFILE
"
# Если два оригинала, ничего не удаляем (если нет иных проблем)
[
"
$FILNUM
"
-eq
2
]
&&
[
-z
"
$FLAGBROKENFILE
"
]
&&
[
-z
"
$force
"
]
&&
continue
echo
"OLD:
$OLDFILE
"
if
[
-n
"
$OLDFILE
"
]
;
then
COUNT
=
1
for
i
in
$LISTBRICKS
;
do
set_host_path
"
$i
"
...
...
@@ -286,17 +330,30 @@ if [ "$restore" = "--restore" ] ; then
# Удаляем всё, кроме OLDFILE
if
[
!
"
$OLDFILE
"
=
"
$WORKDIR
/
$host
-
$COUNT
"
]
;
then
# FIXME: Нельзя удалять, если OLDFILE на неактивном томе
# TODO: обычно нет смысла удалять пару
# прежде удаляем из .glusterfs
if
opbrick
"test -r"
"
$file
"
;
then
gfid
=
$(
get_gfid
"
$file
"
)
if
[
"
$gfid
"
!=
"
$GENGFID
"
]
;
then
echo
"gfid mismatch!!!! (
$gfid
and
$GENGFID
)"
opbrick
"rm -fv"
"
$(
get_pgf_name
$GENGFID
)
"
fi
[
-n
"
$gfid
"
]
&&
opbrick
"rm -fv"
"
$(
get_pgf_name
$gfid
)
"
else
opbrick
"rm -fv"
"
$(
get_pgf_name
$GENGFID
)
"
fi
opbrick
"rm -fv"
"
$file
"
echo
"
$path$file
(
$host
)"
>>
grf.removed.list
echo
"
$path
/
$file
(
$host
)"
>>
grf.removed.list
fi
# нулевые с правами 10000 уберём по-другому
#if [ -n "$FLAGSYMLINK" ] ; then
# ssh $host test -L $path
$file || ssh $host rm -v $path
$file
# ssh $host test -L $path
/$file || ssh $host rm -v $path/
$file
#fi
COUNT
=
$((
$COUNT
+
1
))
done
stat
"
$sfile
"
fi
fi
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment