Repository navigation
[Store] Wire hardened HMAC-authenticated TCP SSD owner-push runtime into RealClient and Python - #5790
Draft
MaskVulcan wants to merge 30 commits into
Draft
MaskVulcan wants to merge 30 commits into
MaskVulcan wants to merge 30 commits into
Conversation
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add portable POSIX pread bounded streaming read pipeline (ReadSource, ReadPipeline, ThreadedPipelineDriver, BoundedExecutor with WaitSubmit backpressure) and wire FileStorage::ReadLocalStreaming into RealClient whole and ranged local CPU restore paths under MOONCAKE_OFFLOAD_LOCAL_STREAMING_READ. Includes ranged read fallback safety for unregistered CPU user buffers, shared-mutex close drain, O_NONBLOCK clearing after regular-file validation, aligned direct short-read continuation, unit/integration tests, and design docs. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add optional io_uring streaming read executor and pipeline driver (UringReadExecutor, UringPipelineDriver) with fixed-buffer support, EBUSY/EINTR/EAGAIN retry handling, short-read continuation, liburing 2.1 user_data compatibility, atomic WaitForEvent ready/active check, ARM64 SYS_ppoll fallback in fault fixture, and CTest/ASan/UBSan coverage. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
This was referenced Nov 24, 2026
MaskVulcan
force-pushed
the
ssd/pr4-owner-push-runtime
branch
2 times, most recently
from
November 24, 2026 15:44
313808b to
01027be
Compare
Address review findings for submitAcknowledgedTcpWrite: - Enforce v2 framing and WRITE opcode before the zero-length fast path in TcpTransport::startTransfer, log rejected requests, and document local no-op semantics for zero-length acknowledged writes. - Validate classic TCP availability before selectTransports, pre-check v2 framing (MC_TCP_PROTO / peer tcp_proto_version) before mutating the batch so mixed v2/v1 batches cannot partially dispatch, and require an explicit require_ack argument on startTransferSequence. - Include tcp_proto_version in TransferMetadata::SegmentDesc::operator== so protocol-only metadata updates are installed by syncSegmentCache. - Dispatch unpooled one-shot ClientSession::initiate() onto socket->get_executor() in TcpTransport::startTransferWithSocket to avoid cross-thread progress timer races, and track one-shot sessions in ConnectionLaneState so shutdownConnectionLanes() cancels and fails in-flight unpooled work cleanly. - Encapsulate TcpTransport acknowledged-write helpers behind friend class MultiTransport. - Expand unit tests for zero-length legacy writes, legacy peer metadata, mixed batches, ungrouped and grouped mid-sequence metadata downgrades, grouped writes, unpooled connections, and unpooled shutdown while awaiting a receiver ACK. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Address adversarial review findings across local streaming restore and io_uring: - Guard both can_use_pinned_restore_arena and local streaming under offload_rpc_drain_ in RealClient::execute_ranged_read, avoid holding offload_rpc_drain_ across outbound remote peer RPCs, null-guard file_storage_/client_ in offload RPC handlers, and skip redundant local streaming retries after fallback. - Propagate sys_errno from PosixReadSource and io_uring read completions to NotifyDiskError/OnDiskError, respect disk_fenced_, validate backend type via dynamic_cast, reject overlapping destinations before source acquisition or max_chunks checks, merge multi-object batches into a single multi-source ReadPlan/driver with graceful slot degradation and expired-lease reaping on slot miss, check Start/Drain returns defensively, and map plan limits to NO_AVAILABLE_HANDLE for clean fallback. - Probe IORING_OP_READ/IORING_OP_READ_FIXED via io_uring_get_probe_ring so pre-5.6 kernels cleanly fall back to POSIX pread, expose UringReadExecutor::healthy(), make UringReadExecutor::Impl::Fail() idempotent, flush retries inline in both UringReadExecutor and UringPipelineDriver, keep shutdown drain retrying short reads/EINTR, retry io_uring_unregister_buffers on EINTR, validate O_DIRECT alignment on local-ring reads, clamp Wait() deadlines against signed overflow in both drivers, return kInvalidArgument for null sources, cap read lengths at INT_MAX with saturating object-end arithmetic, and gate UringPipelineDriver::Create cleanly. - Fix uint64_t/size_t deduction on 32-bit/macOS in file_storage_config.cpp, keep the deterministic fault test liburing fixture independent of distro <linux/io_uring.h> versions, and link ssd_uring_read_executor_contract_test standalone for BUILD_SHARED_LIBS=ON. - Harden io_uring and config/storage tests with opcode/RLIMIT_MEMLOCK/ O_DIRECT probes, safe RAII teardown ordering, WaitAccepted synchronization, default config assertions, and regression coverage for unhealthy/unsupported-opcode executors, disk fencing, plan limits, overlap precedence, multi-object uring/degraded-slot batches, and lease GC. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Replace the process-global coro_io::io_context_pool used by offload restore RPC reads with a RealClient-owned asio::thread_pool that is initialized lazily on first use and stopped and joined during teardown after in-flight offload RPCs drain. Lazily initialize FileStorage::streaming_reads_ only when the portable pread driver is needed so io_uring-backed local streaming restores do not spawn idle fallback read workers, and align the SSD offload design doc with per-batch fixed-buffer rings and fallback semantics. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Clarify submitAcknowledgedTcpWrite as a fail-closed v2 downgrade guard on top of TCP v2's existing receiver-ACK write semantics, tighten internal boundaries, and streamline tests: - Replace friend class MultiTransport with public validation/submit helpers on TcpTransport and hide OneShotSession in tcp_transport_lane_impl.h. - Query getSegmentDescByID instead of getCachedSegmentDescByID during acknowledged-write preflight to eliminate a stale-cache race window. - Rate-limit dispatch-time rejection logs, drop the redundant opcode check, and assert transport identity in MultiTransport. - Consolidate tests into five focused cases covering pooled, grouped, and unpooled acknowledged writes, legacy/downgrade rejections, unpooled shutdown via submitTransfer, and SegmentDesc equality. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Trim unused zero-caller abstractions and heavy test fixtures from the local streaming restore path while fixing four correctness/usability issues: - Remove unused O_DIRECT, fixed_buffers per-batch io_uring engine, RebindSource, Cancel/attempt_id/region_id fields, and TrySubmit overloads; compile ssd_uring_pipeline.cpp only on Linux with liburing. - Account for OffsetAllocator 3-bit-mantissa bin rounding in StreamingReadConfig::Validate() via OffsetAllocatorSlotBudget() with a lockstep test against OffsetAllocator::normalizedAllocationSize(). - Deduplicate bucket file descriptors and BucketReadGuards per bucket in BucketStorageBackend::AcquireReadSources() so large multi-key batches sharing a few buckets do not hit the open-source limit. - Return NOT_SUPPORTED on overlapping destinations so RealClient falls back to the legacy sequential restore path instead of failing. - Extract pure ClassifyUringReadResult() with table-driven unit tests, probe io_uring_enter via NOP during worker init, log warnings on io_uring init/runtime failure and pread fallback, and remove the fake liburing.h / libc-interposition fault test targets. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
MaskVulcan
force-pushed
the
ssd/pr4-owner-push-runtime
branch
from
November 25, 2026 17:42
01027be to
5e44143
Compare
…nd harden unpooled shutdown Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
… contracts Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
MaskVulcan
force-pushed
the
ssd/pr4-owner-push-runtime
branch
from
November 25, 2026 21:14
5e44143 to
49e7525
Compare
…e and split out TCP bugfixes Address review feedback on kvcache-ai#5773: - Split out unpooled TCP initiation/shutdown tracking and SegmentDesc::operator== tcp_proto_version comparison into standalone independent bugfix PRs, restoring TcpTransport::supportsParallelBatchSubmit() == true. - Rename submitAcknowledgedTcpWrite to guarantee-oriented submitReceiverVisibleWrite and move route validation/submission onto Transport virtual hooks (validateReceiverVisibleWrites / submitReceiverVisibleWriteTasks) so each transport decides whether it can satisfy receiver-visible write completion without MultiTransport special-casing TCP. - Share the completion-latch arming, seal/unseal, and pinned tail release lifecycle between submitTransfer and submitReceiverVisibleWrite via MultiTransport::submitTransferImpl. - Add Status::Code::kProtocolUnsupported (Status::ProtocolUnsupported / IsProtocolUnsupported) so legacy peer / MC_TCP_PROTO=1 rejections are machine-distinguishable from TENT NotImplemented and unsupported-transport NotSupportedTransport. - Simplify TcpTransport::validateReceiverVisibleWrites to a plain std::unordered_set<SegmentID> when metacache is enabled and document the deliberate per-stage descriptor refreshes when metacache is disabled. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add owner-push control primitives (DestinationRegistry, SsdReadProtocol, SsdOwnerRequestLedger with bounded retired-ID intervals and completion-time eviction, SsdControlWire codec, SsdDirectReadOwner, SsdFixedL2Requester with bounded ReadWithRecovery, and portable secureRandomBytes). Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add classic host TCP v2 SourceDrainedWriteTarget adapter built on TransferEngine::submitAcknowledgedTcpWrite without TransferRequest ABI, submitScatter, RDMA/TENT, or global drain changes. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add the authenticated Fixed-L2 control RPC transport (SsdReadIntoRpcEndpoint and MakeSsdRequesterControlCall) and crash-safe SsdPeerDirectory, removing all dead V1 4-RPC machinery (SsdControlRpcEndpoint / CallSsdControlRpc). Fixes review security and lifecycle issues: - Per-frame bidirectional HMAC-SHA256 authentication (OpenSSL Crypto, constant-time CRYPTO_memcmp) bound to requester identity and request tag; raw WriteCredential secrets never cross the wire in plaintext. - Dispatches both kReadInto and kRecoverReadInto off the coro_rpc I/O loop onto separate bounded executors so blocked reads cannot starve recovery and directory lookups never stall I/O threads. - Rejects wildcard 0.0.0.0/:: addresses and oversized headers before buffer allocation; connection pool uses LIFO and skips stale/closed sockets. - SsdPeerDirectory checks JSON object types before field indexing, validates max_batch_objects symmetrically, and holds an exclusive flock on a sidecar lock file so crash-leftover records from SIGKILL/OOM never permanently poison LookupLegacy with kDuplicate. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add FileStorage::ReadOwnerStreaming and MakeFileStorageOwnerReader connecting FileStorage's bounded staging pipeline (POSIX and io_uring) to SsdDirectReadOwner::Reader. - Holds streaming_mutex_ shared lock so FileStorage::Shutdown drains active owner reads before releasing staging memory. - Guards BuildColdReadFlightKey optional before dereference. - Falls back cleanly to ThreadedPipelineDriver when io_uring is unavailable. - Adds FileStorage owner streaming unit tests and an end-to-end TCP v2 owner-push restore test across two TransferEngines. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
…Python Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
…aming tests Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
…tion races, and Python bindings Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
MaskVulcan
force-pushed
the
ssd/pr4-owner-push-runtime
branch
from
November 26, 2026 05:05
49e7525 to
1ae815a
Compare
This was referenced Nov 26, 2026
EL8 wheel-builder containers ship liburing 1.0.7, which provides io_uring_get_probe_ring() and io_uring_opcode_supported() but predates io_uring_free_probe() (introduced in liburing 2.0). Fall back to std::free(probe) when IO_URING_VERSION_MAJOR < 2 (or undefined), matching uring_file.cpp's version guard. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Assert requester peer info shape to remove unused local req_peer (F841), apply Ruff formatting, and tighten subprocess/context-manager lint checks in test_ssd_fixed_l2_direct.py. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 4 of 5 in the SSD Offload streaming & owner-push series tracked in RFC #5768.
Summary
Completes the opt-in CPU/TCP SSD Owner-Push feature end-to-end across control RPC, peer discovery,
RealClient/DummyClient/Python_store, and documentation:ssd_control_rpc.*,ssd_peer_directory.*):dma_drained) with bidirectional per-message HMAC-SHA256 using constant-timeCRYPTO_memcmp; raw 128-bit credentials are never transmitted on the wire.coro_rpcI/O loop, binds only to the configured privatecontrol_host(rejecting wildcard0.0.0.0/::), enforces 60s idle timeouts, and skips launching any control listener on requester-only nodes (control_port == 0).SsdPeerDirectoryusesflock-protected records, strict JSONisObject()checks, bounded capacity (kMaxPeers = 256), andstd::shared_mutex, so crashed peer leftovers (fork()+_exit()) never poison discovery.SsdDirectRuntime& Client/Python Integration (ssd_direct_runtime.*,real_client.*,dummy_client.*,pyclient.h,store_py.cpp,rpc_client_io_context.h,docs/source/design/store/ssd-push.md):MOONCAKE_OFFLOAD_SSD_PUSH=true(classic TCP only; defaultfalseleaves existing pull paths unchanged).get_ssd_push_peer_info(),configure_ssd_push_peers(...)(with self-deduplication),recover_ssd_push(), andtimeout_msonbatch_get_into/batch_get_into_multi_buffers(enforced across memory, local-disk, and DISK/DFS tiers).tearDownAll_internal()checks pending registrations andssd_direct_->Close()before shutting down prefetcher/servers while keepingRpcDrainGuardopen onOBJECT_HAS_LEASE; Pythonclose()retainsself.store_onOBJECT_HAS_LEASEand always releasesRealClientoutside the GIL.HasPending()across all read/write/upsert paths (get_into*,batch_get_into*,put_from*,batch_put_from*,upsert_from*,batch_upsert_from*), guards inner multi-buffer range sizes against mismatch, serializes per-addressregister_buffer/unregister_bufferwith RAII guards, and cleans upSsdDirectRuntime::Implsafely on constructor unwind.Series Overview (RFC #5768)
| PR 4 | #5790 (this PR) | Hardened HMAC-SHA256 control RPC, peer directory,
RealClient& Python_store| Depends on #5789 || PR 5 | #5791 | V6 object write generations, SSD task fencing & HA durable retirement | Independent (
main) |Local Validation
ssd_direct_runtime_test(4/4 C++ E2E & lifecycle regressions) and Python E2E CTestssd_fixed_l2_python_test(1/1 PASS against realmooncake_master+_store), alongside prior full suite passes (rpc_drain_guard_test,ssd_peer_directory_test,ssd_control_rpc_test,ssd_direct_read_test,real_client_shutdown_test).clang-format 20.1.80 diff,typos 1.30.20 issues, DCO verified.