Skip to content

Add optional support for SPDK on Linux - #116

Draft
benjarvis wants to merge 1 commit into
chimera-nas:mainfrom
benjarvis:spdk
Draft

Add optional support for SPDK on Linux#116
benjarvis wants to merge 1 commit into
chimera-nas:mainfrom
benjarvis:spdk

Conversation

@benjarvis

Copy link
Copy Markdown
Member

SPDK can be enabled or not at compile time.

If enabled at compile time, it can be optionally enabled at runtime. If enabled:

  • evpl_threads wrap spdk_threads
  • evpl context stacks on top of SPDK reactor
  • evpl registered memory is registered via SPDK
  • SPDK bdev block devices may be used via the usual API
  • SPDK sockets (standard or io_uring) may be used via the usual API
  • epoll FD is registered to SPDK reactor

The hybrid event/poll mode that libevpl normally has is removed when running on SPDK per SPDK convention.

…protocols

Allow libevpl to run as a guest inside an existing SPDK application,
intermixing libevpl and SPDK workloads on the same spdk_threads and
reactors without stacking two async runtimes:

- EVPL_CORE_MECH_SPDK: core mechanism that composes with the epoll
  backend (all evpl fds live in one internal epoll) and is pumped by a
  period-0 spdk_poller.  Interrupt-mode reactors are supported via
  spdk_interrupt registration of the epoll fd plus a timerfd that is
  re-armed post-pump from the evpl timer heap; evpl_run/evpl_stop abort
  under external-loop mechanisms.  evpl_continue now returns a work
  count so the poller reports honest BUSY/IDLE, and evpl_kick() lets
  same-thread foreign contexts wake the loop.

- evpl_thread/evpl_threadpool transparently wrap spdk_threads in SPDK
  mode: creation bootstraps via spdk_thread_send_msg (blocking for
  readiness only on plain-pthread callers; spdk_thread callers return
  immediately to avoid reactor co-scheduling deadlock) and teardown is
  fully message-driven via a teardown poller.  Existing spdk_threads
  can instead bolt on an evpl directly with evpl_create().

- EVPL_FRAMEWORK_SPDK registers slab buffers with spdk_mem_register
  (slabs become 2MiB-aligned when SPDK is enabled) so evpl iovecs are
  DMA-safe for SPDK I/O.

- Block device open/close become asynchronous operations taking an
  evpl context, like all other libevpl operations (breaking API
  change); completion is deferral-normalized, close must run on the
  opening evpl, and all backends, tests and docs are updated.

- EVPL_BLOCK_PROTOCOL_SPDK_BDEV: block protocol over SPDK bdevs
  (uri = bdev name) with byte-offset submits, ENOMEM io_wait retry,
  sync-write flush chaining, and registered-slab bounce buffers.

- EVPL_STREAM_SPDK_TCP: TCP stream protocol over spdk_sock (pluggable
  impls via evpl_global_config_set_spdk_sock_impl) with zero-copy
  writev_async sends using a waist-based send ring, group-polled
  receive, interrupt-mode group registration, and a progress timer for
  connects and write stalls.

- Legacy evpl_run tests (timer_oneshot, ping_pong_msg, bulk_msg,
  ping_pong_connected_msg, rdma_ops, rpc2 multifrag) are refactored to
  evpl_thread/callback form and now also run under the SPDK mechanism
  via EVPL_TEST_CORE_MECH=spdk, which boots a mini-reactor test
  harness; dedicated SPDK tests cover threads, doorbells, timers,
  memory registration, sock ping-pong/framing and bdev I/O against a
  malloc bdev.

- The devcontainer builds SPDK v25.09 (shared libs, no nvme-cuse) so
  the SPDK tests run in CI; builds without SPDK are unaffected
  (SPDK_ENABLED tri-state, autodetected via pkg-config).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@benjarvis
benjarvis marked this pull request as draft July 27, 2026 12:29
benjarvis added a commit to benjarvis/libevpl that referenced this pull request Aug 11, 2026
Three issues in open_handles tracking:

1. chimera_vfs_open_cache_release() error path: when a non-detached
   handle failed to open, it was removed from the shard but open_handles
   was not decremented, causing a permanent over-count.

2. chimera_vfs_open_cache_release() detached path: the comment clarifies
   that detached handles should NOT decrement open_handles since they
   were already removed from the shard during insert().

3. chimera_vfs_open_cache_defer_close(): counted shard->open_handles
   before processing the pending_close list, so handles about to be
   closed were included in the count. Move the count after processing
   to report the actual remaining handles.

These issues could cause the close thread to see incorrect handle counts,
potentially leading to shutdown hangs or premature close decisions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant