ReplicatedPG: requeue waiting_for_ondisk in apply_and_flush_repops

Fixes: #3722
Signed-off-by: Samuel Just <sam.just@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
osd: fix race in do_recovery()

Verify that the PG is still RECOVERING or BACKFILL when we take the pg
lock in the recovery thread.  This prevents a crash from an invalid
state machine event when the recovery queue races with a PG state change
(e.g., due to peering).

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>