-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve lvol snapshot checksum get #185
Conversation
Longhorn 8666, 9488 Signed-off-by: Shuo Wu <[email protected]>
WalkthroughThe changes involve modifications to snapshot checksum handling in the SPDK (Storage Performance Development Kit) client implementation. The primary updates focus on how snapshot checksums are retrieved, stored, and processed. The modifications include changing the checksum representation from a pointer to a Changes
Sequence DiagramsequenceDiagram
participant Client
participant SPDKClient
participant LogicalVolume
Client->>SPDKClient: BdevLvolGetWithFilter()
SPDKClient->>LogicalVolume: Check for Snapshot
alt Has Snapshot
SPDKClient->>SPDKClient: BdevLvolGetSnapshotChecksum()
SPDKClient-->>LogicalVolume: Store Checksum in Xattrs
end
SPDKClient-->>Client: Return Logical Volume Details
The sequence diagram illustrates the new flow of retrieving and storing snapshot checksums during the logical volume retrieval process, highlighting the conditional checksum extraction when a snapshot is present. Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
pkg/spdk/client/basic.go (1)
300-305
: Snapshot checksum retrieval gracefully handles errors.
When a snapshot is detected, retrieving and storing its checksum inXattrs
is efficient. If an error occurs, the code continues without halting, which is good for resiliency. Nevertheless, consider logging or documenting the failure reason to ease debugging.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/cmd/basic/bdev_lvol.go
(1 hunks)pkg/spdk/client/basic.go
(3 hunks)
🔇 Additional comments (7)
app/cmd/basic/bdev_lvol.go (2)
746-746
: Use consistent checks for "not found" vs. "invalid" checksums.
Switching from a nil-check to an empty-string check aligns well with the updated return type. However, consider making the error message more explicit if you suspect an "empty" checksum to encompass both "not found" or "invalid format."
750-750
: Returning the checksum as a string is more straightforward.
Printing the string checksum directly is an improvement over dereferencing a pointer. Ensure the calling code is updated to receive a string rather than a pointer.
pkg/spdk/client/basic.go (5)
21-21
: New SnapshotChecksum
constant is well-defined.
Defining a dedicated constant introduces better consistency and readability for referencing the snapshot checksum xattr name.
531-531
: Returning a string from BdevLvolGetSnapshotChecksum
is simpler.
This updated signature is more intuitive for external calls, removing the complexity of pointer handling.
538-538
: Empty return on error is consistent with the updated approach.
Returning ""
on error (rather than an uninitialized pointer) prevents potential panics and simplifies caller logic.
544-544
: Error handling is consistent.
Maintaining a uniform approach for error returns across the function clarifies code flow and avoids confusion.
547-547
: Converting checksum to string ensures flexible usage downstream.
Using strconv.FormatUint
means consumers can log or compare checksums without extra conversions. Ensure edge cases (e.g., zero checksums) are handled appropriately.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #185 +/- ##
==========================================
+ Coverage 22.41% 22.61% +0.19%
==========================================
Files 34 34
Lines 4944 4949 +5
==========================================
+ Hits 1108 1119 +11
+ Misses 3659 3652 -7
- Partials 177 178 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Which issue(s) this PR fixes:
Issue
longhorn/longhorn#8666
longhorn/longhorn#9488
What this PR does / why we need it:
We need a convenient way to get all info of a snapshot lvol including its checksum. For now, we can put the checksum in lvol xattr map.
Special notes for your reviewer:
Additional documentation or context