From a2147ad3cb256c34541ff7dc285594a22a24dfc6 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Fri, 6 May 2016 19:54:11 -0700 Subject: [PATCH 1/2] test: Fix test to not use jq -S which isn't avail in all distributions Fixes: http://tracker.ceph.com/issues/15766 Signed-off-by: David Zafman --- src/test/osd/osd-scrub-snaps.sh | 40 ++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/test/osd/osd-scrub-snaps.sh b/src/test/osd/osd-scrub-snaps.sh index 9898b1eef3f..0f58eba67cb 100755 --- a/src/test/osd/osd-scrub-snaps.sh +++ b/src/test/osd/osd-scrub-snaps.sh @@ -166,21 +166,35 @@ function TEST_scrub_snaps() { rados list-inconsistent-snapset $pgid > $dir/json || return 1 test $(jq '.inconsistents | length' $dir/json) = "20" || return 1 - jq -c -S '.inconsistents | sort' > $dir/checkcsjson << EOF -{"inconsistents":[{"headless":true,"snap":"0x00000001","locator":"","nspace":"","name":"obj1"},{"size_mismatch":true,"snap":"0x00000001","locator":"","nspace":"","name":"obj10"}, -{"headless":true,"snap":"0x00000001","locator":"","nspace":"","name":"obj11"},{"size_mismatch":true,"snap":"0x00000001","locator":"","nspace":"","name":"obj14"},{"headless":true, -"snap":"0x00000001","locator":"","nspace":"","name":"obj6"},{"headless":true,"snap":"0x00000001","locator":"","nspace":"","name":"obj7"},{"size_mismatch":true,"snap":"0x00000001", -"locator":"","nspace":"","name":"obj9"},{"headless":true,"snap":"0x00000004","locator":"","nspace":"","name":"obj2"},{"size_mismatch":true,"snap":"0x00000004","locator":"", -"nspace":"","name":"obj5"},{"headless":true,"snap":"0x00000007","locator":"","nspace":"","name":"obj2"},{"headless":true,"oi_attr_missing":true,"snap":"0x00000007","locator":"", -"nspace":"","name":"obj5"},{"extra clones":[1],"extra_clones":true,"snap":"head","locator":"","nspace":"","name":"obj11"},{"head_mismatch":true,"snap":"head","locator":"", -"nspace":"","name":"obj12"},{"size_mismatch":true,"snap":"head","locator":"","nspace":"","name":"obj3"},{"missing":[2,1],"clone_missing":true,"extra clones":[7],"extra_clones":true, -"snap":"head","locator":"","nspace":"","name":"obj5"},{"extra clones":[1],"extra_clones":true,"snap":"head","locator":"","nspace":"","name":"obj6"},{"extra clones":[1], -"extra_clones":true,"head_mismatch":true,"snap":"head","locator":"","nspace":"","name":"obj7"},{"snapset_mismatch":true,"snap":"head","locator":"","nspace":"","name":"obj8"}, -{"extra clones":[7,4],"extra_clones":true,"ss_attr_missing":true,"snap":"snapdir","locator":"","nspace":"","name":"obj2"},{"missing":[7],"clone_missing":true,"snap":"snapdir", -"locator":"","nspace":"","name":"obj4"}],"epoch":18} + jq -c '.inconsistents | sort' > $dir/checkcsjson << EOF +{"inconsistents":[{"name":"obj5","nspace":"","locator":"","snap":"head", +"extra_clones":true,"extra clones":[7],"clone_missing":true,"missing":[2,1]}, +{"name":"obj4","nspace":"","locator":"","snap":"snapdir","clone_missing":true, +"missing":[7]},{"name":"obj7","nspace":"","locator":"","snap":"head", +"head_mismatch":true,"extra_clones":true,"extra clones":[1]},{"name":"obj11", +"nspace":"","locator":"","snap":"head","extra_clones":true,"extra clones":[1]}, +{"name":"obj6","nspace":"","locator":"","snap":"head","extra_clones":true, +"extra clones":[1]},{"name":"obj2","nspace":"","locator":"","snap":"snapdir", +"ss_attr_missing":true,"extra_clones":true,"extra clones":[7,4]}, +{"name":"obj12","nspace":"","locator":"","snap":"head","head_mismatch":true}, +{"name":"obj5","nspace":"","locator":"","snap":"0x00000007", +"oi_attr_missing":true,"headless":true},{"name":"obj1","nspace":"","locator":"", +"snap":"0x00000001","headless":true},{"name":"obj11","nspace":"","locator":"", +"snap":"0x00000001","headless":true},{"name":"obj2","nspace":"","locator":"", +"snap":"0x00000004","headless":true},{"name":"obj2","nspace":"","locator":"", +"snap":"0x00000007","headless":true},{"name":"obj6","nspace":"","locator":"", +"snap":"0x00000001","headless":true},{"name":"obj7","nspace":"","locator":"", +"snap":"0x00000001","headless":true},{"name":"obj10","nspace":"","locator":"", +"snap":"0x00000001","size_mismatch":true},{"name":"obj14","nspace":"", +"locator":"","snap":"0x00000001","size_mismatch":true},{"name":"obj3", +"nspace":"","locator":"","snap":"head","size_mismatch":true},{"name":"obj5", +"nspace":"","locator":"","snap":"0x00000004","size_mismatch":true}, +{"name":"obj9","nspace":"","locator":"","snap":"0x00000001", +"size_mismatch":true},{"name":"obj8","nspace":"","locator":"","snap":"head", +"snapset_mismatch":true}],"epoch":18} EOF - jq -c -S '.inconsistents | sort' $dir/json > $dir/csjson + jq -c '.inconsistents | sort' $dir/json > $dir/csjson diff $dir/csjson $dir/checkcsjson || return 1 for i in `seq 1 7` From 07dc844d6804db93055573ec83e6753773a4c049 Mon Sep 17 00:00:00 2001 From: David Zafman Date: Thu, 5 May 2016 23:20:58 -0700 Subject: [PATCH 2/2] rados: Improve list-inconsistent json format Use array "errors" of strings for the error bits Change snapshot number to integer instead of hex Signed-off-by: David Zafman --- src/test/osd/osd-scrub-snaps.sh | 50 ++++++++--------- src/tools/rados/rados.cc | 97 ++++++++++++++++++++------------- 2 files changed, 83 insertions(+), 64 deletions(-) diff --git a/src/test/osd/osd-scrub-snaps.sh b/src/test/osd/osd-scrub-snaps.sh index 0f58eba67cb..e5c97267acd 100755 --- a/src/test/osd/osd-scrub-snaps.sh +++ b/src/test/osd/osd-scrub-snaps.sh @@ -167,31 +167,31 @@ function TEST_scrub_snaps() { test $(jq '.inconsistents | length' $dir/json) = "20" || return 1 jq -c '.inconsistents | sort' > $dir/checkcsjson << EOF -{"inconsistents":[{"name":"obj5","nspace":"","locator":"","snap":"head", -"extra_clones":true,"extra clones":[7],"clone_missing":true,"missing":[2,1]}, -{"name":"obj4","nspace":"","locator":"","snap":"snapdir","clone_missing":true, -"missing":[7]},{"name":"obj7","nspace":"","locator":"","snap":"head", -"head_mismatch":true,"extra_clones":true,"extra clones":[1]},{"name":"obj11", -"nspace":"","locator":"","snap":"head","extra_clones":true,"extra clones":[1]}, -{"name":"obj6","nspace":"","locator":"","snap":"head","extra_clones":true, -"extra clones":[1]},{"name":"obj2","nspace":"","locator":"","snap":"snapdir", -"ss_attr_missing":true,"extra_clones":true,"extra clones":[7,4]}, -{"name":"obj12","nspace":"","locator":"","snap":"head","head_mismatch":true}, -{"name":"obj5","nspace":"","locator":"","snap":"0x00000007", -"oi_attr_missing":true,"headless":true},{"name":"obj1","nspace":"","locator":"", -"snap":"0x00000001","headless":true},{"name":"obj11","nspace":"","locator":"", -"snap":"0x00000001","headless":true},{"name":"obj2","nspace":"","locator":"", -"snap":"0x00000004","headless":true},{"name":"obj2","nspace":"","locator":"", -"snap":"0x00000007","headless":true},{"name":"obj6","nspace":"","locator":"", -"snap":"0x00000001","headless":true},{"name":"obj7","nspace":"","locator":"", -"snap":"0x00000001","headless":true},{"name":"obj10","nspace":"","locator":"", -"snap":"0x00000001","size_mismatch":true},{"name":"obj14","nspace":"", -"locator":"","snap":"0x00000001","size_mismatch":true},{"name":"obj3", -"nspace":"","locator":"","snap":"head","size_mismatch":true},{"name":"obj5", -"nspace":"","locator":"","snap":"0x00000004","size_mismatch":true}, -{"name":"obj9","nspace":"","locator":"","snap":"0x00000001", -"size_mismatch":true},{"name":"obj8","nspace":"","locator":"","snap":"head", -"snapset_mismatch":true}],"epoch":18} +{"epoch":18,"inconsistents":[{"name":"obj1","nspace":"","locator":"","snap":1, +"errors":["headless"]},{"name":"obj10","nspace":"","locator":"","snap":1, +"errors":["size_mismatch"]},{"name":"obj11","nspace":"","locator":"","snap":1, +"errors":["headless"]},{"name":"obj14","nspace":"","locator":"","snap":1, +"errors":["size_mismatch"]},{"name":"obj6","nspace":"","locator":"","snap":1, +"errors":["headless"]},{"name":"obj7","nspace":"","locator":"","snap":1, +"errors":["headless"]},{"name":"obj9","nspace":"","locator":"","snap":1, +"errors":["size_mismatch"]},{"name":"obj2","nspace":"","locator":"","snap":4, +"errors":["headless"]},{"name":"obj5","nspace":"","locator":"","snap":4, +"errors":["size_mismatch"]},{"name":"obj2","nspace":"","locator":"","snap":7, +"errors":["headless"]},{"name":"obj5","nspace":"","locator":"","snap":7, +"errors":["oi_attr_missing","headless"]},{"name":"obj11","nspace":"", +"locator":"","snap":"head","errors":["extra_clones"],"extra clones":[1]}, +{"name":"obj12","nspace":"","locator":"","snap":"head", +"errors":["head_mismatch"]},{"name":"obj3","nspace":"","locator":"", +"snap":"head","errors":["size_mismatch"]},{"name":"obj5","nspace":"", +"locator":"","snap":"head","errors":["extra_clones","clone_missing"], +"extra clones":[7],"missing":[2,1]},{"name":"obj6","nspace":"","locator":"", +"snap":"head","errors":["extra_clones"],"extra clones":[1]},{"name":"obj7", +"nspace":"","locator":"","snap":"head","errors":["head_mismatch", +"extra_clones"],"extra clones":[1]},{"name":"obj8","nspace":"","locator":"", +"snap":"head","errors":["snapset_mismatch"]},{"name":"obj2","nspace":"", +"locator":"","snap":"snapdir","errors":["ss_attr_missing","extra_clones"], +"extra clones":[7,4]},{"name":"obj4","nspace":"","locator":"","snap":"snapdir", +"errors":["clone_missing"],"missing":[7]}]} EOF jq -c '.inconsistents | sort' $dir/json > $dir/csjson diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index a3962c6837f..aec380df0b1 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -1246,26 +1246,14 @@ static void dump_shard(const shard_info_t& shard, const inconsistent_obj_t& inc, Formatter &f) { + // A missing shard just has that error and nothing else if (shard.has_shard_missing()) { - f.dump_bool("missing", shard.has_shard_missing()); + f.open_array_section("errors"); + f.dump_string("error", "missing"); + f.close_section(); return; } - if (shard.has_read_error()) - f.dump_bool("read_error", shard.has_read_error()); - if (shard.has_data_digest_mismatch()) - f.dump_bool("data_digest_mismatch", shard.has_data_digest_mismatch()); - if (shard.has_omap_digest_mismatch()) - f.dump_bool("omap_digest_mismatch", shard.has_omap_digest_mismatch()); - if (shard.has_size_mismatch()) - f.dump_bool("size_mismatch", shard.has_size_mismatch()); - if (!shard.has_read_error()) { - if (shard.has_data_digest_mismatch_oi()) - f.dump_bool("data_digest_mismatch_oi", shard.has_data_digest_mismatch_oi()); - if (shard.has_omap_digest_mismatch_oi()) - f.dump_bool("omap_digest_mismatch_oi", shard.has_omap_digest_mismatch_oi()); - if (shard.has_size_mismatch_oi()) - f.dump_bool("size_mismatch_oi", shard.has_size_mismatch_oi()); - } + f.dump_unsigned("size", shard.size); if (shard.omap_digest_present) { f.dump_format("omap_digest", "0x%08x", shard.omap_digest); @@ -1273,6 +1261,30 @@ static void dump_shard(const shard_info_t& shard, if (shard.data_digest_present) { f.dump_format("data_digest", "0x%08x", shard.data_digest); } + + f.open_array_section("errors"); + if (shard.has_read_error()) + f.dump_string("error", "read_error"); + if (shard.has_data_digest_mismatch()) + f.dump_string("error", "data_digest_mismatch"); + if (shard.has_omap_digest_mismatch()) + f.dump_string("error", "omap_digest_mismatch"); + if (shard.has_size_mismatch()) + f.dump_string("error", "size_mismatch"); + if (!shard.has_read_error()) { + if (shard.has_data_digest_mismatch_oi()) + f.dump_string("error", "data_digest_mismatch_oi"); + if (shard.has_omap_digest_mismatch_oi()) + f.dump_string("error", "omap_digest_mismatch_oi"); + if (shard.has_size_mismatch_oi()) + f.dump_string("error", "size_mismatch_oi"); + } + if (shard.has_attr_missing()) + f.dump_string("error", "attr_missing"); + if (shard.has_attr_unexpected()) + f.dump_string("error", "attr_unexpected"); + f.close_section(); + if (inc.has_attr_mismatch()) { f.open_object_section("attrs"); for (auto kv : shard.attrs) { @@ -1286,10 +1298,6 @@ static void dump_shard(const shard_info_t& shard, } f.close_section(); } - if (shard.has_attr_missing()) - f.dump_bool("attr_missing", shard.has_attr_missing()); - if (shard.has_attr_unexpected()) - f.dump_bool("attr_unexpected", shard.has_attr_unexpected()); } static void dump_object_id(const object_id_t& object, @@ -1306,7 +1314,7 @@ static void dump_object_id(const object_id_t& object, f.dump_string("snap", "snapdir"); break; default: - f.dump_format("snap", "0x%08x", object.snap); + f.dump_unsigned("snap", object.snap); break; } } @@ -1317,20 +1325,26 @@ static void dump_inconsistent(const inconsistent_obj_t& inc, f.open_object_section("object"); dump_object_id(inc.object, f); f.close_section(); + + f.open_array_section("errors"); + if (inc.has_attr_unexpected()) + f.dump_string("error", "attr_unexpected"); if (inc.has_shard_missing()) - f.dump_bool("missing", inc.has_shard_missing()); + f.dump_string("error", "missing"); if (inc.has_stat_error()) - f.dump_bool("stat_err", inc.has_stat_error()); + f.dump_string("error", "stat_error"); if (inc.has_read_error()) - f.dump_bool("read_err", inc.has_read_error()); + f.dump_string("error", "read_error"); if (inc.has_data_digest_mismatch()) - f.dump_bool("data_digest_mismatch", inc.has_data_digest_mismatch()); + f.dump_string("error", "data_digest_mismatch"); if (inc.has_omap_digest_mismatch()) - f.dump_bool("omap_digest_mismatch", inc.has_omap_digest_mismatch()); + f.dump_string("error", "omap_digest_mismatch"); if (inc.has_size_mismatch()) - f.dump_bool("size_mismatch", inc.has_size_mismatch()); + f.dump_string("error", "size_mismatch"); if (inc.has_attr_mismatch()) - f.dump_bool("attr_mismatch", inc.has_attr_mismatch()); + f.dump_string("error", "attr_mismatch"); + f.close_section(); + f.open_array_section("shards"); for (auto osd_shard : inc.shards) { f.open_object_section("shard"); @@ -1345,25 +1359,31 @@ static void dump_inconsistent(const inconsistent_snapset_t& inc, Formatter &f) { dump_object_id(inc.object, f); + + f.open_array_section("errors"); if (inc.ss_attr_missing()) - f.dump_bool("ss_attr_missing", inc.ss_attr_missing()); + f.dump_string("error", "ss_attr_missing"); if (inc.ss_attr_corrupted()) - f.dump_bool("ss_attr_corrupted", inc.ss_attr_corrupted()); + f.dump_string("error", "ss_attr_corrupted"); if (inc.oi_attr_missing()) - f.dump_bool("oi_attr_missing", inc.oi_attr_missing()); + f.dump_string("error", "oi_attr_missing"); if (inc.oi_attr_corrupted()) - f.dump_bool("oi_attr_corrupted", inc.oi_attr_corrupted()); + f.dump_string("error", "oi_attr_corrupted"); if (inc.snapset_mismatch()) - f.dump_bool("snapset_mismatch", inc.snapset_mismatch()); + f.dump_string("error", "snapset_mismatch"); if (inc.head_mismatch()) - f.dump_bool("head_mismatch", inc.head_mismatch()); + f.dump_string("error", "head_mismatch"); if (inc.headless()) - f.dump_bool("headless", inc.headless()); + f.dump_string("error", "headless"); if (inc.size_mismatch()) - f.dump_bool("size_mismatch", inc.size_mismatch()); + f.dump_string("error", "size_mismatch"); + if (inc.extra_clones()) + f.dump_string("error", "extra_clones"); + if (inc.clone_missing()) + f.dump_string("error", "clone_missing"); + f.close_section(); if (inc.extra_clones()) { - f.dump_bool("extra_clones", inc.extra_clones()); f.open_array_section("extra clones"); for (auto snap : inc.clones) { f.dump_unsigned("snap", snap); @@ -1372,7 +1392,6 @@ static void dump_inconsistent(const inconsistent_snapset_t& inc, } if (inc.clone_missing()) { - f.dump_bool("clone_missing", inc.clone_missing()); f.open_array_section("missing"); for (auto snap : inc.missing) { f.dump_unsigned("snap", snap);