From: Bartłomiej Święcki Date: Wed, 5 Oct 2016 14:33:01 +0000 (+0000) Subject: tools: Support hammer in rbd_recover_tool X-Git-Tag: v12.0.0~280^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1380a39018b0d0395dc76ad95499da78694ba5d2;p=ceph-ci.git tools: Support hammer in rbd_recover_tool Signed-off-by: Bartłomiej Święcki --- diff --git a/src/tools/rbd_recover_tool/database_h b/src/tools/rbd_recover_tool/database_h index 1a7073a1859..c8e97598b68 100644 --- a/src/tools/rbd_recover_tool/database_h +++ b/src/tools/rbd_recover_tool/database_h @@ -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]; diff --git a/src/tools/rbd_recover_tool/epoch_h b/src/tools/rbd_recover_tool/epoch_h index 6e9dea2f35f..edfaeafd828 100644 --- a/src/tools/rbd_recover_tool/epoch_h +++ b/src/tools/rbd_recover_tool/epoch_h @@ -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" @@ -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` }