]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix do not always clear DEGRADED/set CLEAN on recovery finish
authorSage Weil <sage@newdream.net>
Wed, 15 Feb 2012 23:20:35 +0000 (15:20 -0800)
committerSage Weil <sage@newdream.net>
Wed, 15 Feb 2012 23:20:35 +0000 (15:20 -0800)
Clean means we have exactly the right number of replicas and recovery is
complete.  Degraded means we do not have enough replicas, either because
recovery is in progress, or because acting is too small.

A consequence is that if we have a PG with len(up) == 1 but a pg_temp
mapping so that len(acting) == 2, it will be active and not clean.

Fixes: #2060
Signed-off-by: Sage Weil <sage@newdream.net>
Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
src/osd/PG.cc

index 8a42e5e6590e9c58e2fe452177ef0f173f8ad70d..49d7a4181de2383ddb6cfacf52376d49caadd04d 100644 (file)
@@ -1541,9 +1541,15 @@ struct C_PG_FinishRecovery : public Context {
 void PG::finish_recovery(ObjectStore::Transaction& t, list<Context*>& tfin)
 {
   dout(10) << "finish_recovery" << dendl;
-  state_clear(PG_STATE_DEGRADED);
   state_clear(PG_STATE_BACKFILL);
-  state_set(PG_STATE_CLEAN);
+
+  // only clear DEGRADED (or mark CLEAN) if we have enough (or the
+  // desired number of) replicas.
+  if (acting.size() >= get_osdmap()->get_pg_size(info.pgid))
+    state_clear(PG_STATE_DEGRADED);
+  if (acting.size() == get_osdmap()->get_pg_size(info.pgid))
+    state_set(PG_STATE_CLEAN);
+
   assert(info.last_complete == info.last_update);
 
   // NOTE: this is actually a bit premature: we haven't purged the