Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: Support hammer in rbd_recover_tool #12413

Merged
merged 1 commit into from Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/rbd_recover_tool/database_h
Expand Up @@ -138,7 +138,7 @@ function gather_hobject_common()

hobject=$2;
data_path=arr1[1];
gsub(/\\u/, "\\\\\\\\\\\\\\\\u", hobject); # dump backslash to delay escape (\ -> \\)
gsub(/\\u/, "\\\\\\\\u", hobject); # dump backslash to delay escape (\ -> \\)
"awk \"\\$1 == \\\""$1"\\\" {print \\$2}\" "osd_host_mapping" | head -n 1" | getline node
pgid = arr3[1];

Expand Down
43 changes: 41 additions & 2 deletions src/tools/rbd_recover_tool/epoch_h
Expand Up @@ -63,6 +63,30 @@ function get_pg_epoch()
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"

Expand All @@ -73,8 +97,23 @@ function get_pg_epoch()
local prefix="_USER_"$infos_seq"_USER_"

pg_epoch=`get_header_kv $prefix $key int`
if [ "$pg_epoch"x = ""x ];then
echo "$func: $key not exists"
}

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`
}