flags:
- startup
+- name: crimson_osd_max_send_buffers
+ type: uint
+ level: advanced
+ default: 1024
+ min: 1
+ max: 65535
+ desc: Maximum buffer fragments to batch in a single outgoing network write
+ long_desc: Limits how many buffer::ptr entries are batched into one seastar
+ packet during the outgoing message sweep. Prevents overflow of the
+ seastar packet fragment counter (uint16_t).
+
- name: crimson_allow_pg_split
type: bool
level: advanced
bool require_ack)
{
std::size_t num_msgs = out_pending_msgs.size();
+ const unsigned max_bufs =
+ local_conf().get_val<uint64_t>("crimson_osd_max_send_buffers");
ceph::bufferlist bl;
#ifdef UNIT_TESTS_BUILT
#endif
}
- std::for_each(
- out_pending_msgs.begin(),
- out_pending_msgs.begin()+num_msgs,
- [this, &bl
-#ifdef UNIT_TESTS_BUILT
- , &tags
-#endif
- ](const MessageFRef& msg) {
- // set priority
+ std::size_t num_swept = 0;
+ for (std::size_t i = 0; i < num_msgs; ++i) {
+ auto& msg = out_pending_msgs[i];
+
msg->get_header().src = conn.messenger.get_myname();
msg->encode(conn.features, 0);
auto tag = MessageFrame::tag;
tags.push_back(tag);
#endif
- });
+ ++num_swept;
+ if (bl.get_num_buffers() >= max_bufs) {
+ break;
+ }
+ }
if (!conn.policy.lossy) {
out_sent_msgs.insert(
out_sent_msgs.end(),
std::make_move_iterator(out_pending_msgs.begin()),
- std::make_move_iterator(out_pending_msgs.end()));
+ std::make_move_iterator(out_pending_msgs.begin() + num_swept));
}
- out_pending_msgs.clear();
+ out_pending_msgs.erase(
+ out_pending_msgs.begin(),
+ out_pending_msgs.begin() + num_swept);
#ifdef UNIT_TESTS_BUILT
return sweep_ret{std::move(bl), tags};
#else
ceph::bufferlist
#endif
+ /**
+ * Encode and drain pending outgoing messages into a single bufferlist
+ * for a batched socket write. Stops early when the accumulated number
+ * of buffer fragments reaches crimson_osd_max_send_buffers to prevent
+ * overflowing seastar's uint16_t packet fragment
+ * counter. Un-swept messages remain in the queue and are picked up
+ * by the next do_out_dispatch() iteration.
+ */
sweep_out_pending_msgs_to_sent(
bool require_keepalive,
std::optional<utime_t> maybe_keepalive_ack,