From b086f53ec0542ff1de00a1975d2d66edfe49b8f7 Mon Sep 17 00:00:00 2001 From: Abhishek Lekshmanan Date: Mon, 27 Nov 2017 19:36:16 +0100 Subject: [PATCH] tools/rados: add a cli option to clear omap rados clearomap will clear all the omap keys of an object calling the underlying omap_clear librados api Fixes: http://tracker.ceph.com/issues/22255 Signed-off-by: Abhishek Lekshmanan --- src/tools/rados/rados.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tools/rados/rados.cc b/src/tools/rados/rados.cc index 2102525c0f08..03c621d8a46c 100644 --- a/src/tools/rados/rados.cc +++ b/src/tools/rados/rados.cc @@ -115,6 +115,7 @@ void usage(ostream& out) " in the object's object map\n" " setomapval \n" " rmomapkey \n" +" clearomap clear all the omap keys for this object\n" " getomapheader [file]\n" " setomapheader \n" " tmap-to-omap convert tmap keys/values to omap\n" @@ -2589,6 +2590,20 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, } else { ret = 0; } + } else if (strcmp(nargs[0], "clearomap") == 0) { + if (!pool_name || nargs.size() < 2) { + usage_exit(); + } + + string oid(nargs[1]); + ret = io_ctx.omap_clear(oid); + if (ret < 0) { + cerr << "error removing omap key " << pool_name << "/" << oid << "/" + << cpp_strerror(ret) << std::endl; + goto out; + } else { + ret = 0; + } } else if (strcmp(nargs[0], "listomapvals") == 0) { if (!pool_name || nargs.size() < 2) usage_exit(); -- 2.47.3