From 1380a39018b0d0395dc76ad95499da78694ba5d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bart=C5=82omiej=20=C5=9Awi=C4=99cki?= Date: Wed, 5 Oct 2016 14:33:01 +0000 Subject: [PATCH] tools: Support hammer in rbd_recover_tool MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Bartłomiej Święcki --- src/tools/rbd_recover_tool/database_h | 2 +- src/tools/rbd_recover_tool/epoch_h | 43 +++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/tools/rbd_recover_tool/database_h b/src/tools/rbd_recover_tool/database_h index 1a7073a18598..c8e97598b680 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 6e9dea2f35f4..edfaeafd8280 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` } -- 2.47.3