Skip to content

blob: allow bdev_lvol_set_parent when child has more clusters than parent#73

Merged
derekbit merged 1 commit into
longhorn:longhorn-v25.09from
shuo-wu:master
Jun 12, 2026
Merged

blob: allow bdev_lvol_set_parent when child has more clusters than parent#73
derekbit merged 1 commit into
longhorn:longhorn-v25.09from
shuo-wu:master

Conversation

@shuo-wu

@shuo-wu shuo-wu commented Jun 10, 2026

Copy link
Copy Markdown

The I/O path already handles parent < child correctly:

  • blob_bs_dev_read zeros trailing bytes beyond the parent blockcnt
  • blob_bs_is_range_valid returns false for out-of-range clusters
  • bdev_lvol_snapshot already creates this parent < child relationship when snapshotting a resized lvol

Relax the check to only reject child < parent (which would be semantically invalid), allowing child >= parent as a valid reparenting operation, as the Longhorn SPDK server will encounter this case during rebuild.

Which issue(s) this PR fixes:

Issue longhorn/longhorn#12552

What this PR does / why we need it:

Special notes for your reviewer:

Additional documentation or context

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 relaxes the blob parent/child size constraint in spdk_bs_blob_set_parent() so a thin-provisioned child blob may be reparented to a snapshot with fewer clusters (child ≥ parent), which is a scenario encountered by Longhorn during rebuild and is already handled by the I/O path.

Changes:

  • Update the parent/child cluster-count validation to only reject the semantically invalid case where the child has fewer clusters than the parent snapshot.
  • Update the associated error log text (noting: the new log message currently doesn’t match the new condition and should be corrected).

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

Comment thread lib/blob/blobstore.c Outdated

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 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread lib/blob/blobstore.c
Comment thread lib/blob/blobstore.c
Comment thread lib/blob/blobstore.c Outdated
@shuo-wu
shuo-wu force-pushed the master branch 3 times, most recently from 1552a5c to 2051513 Compare June 11, 2026 00:22
…rent

The I/O path already handles parent < child correctly:
- blob_bs_dev_read zeros trailing bytes beyond the parent blockcnt
- blob_bs_is_range_valid returns false for out-of-range clusters
- bdev_lvol_snapshot already creates this parent < child relationship
  when snapshotting a resized lvol

Relax the check to only reject child < parent (which would be semantically
invalid), allowing child >= parent as a valid reparenting operation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Shuo Wu <shuo.wu@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 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread include/spdk/blob.h
Comment on lines +925 to +928
* The blob must have at least as many clusters as the parent snapshot
* (child cluster count >= parent cluster count). A child with more clusters
* than the parent is valid; reads beyond the parent range return zeros via
* thin provisioning.
Comment on lines +10456 to +10459
/* Call set_parent with blob that has more clusters than snapshot (child > parent, now succeeds) */
spdk_bs_blob_set_parent(bs, blobid2, snapshotid1, blob_op_complete, NULL);
poll_threads();
CU_ASSERT(g_bserrno == -EINVAL);
CU_ASSERT(g_bserrno == 0);
@derekbit
derekbit merged commit 440f107 into longhorn:longhorn-v25.09 Jun 12, 2026
2 checks passed
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.

3 participants