Skip to contentSkip to conversation

Question about OSDSuperblock

DISCUSSION xxhdx1985126 2 participants 4 messages Oct 24, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi, everyone.

I'm trying to read the source code that boots an OSD instance, and I find something really overwhelms me.
In the OSD::init() method, it read the OSDSuperblock by calling OSD::read_superblock(), and the it tried to get the "current" map : "osdmap = get_map(superblock.current_epoch)". Then OSD uses this osdmap to calculate the acting and up set of each pg.
I really don't understand this! Since the OSDSuperblock is read from the disk, the content of the superblock.current_epoch must be an old epoch which is recorded by the last OSD instance that run on the ceph osd's directory. Why use an old "current_epoch" to calculate the acting and up set of each pg?

Please help me, thank you:-)

#1 lore raw
Quoted 6 lines · On Mon, 24 Oct 2016, xxhdx1985126 wrote:

Hi, everyone.

I'm trying to read the source code that boots an OSD instance, and I find something really overwhelms me.
In the OSD::init() method, it read the OSDSuperblock by calling OSD::read_superblock(), and the it tried to get the "current" map : "osdmap = get_map(superblock.current_epoch)". Then OSD uses this osdmap to calculate the acting and up set of each pg.
I really don't understand this! Since the OSDSuperblock is read from the disk, the content of the superblock.current_epoch must be an old epoch which is recorded by the last OSD instance that run on the ceph osd's directory. Why use an old "current_epoch" to calculate the acting and up set of each pg?

Yes. load_pgs() instantiates all of the PGs, populates the current (== current_epoch) up and acting vectors, and triggers a loaded event to help get everything in-memory initialized.

Then, during the 'booting' sequence, we request the latest map from the monitor, and respond to any changes in the OSDMap--everything that happened while the OSD was down, and eventually the OSDmap that indicates the OSD is now up. At that point it can start doing useful work. Look for the AdvMap and ActMap state events.

This process of responding to changes to the OSDMap and synchronizing with other OSDs in collectively called "peering" and is one of the more difficult areas of the code to understand. :/

sage

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 9 lines · On Mon, 24 Oct 2016, xxhdx1985126 wrote:

Thanks, sir:-) I got it. I'll try to understand the "peering" part of code.:-)

By the way, please allow me to ask just one more question:-) Under what circumstance will the OSDMap mark a newly added osd "UP"? Or, in other words, how does the OSDMap judge whether or not an booting osd has finished the 'booting' sequence and should be mark "UP"?

Thank you very much, sir:-)

Once the starting OSD has fetched all of the OSDMaps from the monitor (to within a few epochs at least), it will send an MOSDBoot message asking the monitor to mark it UP.

See OSD::start_boot() to follow the the full sequence!

sage

Quoted 42 lines
Quoted 5 lines · Sage Weil
Quoted 4 lines · On Mon, 24 Oct 2016, xxhdx1985126 wrote:

Hi, everyone.

I'm trying to read the source code that boots an OSD instance, and I find

something really overwhelms me.

Quoted 1 line
Quoted 1 line

In the OSD::init() method, it read the OSDSuperblock by calling OSD::read

_superblock(), and the it tried to get the "current" map : "osdmap = get_map (superblock.current_epoch)". Then OSD uses this osdmap to calculate the acti ng and up set of each pg.

Quoted 1 line
Quoted 1 line

I really don't understand this! Since the OSDSuperblock is read from the

disk, the content of the superblock.current_epoch must be an old epoch which
is recorded by the last OSD instance that run on the ceph osd's directory.
Why use an old "current_epoch" to calculate the acting and up set of each pg ?

Quoted 11 lines

Yes. load_pgs() instantiates all of the PGs, populates the current (== current_epoch) up and acting vectors, and triggers a loaded event to help get everything in-memory initialized.

Then, during the 'booting' sequence, we request the latest map from the monitor, and respond to any changes in the OSDMap--everything that happened while the OSD was down, and eventually the OSDmap that indicates the OSD is now up. At that point it can start doing useful work. Look for the AdvMap and ActMap state events.

Quoted 5 lines

This process of responding to changes to the OSDMap and synchronizing with other OSDs in collectively called "peering" and is one of the more difficult areas of the code to understand. :/

sage

#4 lore raw

Thanks, sir:-)

Quoted 62 lines · Sage Weil
Quoted 9 lines · On Mon, 24 Oct 2016, xxhdx1985126 wrote:

Thanks, sir:-) I got it. I'll try to understand the "peering" part of code.:-)

By the way, please allow me to ask just one more question:-) Under what circumstance will the OSDMap mark a newly added osd "UP"? Or, in other words, how does the OSDMap judge whether or not an booting osd has finished the 'booting' sequence and should be mark "UP"?

Thank you very much, sir:-)

Once the starting OSD has fetched all of the OSDMaps from the monitor (to within a few epochs at least), it will send an MOSDBoot message asking the monitor to mark it UP.

See OSD::start_boot() to follow the the full sequence!

sage

Quoted 42 lines
Quoted 5 lines · Sage Weil
Quoted 4 lines · On Mon, 24 Oct 2016, xxhdx1985126 wrote:

Hi, everyone.

I'm trying to read the source code that boots an OSD instance, and I find

something really overwhelms me.

Quoted 1 line
Quoted 1 line

In the OSD::init() method, it read the OSDSuperblock by calling OSD::read

_superblock(), and the it tried to get the "current" map : "osdmap = get_map (superblock.current_epoch)". Then OSD uses this osdmap to calculate the acti ng and up set of each pg.

Quoted 1 line
Quoted 1 line

I really don't understand this! Since the OSDSuperblock is read from the

disk, the content of the superblock.current_epoch must be an old epoch which
is recorded by the last OSD instance that run on the ceph osd's directory.
Why use an old "current_epoch" to calculate the acting and up set of each pg ?

Quoted 11 lines

Yes. load_pgs() instantiates all of the PGs, populates the current (== current_epoch) up and acting vectors, and triggers a loaded event to help get everything in-memory initialized.

Then, during the 'booting' sequence, we request the latest map from the monitor, and respond to any changes in the OSDMap--everything that happened while the OSD was down, and eventually the OSDmap that indicates the OSD is now up. At that point it can start doing useful work. Look for the AdvMap and ActMap state events.

Quoted 5 lines

This process of responding to changes to the OSDMap and synchronizing with other OSDs in collectively called "peering" and is one of the more difficult areas of the code to understand. :/

sage