From 3e4d68640cc43efc0cf10ea8119b3aa583b7f36b Mon Sep 17 00:00:00 2001 From: David Zafman Date: Tue, 12 Sep 2017 23:14:15 -0700 Subject: [PATCH] tools: Add the ability to reset state to v2 Available for testing and user downgrade. Signed-off-by: David Zafman --- src/os/filestore/DBObjectMap.cc | 8 +++++++- src/os/filestore/DBObjectMap.h | 2 ++ src/tools/ceph_osdomap_tool.cc | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/os/filestore/DBObjectMap.cc b/src/os/filestore/DBObjectMap.cc index 12c334ade13d2..349fc15b862f9 100644 --- a/src/os/filestore/DBObjectMap.cc +++ b/src/os/filestore/DBObjectMap.cc @@ -1021,12 +1021,18 @@ int DBObjectMap::upgrade_to_v2() state.v = 2; + set_state(); + return 0; +} + +void DBObjectMap::set_state() +{ Mutex::Locker l(header_lock); KeyValueDB::Transaction t = db->get_transaction(); write_state(t); db->submit_transaction_sync(t); dout(1) << __func__ << " done" << dendl; - return 0; + return; } int DBObjectMap::get_state() diff --git a/src/os/filestore/DBObjectMap.h b/src/os/filestore/DBObjectMap.h index 8c465ac12837b..4d95450fe1d01 100644 --- a/src/os/filestore/DBObjectMap.h +++ b/src/os/filestore/DBObjectMap.h @@ -220,6 +220,8 @@ public: /// Read initial state from backing store int get_state(); + /// Write current state settings to DB + void set_state(); /// Read initial state and upgrade or initialize state int init(bool upgrade = false); diff --git a/src/tools/ceph_osdomap_tool.cc b/src/tools/ceph_osdomap_tool.cc index 1f78cb901c544..d7c240d792311 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -198,6 +198,9 @@ int main(int argc, char **argv) { for (auto i : headers) std::cout << i << std::endl; return 0; + } else if (cmd == "resetv2") { + omap.state.v = 2; + omap.set_state(); } else { std::cerr << "Did not recognize command " << cmd << std::endl; return 1; -- 2.39.5