Skip to content

feat: ec module#72

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

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

Conversation

@c3y1huang
Copy link
Copy Markdown

@c3y1huang c3y1huang commented May 25, 2026

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 added 30 commits May 13, 2026 09:07
longhorn/longhorn-1061

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

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>
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>
…queue

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>
…gments

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>
…d bit clear

longhorn/longhorn-1061

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

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>
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 2 times, most recently from 1fc7dfd to 9491893 Compare May 28, 2026 07:43
@c3y1huang c3y1huang requested a review from Copilot May 28, 2026 07:48
Copy link
Copy Markdown

Copilot AI left a comment

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 thread module/bdev/ec/bdev_ec_rmw.c
Comment thread module/bdev/ec/bdev_ec_rpc.c
Comment thread python/spdk/rpc/bdev.py
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 3 times, most recently from c097726 to 82ddb16 Compare May 28, 2026 09:10
@c3y1huang c3y1huang requested a review from Copilot May 28, 2026 09:11
Copy link
Copy Markdown

Copilot AI left a comment

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 6 comments.

Comment thread module/bdev/ec/bdev_ec.c Outdated
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
* the JSON-RPC response once WIB load completes.
*/
}
SPDK_RPC_REGISTER("bdev_ec_create", rpc_bdev_ec_create, SPDK_RPC_RUNTIME)
Copy link
Copy Markdown
Author

@c3y1huang c3y1huang May 28, 2026

Choose a reason for hiding this comment

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

IMO, this is legitimate but low priority for this PR deliverable. Longhorn doesn't read schema/schema.json, impact zero. Can defer to later and improve on request.

Comment thread module/bdev/ec/bdev_ec_bitmap.c
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 6 times, most recently from 94ab6a1 to 744e8f0 Compare May 28, 2026 12:09
@c3y1huang c3y1huang requested a review from Copilot May 28, 2026 12:09
Copy link
Copy Markdown

Copilot AI left a comment

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 7 comments.

Comment thread module/bdev/ec/bdev_ec_rpc.c
Comment thread module/bdev/ec/bdev_ec_resize.c
Comment thread module/bdev/ec/bdev_ec_resize.c Outdated
Comment on lines +456 to +478
slot_lba_blocks = ec_bitmap_slot_lba_blocks(ec, ctx->next_copy);

ec->bitmap_persist_pending = true;

for (i = 0; i < ec->n; i++) {
if (!ec->descs[i] || !ec->bitmap_chans[i] ||
!ec_slot_is_writable(ec, i)) {
continue;
}

ctx->writes_in_flight++;
rc = spdk_bdev_write(ec->descs[i],
ec->bitmap_chans[i],
ctx->dma_buf,
slot_lba_blocks * ec->bdev.blocklen,
slot_size_bytes,
ec_bitmap_persist_write_cb,
ctx);
if (rc != 0) {
SPDK_WARNLOG("EC bdev %s: bitmap persist submit failed "
"for slot %u (rc=%d)\n",
ec->bdev.name, i, rc);
ctx->writes_in_flight--;
Copy link
Copy Markdown
Author

@c3y1huang c3y1huang May 29, 2026

Choose a reason for hiding this comment

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

The suggested fix seems under-evaluated (potentially might break the bitmap's single-writer on-disk model). Went with marshalling + home-thread assertion.

Copy link
Copy Markdown
Author

@c3y1huang c3y1huang May 29, 2026

Choose a reason for hiding this comment

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

I've also under-evaluated. Since Longhorn V2 RAID1 mode supports multi-reactor, marshalling + home-thread assertions are not a good fit, either (1) all write requests would need to be marshalled back to the home-thread, or (2) write requests would get dropped due to home-thread assertions in the multi-reactor case. Neither is safe/scalable approach.

Planning for multi-reactor support.

Copy link
Copy Markdown
Author

@c3y1huang c3y1huang May 29, 2026

Choose a reason for hiding this comment

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

PoC with a similar approach to the blobstore md_thread pattern.

Comment thread module/bdev/ec/bdev_ec_wib.c
Comment thread module/bdev/ec/bdev_ec_wib.c
Comment thread module/bdev/ec/bdev_ec_rmw.c
@c3y1huang c3y1huang force-pushed the 1061-v2-sharding branch 7 times, most recently from c4e0838 to 78af565 Compare May 29, 2026 05:28
@c3y1huang c3y1huang requested a review from Copilot May 29, 2026 05:28
Copy link
Copy Markdown

Copilot AI left a comment

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 7 comments.

Comment thread module/bdev/ec/bdev_ec_bitmap.c Outdated
Comment on lines +413 to +416
* For now the assert lands here: under multi-reactor it aborts at the
* exact spot the follow-up needs to land. Single-reactor is unaffected.
*/
assert(spdk_get_thread() == ec->home_thread);
Comment on lines +356 to +360
* For now the assert lands here: under multi-reactor it aborts at
* the exact spot the follow-up needs to land. Single-reactor is
* unaffected.
*/
assert(spdk_get_thread() == ec->home_thread);
Comment on lines +904 to +908
* For now the assert lands here: under multi-reactor it aborts at
* the exact spot the follow-up needs to land. Single-reactor is
* unaffected.
*/
assert(spdk_get_thread() == ec->home_thread);
Comment on lines +9 to +11
* The WIB protects against the RMW write-hole. One dirty bit per
* region of EC_WIB_REGION_STRIPES stripes, stored on-disk as two
* alternating copies in the last two strips of every parity disk.
Comment on lines +254 to +257
* Protects against the RMW write-hole. One dirty bit per region of
* EC_WIB_REGION_STRIPES stripes, stored on-disk as two alternating
* copies in the last two strips of every parity disk. See
* bdev_ec_wib.c for the on-disk layout and persist protocol.
Comment thread module/bdev/ec/bdev_ec_io.c Outdated
if (spdk_likely(owner == spdk_get_thread())) {
ec_write_into_unmapped_finalize(ec_io);
} else {
spdk_thread_send_msg(owner, ec_write_into_unmapped_finalize, ec_io);
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