Skip to content

Commit

Permalink
tools: Add the ability to reset state to v2
Browse files Browse the repository at this point in the history
Available for testing and user downgrade.

Signed-off-by: David Zafman <dzafman@redhat.com>
  • Loading branch information
dzafman committed Sep 13, 2017
1 parent 3214882 commit 3e4d686
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/os/filestore/DBObjectMap.cc
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/os/filestore/DBObjectMap.h
Expand Up @@ -220,6 +220,8 @@ class DBObjectMap : public ObjectMap {

/// 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);

Expand Down
3 changes: 3 additions & 0 deletions src/tools/ceph_osdomap_tool.cc
Expand Up @@ -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;
Expand Down

0 comments on commit 3e4d686

Please sign in to comment.