Skip to content

feat: ec module#72

Draft
c3y1huang wants to merge 62 commits into
longhorn:longhorn-v25.09from
c3y1huang:1061-v2-sharding
Draft

feat: ec module#72
c3y1huang wants to merge 62 commits into
longhorn:longhorn-v25.09from
c3y1huang:1061-v2-sharding

Conversation

@c3y1huang

@c3y1huang c3y1huang commented May 25, 2026

Copy link
Copy Markdown

Which issue(s) this PR fixes:

Issue longhorn/longhorn#1061

What this PR does / why we need it:

Implement EC module.

Special notes for your reviewer:

None

Additional documentation or context

None

@c3y1huang c3y1huang self-assigned this May 25, 2026
@c3y1huang c3y1huang changed the title bdev/nvme: refresh namespace blockcnt during reset reconnect feat: ec module May 25, 2026
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 8 times, most recently from 0bdfee7 to e57455b Compare May 26, 2026 01:17
@c3y1huang c3y1huang requested a review from Copilot May 26, 2026 01:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new SPDK bdev_ec (erasure coding) module intended for Longhorn’s EC volumes, along with RPC/CLI surfaces, unit tests, and a small NVMe reconnect enhancement to refresh namespace capacity after a target-side resize.

Changes:

  • Add the bdev_ec module (WIB + unmapped-bitmap metadata, UNMAP fan-out, RMW path, resize support, and JSON-RPC handlers).
  • Add Python RPC/CLI bindings and a new unit test suite for EC bitmap/geometry logic.
  • Refresh NVMe namespace blockcnt during reconnect and notify upper layers of size changes.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
test/unit/unittest.sh Runs the new EC unit test binary from the unit test driver script.
test/unit/lib/bdev/Makefile Adds the EC unit-test subdirectory to the unit-test build.
test/unit/lib/bdev/ec/Makefile New unit-test subdir makefile for EC tests.
test/unit/lib/bdev/ec/bdev_ec.c/Makefile Builds the EC unit test source via the SPDK unittest makefile.
test/unit/lib/bdev/ec/bdev_ec.c/bdev_ec_ut.c Adds unit tests covering geometry math and unmapped-bitmap blob logic.
python/spdk/rpc/bdev.py Adds Python RPC client wrappers for EC lifecycle/ops RPCs.
python/spdk/cli/bdev.py Adds CLI commands for EC create/delete/status/replace/rebuild/resize.
module/bdev/nvme/bdev_nvme.c Refreshes namespace blockcnt during reconnect and notifies bdev layer.
module/bdev/Makefile Adds ec module directory to the bdev module build list.
module/bdev/ec/Makefile New build rules for the EC module library.
module/bdev/ec/bdev_ec.h Adds the EC module’s public header/API surface.
module/bdev/ec/bdev_ec_wib.c Implements WIB persist/load and WIB status query.
module/bdev/ec/bdev_ec_unmap.c Implements UNMAP handling (bitmap-backed fan-out + split head/tail zero-fill).
module/bdev/ec/bdev_ec_rpc.c Adds JSON-RPC handlers for EC lifecycle/data-plane/control operations.
module/bdev/ec/bdev_ec_rmw.c Implements RMW path for sub-stripe writes (including zero-fill).
module/bdev/ec/bdev_ec_resize.c Implements async in-place resize of EC bdevs after base growth.
module/bdev/ec/bdev_ec_bitmap.c Implements unmapped-bitmap on-disk format, persist/load, and bit-clear queue.
mk/spdk.modules.mk Registers bdev_ec in the global modules list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread module/bdev/ec/Makefile
Comment thread module/bdev/Makefile Outdated
Comment thread mk/spdk.modules.mk
Comment thread test/unit/lib/bdev/Makefile Outdated
Comment thread python/spdk/rpc/bdev.py
Comment thread module/bdev/ec/bdev_ec_rpc.c
Comment thread module/bdev/ec/bdev_ec_rmw.c
Comment thread module/bdev/ec/bdev_ec_bitmap.c
Comment thread python/spdk/rpc/bdev.py Outdated
Comment thread test/unit/unittest.sh Outdated
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 7 times, most recently from 29cbeba to fea1ddd Compare May 26, 2026 04:17
@c3y1huang c3y1huang requested a review from Copilot May 26, 2026 04:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Comment thread module/bdev/ec/bdev_ec_resize.c
Comment thread module/bdev/ec/bdev_ec_resize.c
Comment thread module/bdev/ec/bdev_ec.c Outdated
Comment thread module/bdev/ec/bdev_ec.c
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 4 times, most recently from 4849864 to a9cf467 Compare May 26, 2026 10:10
@c3y1huang c3y1huang requested a review from Copilot May 26, 2026 10:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.

Comment on lines +211 to +216
struct ec_bdev *ec = ec_from_bdev_io(ec_io->bdev_io);

ec_io->is_zero_fill = true;
ec->unmaps_via_write_zeros++;
return ec_submit_write(ec_io);
}

@c3y1huang c3y1huang May 26, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is by design. A single-stripe UNMAP never goes through the native path - it doesn't set bitmap bits or send UNMAP to the base disks; instead, it gets zero-filled (explained in ec_submit_unmap). So the count is not meant to add up. I reworded the comments so the gap doesn't read like a leak.

Comment thread module/bdev/ec/bdev_ec_unmap.c Outdated
Comment thread module/bdev/ec/bdev_ec_resize.c
c3y1huang added 26 commits June 10, 2026 18:11
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
…mitter thread

longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
… documentation

longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
…b APIs

longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 22 out of 22 changed files in this pull request and generated no new comments.

…s slot

longhorn/longhorn-1061

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
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.

2 participants