crimson: use the seastar span sink API and build at API level 10

At SEASTAR_API_LEVEL >= 9 seastar dropped output_stream::write(net::packet) in
favour of write(std::span<temporary_buffer<char>>). Convert Socket's writes to
the span form, writing the packet's released fragments and keeping them alive
across the write with do_with, then raise Seastar_API_LEVEL from 6 to 10 to
match the updated seastar. The span write overloads are unconditional, so the
Socket change is valid at every API level.

Signed-off-by: Kefu Chai <k.chai@proxmox.com>
This commit is contained in:
Kefu Chai 2026-06-26 15:56:35 +08:00
parent df181842f1
commit dcbe48ff0b
2 changed files with 10 additions and 4 deletions

View File

@ -472,7 +472,7 @@ if(WITH_CRIMSON)
_find_package(${ARGV})
endif()
endmacro ()
set(Seastar_API_LEVEL "6" CACHE STRING "" FORCE)
set(Seastar_API_LEVEL "10" CACHE STRING "" FORCE)
set(Seastar_IO_URING ${HAVE_LIBURING} CACHE BOOL "" FORCE)
set(Seastar_DEPRECATED_OSTREAM_FORMATTERS OFF CACHE BOOL "" FORCE)
if(WITH_ASAN)

View File

@ -5,8 +5,11 @@
#include <seastar/core/sleep.hh>
#include <seastar/core/when_all.hh>
#include <seastar/core/do_with.hh>
#include <seastar/net/packet.hh>
#include <span>
#include "crimson/common/config_proxy.h" // for local_conf()
#include "crimson/common/log.h"
#include "include/random.h" // for ceph::util::generate_random_number()
@ -191,7 +194,9 @@ Socket::write(bufferlist buf)
return inject_delay(
).then([buf = std::move(buf), this]() mutable {
packet p(std::move(buf));
return out.write(std::move(p));
return seastar::do_with(p.release(), [this](auto& frags) {
return out.write(std::span<seastar::temporary_buffer<char>>(frags));
});
});
#ifdef UNIT_TESTS_BUILT
}).then([this] {
@ -222,8 +227,9 @@ Socket::write_flush(bufferlist buf)
return inject_delay(
).then([buf = std::move(buf), this]() mutable {
packet p(std::move(buf));
return out.write(std::move(p)
).then([this] {
return seastar::do_with(p.release(), [this](auto& frags) {
return out.write(std::span<seastar::temporary_buffer<char>>(frags));
}).then([this] {
return out.flush();
});
});