blob: e268eafa7373872fc69c79023ed88c2259c2195a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!/usr/bin/env bash
# file: epoch_h
#
# Copyright (C) 2015 Ubuntu Kylin
#
# Author: Min Chen <minchen@ubuntukylin.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library Public License for more details.
#
my_dir=$(dirname "$0")
. $my_dir/common_h
#pgid_list=$single_node/$cluster-$id/pgid_list
function get_pgid_list()
{
find $osd_data/current/ -type d -name "*_head"|\
sed -n 's/\(.*\)\/current\/\([0-9a-fA-F]\+\.[0-9a-fA-F]\+\)_head/\2 \1/p'|\
sort -t ' ' -k 1.1,1h -k 2.1,2 > $pgid_list;
}
function get_pgid()
{
hobject_path=$1
echo $hobject_path| sed -n 's/\(.*\)\/\([0-9a-fA-F]\+\.[0-9a-fA-F]\+\)_head\(.*\)/\2/p'
}
infos_seq=
function get_infos_seq()
{
local func="get_infos_seq"
local keyword=":infos."
local infos_key=`get_map_header_key $keyword`
if [ "$infos_key"x = ""x ];then
echo "$func: keyword not input or infos_key not exists"
exit
fi
local prefix=`get_map_header_prefix`
local key=$infos_key
infos_seq=`get_header_seq $prefix $key`
if [ "$infos_seq"x = ""x ];then
echo "$func: infos_seq not exists"
exit
fi
}
pg_epoch=
function get_pg_epoch()
{
local func="get_pg_epoch"
if [ "$1"x = ""x ];then
echo "$func: no pgid input"
exit
fi
get_pg_epoch_firefly "$1"
if [ "$pg_epoch"x != ""x ]; then
# echo "Epoch for $1: $pg_epoch (firefly)"
return
fi
get_pg_epoch_hammer "$1"
if [ "$pg_epoch"x != ""x ]; then
# echo "Epoch for $1: $pg_epoch (hammer)"
return
fi
echo "$func: Couldn't find epoch for $1"
exit
}
function get_pg_epoch_firefly()
{
local func="get_pg_epoch_firefly"
if [ "$1"x = ""x ];then
echo "$func: no pgid input"
exit
fi
local pgid=$1
local key=$pgid"_epoch"
#get_infos_seq;
# infos_seq default to 1
infos_seq=1
local infos_seq=`printf "%016d" $infos_seq`
local prefix="_USER_"$infos_seq"_USER_"
pg_epoch=`get_header_kv $prefix $key int`
}
function get_pg_epoch_hammer()
{
local func="get_pg_epoch_hammer"
if [ "$1"x = ""x ];then
echo "$func: no pgid input"
exit
fi
local pgid="$1"
local hkey_prefix="$(get_map_header_prefix)"
local hkey="$(printf '...head.%x.%08X' "$(echo "$pgid"|cut -d'.' -f1)" "$((0x$(echo "$pgid"|cut -d'.' -f2)))")"
local infos_seq="$(get_header_seq "$hkey_prefix" "$hkey")"
local infos_seq=`printf "%016d" $infos_seq`
local prefix="_USER_"$infos_seq"_USER_"
local key="_epoch"
pg_epoch=`get_header_kv $prefix $key int`
}
|