glusterfs

Форк
0
/
afr.rc 
139 строк · 4.6 Кб
1
#!/bin/bash
2

3
function create_brick_xattrop_entry {
4
        local xattrop_dir=$(afr_get_index_path $1)
5
        local base_entry=`ls $xattrop_dir|grep xattrop`
6
        local gfid_str
7
        local params=`echo "$@" | cut -d' ' -f2-`
8
        echo $params
9

10
        exit_val=0
11
        for file in $params
12
        do
13
                gfid_str=$(gf_gfid_xattr_to_str $(gf_get_gfid_xattr $1/$file))
14
                if [ -z "$base_entry"];
15
                then
16
                        touch $xattrop_dir/$gfid_str
17
                else
18
                        ln $xattrop_dir/$base_entry $xattrop_dir/$gfid_str
19
                fi
20

21
                if [ $? -ne 0 ];
22
                then
23
                        exit_val=1
24
                fi
25
        done
26

27
        if [ $exit_val -eq 1 ];
28
        then
29
                false
30
        fi
31
}
32

33
function diff_dirs {
34
        diff <(ls $1 | sort) <(ls $2 | sort)
35
}
36

37
function heal_status {
38
        local f1_path="${1}/${3}"
39
        local f2_path="${2}/${3}"
40
        local zero_xattr="000000000000000000000000"
41
        local insync=""
42
        diff_dirs $f1_path $f2_path
43
        if [ $? -eq 0 ];
44
        then
45
                insync="Y"
46
        else
47
                insync="N"
48
        fi
49
        local xattr11=$(get_hex_xattr trusted.afr.$V0-client-0 $f1_path)
50
        local xattr12=$(get_hex_xattr trusted.afr.$V0-client-1 $f1_path)
51
        local xattr21=$(get_hex_xattr trusted.afr.$V0-client-0 $f2_path)
52
        local xattr22=$(get_hex_xattr trusted.afr.$V0-client-1 $f2_path)
53
        local dirty1=$(get_hex_xattr trusted.afr.dirty $f1_path)
54
        local dirty2=$(get_hex_xattr trusted.afr.dirty $f2_path)
55
        if [ -z $xattr11 ]; then xattr11="000000000000000000000000"; fi
56
        if [ -z $xattr12 ]; then xattr12="000000000000000000000000"; fi
57
        if [ -z $xattr21 ]; then xattr21="000000000000000000000000"; fi
58
        if [ -z $xattr22 ]; then xattr22="000000000000000000000000"; fi
59
        if [ -z $dirty1 ]; then dirty1="000000000000000000000000"; fi
60
        if [ -z $dirty2 ]; then dirty2="000000000000000000000000"; fi
61
        echo ${insync}${xattr11}${xattr12}${xattr21}${xattr22}${dirty1}${dirty2}
62
}
63
# Check if given dir's self-heal is done
64
function is_dir_heal_done {
65
        local zero_xattr="000000000000000000000000"
66
        if [ "$(heal_status $@)" == "Y${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}${zero_xattr}" ];
67
        then
68
                echo "Y"
69
        else
70
                echo "N"
71
        fi
72
}
73
# Check if the given file's self-heal is done
74
function is_file_heal_done {
75
        local f1_path="${1}/${3}"
76
        local f2_path="${2}/${3}"
77
        local zxattr="000000000000000000000000"
78
        local size1=$(stat -c "%s" $f1_path)
79
        local size2=$(stat -c "%s" $f2_path)
80
        local diff=$((size1-size2))
81
        local x11=$(get_hex_xattr trusted.afr.$V0-client-0 $f1_path)
82
        local x12=$(get_hex_xattr trusted.afr.$V0-client-1 $f1_path)
83
        local x21=$(get_hex_xattr trusted.afr.$V0-client-0 $f2_path)
84
        local x22=$(get_hex_xattr trusted.afr.$V0-client-1 $f2_path)
85
        local dirty1=$(get_hex_xattr trusted.afr.dirty $f1_path)
86
        local dirty2=$(get_hex_xattr trusted.afr.dirty $f2_path)
87
        if [ -z $x11 ]; then x11="000000000000000000000000"; fi
88
        if [ -z $x12 ]; then x12="000000000000000000000000"; fi
89
        if [ -z $x21 ]; then x21="000000000000000000000000"; fi
90
        if [ -z $x22 ]; then x22="000000000000000000000000"; fi
91
        if [ -z $dirty1 ]; then dirty1="000000000000000000000000"; fi
92
        if [ -z $dirty2 ]; then dirty2="000000000000000000000000"; fi
93
        if [ "${diff}${x11}${x12}${x21}${x22}${dirty1}${dirty2}" == "0${zxattr}${zxattr}${zxattr}${zxattr}${zxattr}${zxattr}" ];
94
        then
95
             echo "Y"
96
        else
97
             echo "N"
98
        fi
99
}
100

101
#count the number of entries marked for self-heal
102
#in brick $1's index
103

104
function count_index_entries()
105
{
106
    ls $1/.glusterfs/indices/xattrop | wc -l
107
}
108

109
function afr_up_status()
110
{
111
        local v=$1
112
        local m=$2
113
        local replica_id=$3
114
        grep -E "^up = " $m/.meta/graphs/active/${v}-replicate-${replica_id}/private | cut -f2 -d'='
115
}
116

117
function get_quorum_type()
118
{
119
        local m="$1"
120
        local v="$2"
121
        local repl_id="$3"
122
        cat $m/.meta/graphs/active/$v-replicate-$repl_id/private|grep quorum-type|awk '{print $3}'
123
}
124

125
function afr_private_key_value()
126
{
127
        local v=$1
128
        local m=$2
129
        local replica_id=$3
130
        local key=$4
131
#xargs at the end will strip leading spaces
132
        grep -E "^${key} = " $m/.meta/graphs/active/${v}-replicate-${replica_id}/private | cut -f2 -d'=' | xargs
133
}
134

135
function afr_anon_entry_count()
136
{
137
    local b=$1
138
    ls $b/.glusterfs-anonymous-inode* | wc -l
139
}
140

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.