| 1411 | } |
| 1412 | |
| 1413 | MOSDMap *OSDService::build_incremental_map_msg(epoch_t since, epoch_t to, |
| 1414 | OSDSuperblock& sblock) |
| 1415 | { |
| 1416 | auto get_map_and_adjust_counters = [] ( |
| 1417 | bufferlist& bl, |
| 1418 | int& max, |
| 1419 | ssize_t& max_bytes, |
| 1420 | std::function<bool()> map_getter) { |
| 1421 | if (!map_getter()) { |
| 1422 | return false; |
| 1423 | } |
| 1424 | max--; |
| 1425 | max_bytes -= bl.length(); |
| 1426 | return true; |
| 1427 | }; |
| 1428 | |
| 1429 | MOSDMap *m = new MOSDMap(monc->get_fsid(), |
| 1430 | osdmap->get_encoding_features()); |
| 1431 | m->cluster_osdmap_trim_lower_bound = sblock.cluster_osdmap_trim_lower_bound; |
| 1432 | m->newest_map = sblock.get_newest_map(); |
| 1433 | |
| 1434 | int max = cct->_conf->osd_map_message_max; |
| 1435 | ssize_t max_bytes = cct->_conf->osd_map_message_max_bytes; |
| 1436 | |
| 1437 | if (since < m->cluster_osdmap_trim_lower_bound) { |
| 1438 | // we don't have the next map the target wants, so start with a |
| 1439 | // full map. |
| 1440 | dout(10) << __func__ << " cluster osdmap lower bound " |
| 1441 | << sblock.cluster_osdmap_trim_lower_bound |
| 1442 | << " > since " << since << ", starting with full map" |
| 1443 | << dendl; |
| 1444 | since = m->cluster_osdmap_trim_lower_bound; |
| 1445 | if (bufferlist bl; |
| 1446 | get_map_and_adjust_counters(bl, max, max_bytes, [&] { return get_map_bl(since, bl);})) { |
| 1447 | m->maps[since] = std::move(bl); |
| 1448 | ++since; |
| 1449 | } else { |
| 1450 | derr << __func__ << " missing full map after map gap " << since << dendl; |
| 1451 | goto panic; |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | for (epoch_t e = since; e <= to && max > 0 && max_bytes > 0; ++e) { |
| 1456 | if (bufferlist bl; |
| 1457 | get_map_and_adjust_counters(bl, max, max_bytes, [&] { return get_inc_map_bl(e, bl);})) { |
| 1458 | m->incremental_maps[e] = std::move(bl); |
| 1459 | } else { |
| 1460 | dout(10) << __func__ << " missing incremental map " << e << dendl; |
| 1461 | if (bufferlist bl; |
| 1462 | get_map_and_adjust_counters(bl, max, max_bytes, [&] { return get_map_bl(e, bl);})) { |
| 1463 | m->maps[e] = std::move(bl); |
| 1464 | } else { |
| 1465 | derr << __func__ << " also missing full map " << e << dendl; |
| 1466 | goto panic; |
| 1467 | } |
| 1468 | } |
| 1469 | } |
| 1470 | return m; |
nothing calls this directly
no test coverage detected