From 85ba2f0a826a74d02917c916961e4fe4d19d8df8 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Thu, 23 Aug 2018 14:29:01 +0800 Subject: [PATCH] osd/PrimaryLogPG: s/list_missing/list_unfound/ Also: - Do not print **offset** until specified - Count missing objects correctly (used to be primary's local missing) Signed-off-by: xie xingguo --- PendingReleaseNotes | 3 +++ doc/rados/troubleshooting/troubleshooting-pg.rst | 2 +- qa/standalone/erasure-code/test-erasure-eio.sh | 4 ++-- qa/standalone/osd/osd-rep-recov-eio.sh | 4 ++-- qa/standalone/scrub/osd-scrub-repair.sh | 2 +- qa/tasks/ceph_manager.py | 6 +++--- qa/tasks/ec_lost_unfound.py | 2 +- qa/tasks/lost_unfound.py | 2 +- qa/tasks/rep_lost_unfound_delete.py | 2 +- src/osd/OSD.cc | 10 +++++----- src/osd/PrimaryLogPG.cc | 12 ++++++------ 11 files changed, 26 insertions(+), 23 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index bf44d588722..11e286a5fdb 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -8,6 +8,9 @@ * Nautilus is not supported on any distros still running upstart so upstart specific files and references have been removed. +* The 'ceph pg list_missing' command has been renamed to + 'ceph pg list_unfound' to better match its behaviour. + >=13.1.0 -------- diff --git a/doc/rados/troubleshooting/troubleshooting-pg.rst b/doc/rados/troubleshooting/troubleshooting-pg.rst index 467f5ce7308..a11b972f50f 100644 --- a/doc/rados/troubleshooting/troubleshooting-pg.rst +++ b/doc/rados/troubleshooting/troubleshooting-pg.rst @@ -213,7 +213,7 @@ assumed to be preferable to returning an IO error to the user. First, you can identify which objects are unfound with:: - ceph pg 2.4 list_missing [starting offset, in json] + ceph pg 2.4 list_unfound [starting offset, in json] .. code-block:: javascript diff --git a/qa/standalone/erasure-code/test-erasure-eio.sh b/qa/standalone/erasure-code/test-erasure-eio.sh index a37258b2fd8..a75b6097f85 100755 --- a/qa/standalone/erasure-code/test-erasure-eio.sh +++ b/qa/standalone/erasure-code/test-erasure-eio.sh @@ -558,7 +558,7 @@ function TEST_ec_backfill_unfound() { done ceph pg dump pgs - ceph pg 2.0 list_missing | grep -q $testobj || return 1 + ceph pg 2.0 list_unfound | grep -q $testobj || return 1 # Command should hang because object is unfound timeout 5 rados -p $poolname get $testobj $dir/CHECK @@ -638,7 +638,7 @@ function TEST_ec_recovery_unfound() { done ceph pg dump pgs - ceph pg 2.0 list_missing | grep -q $testobj || return 1 + ceph pg 2.0 list_unfound | grep -q $testobj || return 1 # Command should hang because object is unfound timeout 5 rados -p $poolname get $testobj $dir/CHECK diff --git a/qa/standalone/osd/osd-rep-recov-eio.sh b/qa/standalone/osd/osd-rep-recov-eio.sh index e286a79b32a..cc86b77052a 100755 --- a/qa/standalone/osd/osd-rep-recov-eio.sh +++ b/qa/standalone/osd/osd-rep-recov-eio.sh @@ -189,7 +189,7 @@ function TEST_rep_backfill_unfound() { done ceph pg dump pgs - ceph pg 2.0 list_missing | grep -q $testobj || return 1 + ceph pg 2.0 list_unfound | grep -q $testobj || return 1 # Command should hang because object is unfound timeout 5 rados -p $poolname get $testobj $dir/CHECK @@ -266,7 +266,7 @@ function TEST_rep_recovery_unfound() { done ceph pg dump pgs - ceph pg 2.0 list_missing | grep -q $testobj || return 1 + ceph pg 2.0 list_unfound | grep -q $testobj || return 1 # Command should hang because object is unfound timeout 5 rados -p $poolname get $testobj $dir/CHECK diff --git a/qa/standalone/scrub/osd-scrub-repair.sh b/qa/standalone/scrub/osd-scrub-repair.sh index a2a1333eb48..4981edf8f68 100755 --- a/qa/standalone/scrub/osd-scrub-repair.sh +++ b/qa/standalone/scrub/osd-scrub-repair.sh @@ -466,7 +466,7 @@ function list_missing_erasure_coded() { for i in $(seq 0 120) ; do [ $i -lt 60 ] || return 1 - matches=$(ceph pg $pg list_missing | egrep "MOBJ0|MOBJ1" | wc -l) + matches=$(ceph pg $pg list_unfound | egrep "MOBJ0|MOBJ1" | wc -l) [ $matches -eq 2 ] && break done diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 855124567e9..6be5044d8f4 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -1756,14 +1756,14 @@ class CephManager: self.set_pool_property(pool_name, 'pgp_num', self.pools[pool_name]) return True - def list_pg_missing(self, pgid): + def list_pg_unfound(self, pgid): """ - return list of missing pgs with the id specified + return list of unfound pgs with the id specified """ r = None offset = {} while True: - out = self.raw_cluster_cmd('--', 'pg', pgid, 'list_missing', + out = self.raw_cluster_cmd('--', 'pg', pgid, 'list_unfound', json.dumps(offset)) j = json.loads(out) if r is None: diff --git a/qa/tasks/ec_lost_unfound.py b/qa/tasks/ec_lost_unfound.py index cc0bdb25850..2412cbd583a 100644 --- a/qa/tasks/ec_lost_unfound.py +++ b/qa/tasks/ec_lost_unfound.py @@ -123,7 +123,7 @@ def task(ctx, config): # verify that i can list them direct from the osd log.info('listing missing/lost in %s state %s', pg['pgid'], pg['state']); - m = manager.list_pg_missing(pg['pgid']) + m = manager.list_pg_unfound(pg['pgid']) log.info('%s' % m) assert m['num_unfound'] == pg['stat_sum']['num_objects_unfound'] diff --git a/qa/tasks/lost_unfound.py b/qa/tasks/lost_unfound.py index 64872743b25..c50082863d7 100644 --- a/qa/tasks/lost_unfound.py +++ b/qa/tasks/lost_unfound.py @@ -139,7 +139,7 @@ def task(ctx, config): # verify that i can list them direct from the osd log.info('listing missing/lost in %s state %s', pg['pgid'], pg['state']); - m = manager.list_pg_missing(pg['pgid']) + m = manager.list_pg_unfound(pg['pgid']) #log.info('%s' % m) assert m['num_unfound'] == pg['stat_sum']['num_objects_unfound'] num_unfound=0 diff --git a/qa/tasks/rep_lost_unfound_delete.py b/qa/tasks/rep_lost_unfound_delete.py index d2436008386..6051c0720c1 100644 --- a/qa/tasks/rep_lost_unfound_delete.py +++ b/qa/tasks/rep_lost_unfound_delete.py @@ -139,7 +139,7 @@ def task(ctx, config): # verify that i can list them direct from the osd log.info('listing missing/lost in %s state %s', pg['pgid'], pg['state']); - m = manager.list_pg_missing(pg['pgid']) + m = manager.list_pg_unfound(pg['pgid']) #log.info('%s' % m) assert m['num_unfound'] == pg['stat_sum']['num_objects_unfound'] num_unfound=0 diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index e684898fd43..3680e4ddd88 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5731,9 +5731,9 @@ COMMAND("pg " \ "osd", "rw", "cli") COMMAND("pg " \ "name=pgid,type=CephPgid " \ - "name=cmd,type=CephChoices,strings=list_missing " \ + "name=cmd,type=CephChoices,strings=list_unfound " \ "name=offset,type=CephString,req=false", - "list missing objects on this pg, perhaps starting at an offset given in JSON", + "list unfound objects on this pg, perhaps starting at an offset given in JSON", "osd", "r", "cli") // new form: tell for both cli and rest @@ -5744,9 +5744,9 @@ COMMAND("mark_unfound_lost " \ "name=mulcmd,type=CephChoices,strings=revert|delete", \ "mark all unfound objects in this pg as lost, either removing or reverting to a prior version if one is available", "osd", "rw", "cli,rest") -COMMAND("list_missing " \ +COMMAND("list_unfound " \ "name=offset,type=CephString,req=false", - "list missing objects on this pg, perhaps starting at an offset given in JSON", + "list unfound objects on this pg, perhaps starting at an offset given in JSON", "osd", "r", "cli,rest") COMMAND("perf histogram dump " "name=logger,type=CephString,req=false " @@ -5979,7 +5979,7 @@ int OSD::_do_command( else if (prefix == "pg" || prefix == "query" || prefix == "mark_unfound_lost" || - prefix == "list_missing" + prefix == "list_unfound" ) { pg_t pgid; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index c81562fc405..103ec116c58 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -991,7 +991,6 @@ int PrimaryLogPG::do_command( ConnectionRef con, ceph_tid_t tid) { - const auto &missing = pg_log.get_missing(); string prefix; string format; @@ -1106,9 +1105,10 @@ int PrimaryLogPG::do_command( mark_all_unfound_lost(mode, con, tid); return -EAGAIN; } - else if (command == "list_missing") { + else if (command == "list_unfound") { hobject_t offset; string offset_json; + bool show_offset = false; if (cmd_getval(cct, cmdmap, "offset", offset_json)) { json_spirit::Value v; try { @@ -1119,17 +1119,17 @@ int PrimaryLogPG::do_command( ss << "error parsing offset: " << e.what(); return -EINVAL; } + show_offset = true; } f->open_object_section("missing"); - { + if (show_offset) { f->open_object_section("offset"); offset.dump(f.get()); f->close_section(); } - f->dump_int("num_missing", missing.num_missing()); + auto &needs_recovery_map = missing_loc.get_needs_recovery(); + f->dump_int("num_missing", needs_recovery_map.size()); f->dump_int("num_unfound", get_num_unfound()); - const map &needs_recovery_map = - missing_loc.get_needs_recovery(); map::const_iterator p = needs_recovery_map.upper_bound(offset); { -- 2.39.5