From: Kefu Chai Date: Sat, 30 Jan 2016 13:22:19 +0000 (+0800) Subject: rados: add "list-inconsistent-snapset" cmd X-Git-Tag: v10.1.0~303^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e2374c43c9a14461ee8fc6b67f777388c7230ce8;p=ceph.git rados: add "list-inconsistent-snapset" cmd to list inconsistent snapsets of a given PG, this command exposes get_inconsistent_snapsets() rados API to user. Fixes: #13505 Signed-off-by: Kefu Chai --- diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 4d314ebe1f3..d46f3a153c4 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -146,6 +146,7 @@ void usage(ostream& out) "SCRUB AND REPAIR:\n" " list-inconsistent-pg list inconsistent PGs in given pool\n" " list-inconsistent-obj list inconsistent objects in given pg\n" +" list-inconsistent-snapset list inconsistent snapsets in the given pg\n" "\n" "CACHE POOLS: (for testing/development only)\n" " cache-flush flush cache pool object (blocking)\n" @@ -1323,6 +1324,34 @@ static void dump_inconsistent(const inconsistent_obj_t& inc, f.close_section(); } +static void dump_inconsistent(const inconsistent_snapset_t& inc, + Formatter &f) +{ + dump_object_id(inc.object, f); + f.dump_bool("ss_attr_missing", inc.ss_attr_missing()); + f.dump_bool("ss_attr_corrupted", inc.ss_attr_corrupted()); + f.dump_bool("clone_missing", inc.clone_missing()); + f.dump_bool("snapset_mismatch", inc.snapset_mismatch()); + f.dump_bool("head_mismatch", inc.head_mismatch()); + f.dump_bool("headless", inc.headless()); + f.dump_bool("size_mismatch", inc.size_mismatch()); + + if (inc.clone_missing()) { + f.open_array_section("clones"); + for (auto snap : inc.clones) { + f.dump_unsigned("snap", snap); + } + f.close_section(); + + f.open_array_section("missing"); + for (auto snap : inc.missing) { + f.dump_unsigned("snap", snap); + } + f.close_section(); + } + f.close_section(); +} + // dispatch the call by type static int do_get_inconsistent(Rados& rados, const PlacementGroup& pg, @@ -1336,6 +1365,18 @@ static int do_get_inconsistent(Rados& rados, objs, interval); } +static int do_get_inconsistent(Rados& rados, + const PlacementGroup& pg, + const librados::object_id_t &start, + unsigned max_return, + AioCompletion *c, + std::vector* snapsets, + uint32_t* interval) +{ + return rados.get_inconsistent_snapsets(pg, start, max_return, c, + snapsets, interval); +} + template static int do_get_inconsistent_cmd(const std::vector &nargs, Rados& rados, @@ -3016,6 +3057,11 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, formatter = new JSONFormatter(pretty_format); } ret = do_get_inconsistent_cmd(nargs, rados, *formatter); + } else if (strcmp(nargs[0], "list-inconsistent-snapset") == 0) { + if (!formatter) { + formatter = new JSONFormatter(pretty_format); + } + ret = do_get_inconsistent_cmd(nargs, rados, *formatter); } else if (strcmp(nargs[0], "cache-flush") == 0) { if (!pool_name || nargs.size() < 2) usage_exit();