Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / doc / dev / osd_internals / backfill_reservation.rst
1 ====================
2 Backfill Reservation
3 ====================
4
5 When a new osd joins a cluster, all pgs containing it must eventually backfill
6 to it.  If all of these backfills happen simultaneously, it would put excessive
7 load on the osd. osd_max_backfills limits the number of outgoing or
8 incoming backfills on a single node. The maximum number of outgoing backfills is
9 osd_max_backfills. The maximum number of incoming backfills is
10 osd_max_backfills. Therefore there can be a maximum of osd_max_backfills * 2
11 simultaneous backfills on one osd.
12
13 Each OSDService now has two AsyncReserver instances: one for backfills going
14 from the osd (local_reserver) and one for backfills going to the osd
15 (remote_reserver).  An AsyncReserver (common/AsyncReserver.h) manages a queue
16 by priority of waiting items and a set of current reservation holders.  When a
17 slot frees up, the AsyncReserver queues the Context* associated with the next
18 item on the highest priority queue in the finisher provided to the constructor.
19
20 For a primary to initiate a backfill, it must first obtain a reservation from
21 its own local_reserver.  Then, it must obtain a reservation from the backfill
22 target's remote_reserver via a MBackfillReserve message. This process is
23 managed by substates of Active and ReplicaActive (see the substates of Active
24 in PG.h).  The reservations are dropped either on the Backfilled event, which
25 is sent on the primary before calling recovery_complete and on the replica on
26 receipt of the BackfillComplete progress message), or upon leaving Active or
27 ReplicaActive.
28
29 It's important that we always grab the local reservation before the remote
30 reservation in order to prevent a circular dependency.
31
32 We want to minimize the risk of data loss by prioritizing the order in
33 which PGs are recovered. The highest priority is log based recovery
34 (OSD_RECOVERY_PRIORITY_MAX) since this must always complete before
35 backfill can start.  The next priority is backfill of degraded PGs and
36 is a function of the degradation. A backfill for a PG missing two
37 replicas will have a priority higher than a backfill for a PG missing
38 one replica.  The lowest priority is backfill of non-degraded PGs.