From db9df5ac50d9d716214badabdd9b13197751bfe7 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 (cherry picked from commit 3e4d68640cc43efc0cf10ea8119b3aa583b7f36b) Conflicts: src/tools/ceph_osdomap_tool.cc (trivial) --- 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 2ec7deb614732..1e9c789693ac6 100644 --- a/src/os/filestore/DBObjectMap.cc +++ b/src/os/filestore/DBObjectMap.cc @@ -1019,12 +1019,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 1e9dc3ebc0354..8a1869d37dd67 100644 --- a/src/os/filestore/DBObjectMap.h +++ b/src/os/filestore/DBObjectMap.h @@ -219,6 +219,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 08ac96d47d08c..ff92b132fd644 100644 --- a/src/tools/ceph_osdomap_tool.cc +++ b/src/tools/ceph_osdomap_tool.cc @@ -197,6 +197,9 @@ int main(int argc, char **argv) { } for (auto i : headers) std::cout << i << std::endl; + } else if (cmd == "resetv2") { + omap.state.v = 2; + omap.set_state(); } else { std::cerr << "Did not recognize command " << cmd << std::endl; r = 1; -- 2.39.5