summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@newdream.net>2012-02-24 11:24:04 -0800
committerSage Weil <sage@newdream.net>2012-02-24 11:24:04 -0800
commitc9416e6184905501159e96115f734bdf65a74d28 (patch)
tree5f4004cc1729e4c60e1ab978aafdccfe97298983
parent64038524262cffc6d3409a8e395d7417bb4b931d (diff)
downloadceph-c9416e6184905501159e96115f734bdf65a74d28.tar.gz
osd: 'tell osd.N mark_unfound_lost revert' -> 'pg <pgid> mark_unfound_lost revert'
More consistent interface. Fixes: #2030 Signed-off-by: Sage Weil <sage.weil@dreamhost.com> Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
-rw-r--r--doc/control.rst5
-rw-r--r--src/osd/OSD.cc55
-rw-r--r--src/osd/ReplicatedPG.cc37
3 files changed, 42 insertions, 55 deletions
diff --git a/doc/control.rst b/doc/control.rst
index e19a76c84fc..8020333a806 100644
--- a/doc/control.rst
+++ b/doc/control.rst
@@ -108,6 +108,11 @@ Create a cluster snapshot. ::
Mark an OSD as lost. This may result in permanent data loss. Use with caution. ::
+ $ ceph pg <pgid> mark_unfound_lost revert
+
+Revert "lost" objects to their prior state, either a previous version
+or delete them if they were just created. ::
+
$ ceph osd create [<id>]
Create a new OSD. If no ID is given, a new ID is automatically selected
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 57e372fe54a..259a058e908 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -2460,61 +2460,6 @@ void OSD::do_command(Connection *con, tid_t tid, vector<string>& cmd, bufferlist
flush_pg_stats();
}
- else if (cmd.size() == 3 && cmd[0] == "mark_unfound_lost") {
- pg_t pgid;
- if (!pgid.parse(cmd[1].c_str())) {
- ss << "can't parse pgid '" << cmd[1] << "'";
- r = -EINVAL;
- goto out;
- }
- int mode;
- if (cmd[2] == "revert")
- mode = pg_log_entry_t::LOST_REVERT;
- /*
- else if (cmd[2] == "mark")
- mode = pg_log_entry_t::LOST_MARK;
- else if (cmd[2] == "delete" || cmd[2] == "remove")
- mode = pg_log_entry_t::LOST_DELETE;
- */
- else {
- //ss << "mode must be mark|revert|delete";
- ss << "mode must be revert (mark|delete not yet implemented)";
- r = -EINVAL;
- goto out;
- }
- PG *pg = _have_pg(pgid) ? _lookup_lock_pg(pgid) : NULL;
- if (!pg) {
- ss << "pg " << pgid << " not found";
- r = -ENOENT;
- goto out;
- }
- if (!pg->is_primary()) {
- ss << "pg " << pgid << " not primary";
- pg->unlock();
- r = -EINVAL;
- goto out;
- }
- int unfound = pg->missing.num_missing() - pg->missing_loc.size();
- if (!unfound) {
- ss << "pg " << pgid << " has no unfound objects";
- pg->unlock();
- r = -ENOENT;
- goto out;
- }
- if (!pg->all_unfound_are_queried_or_lost(pg->osd->osdmap)) {
- pg->unlock();
- ss << "pg " << pgid << " has " << unfound
- << " objects but we haven't probed all sources, not marking lost despite command "
- << cmd;
- r = -EINVAL;
- goto out;
- }
- ss << pgid << " has " << unfound
- << " objects unfound and apparently lost, marking";
- pg->mark_all_unfound_lost(mode);
- pg->unlock();
- }
-
else if (cmd[0] == "heap") {
if (ceph_using_tcmalloc()) {
ceph_heap_profiler_handle_command(cmd, clog);
diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc
index 165329028e4..b6d721defdd 100644
--- a/src/osd/ReplicatedPG.cc
+++ b/src/osd/ReplicatedPG.cc
@@ -274,6 +274,43 @@ int ReplicatedPG::do_command(vector<string>& cmd, ostream& ss, bufferlist& data)
data.append(dss);
return 0;
}
+ else if (cmd.size() > 1 &&
+ cmd[0] == "mark_unfound_lost") {
+ if (cmd.size() > 2) {
+ ss << "too many arguments";
+ return -EINVAL;
+ }
+ if (cmd.size() == 1) {
+ ss << "too few arguments; must specify mode as 'revert' (mark and delete not yet implemented)";
+ return -EINVAL;
+ }
+ if (cmd[2] != "revert") {
+ ss << "mode must be 'revert'; mark and delete not yet implemented";
+ return -EINVAL;
+ }
+ int mode = pg_log_entry_t::LOST_REVERT;
+
+ if (!is_primary()) {
+ ss << "not primary";
+ return -EROFS;
+ }
+
+ int unfound = missing.num_missing() - missing_loc.size();
+ if (!unfound) {
+ ss << "pg has no unfound objects";
+ return -ENOENT;
+ }
+
+ if (!all_unfound_are_queried_or_lost(get_osdmap())) {
+ ss << "pg has " << unfound
+ << " objects but we haven't probed all sources, not marking lost";
+ return -EINVAL;
+ }
+
+ ss << "pg has " << unfound << " objects unfound and apparently lost, marking";
+ mark_all_unfound_lost(mode);
+ return 0;
+ }
ss << "unknown command " << cmd;
return -EINVAL;