Skip to content

lvmd: unify VG and ThinPool behind storagePool interface #1057

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

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

molpako
Copy link
Contributor

@molpako molpako commented Jun 13, 2025

This cleans up duplicated branch logic, improves abstraction, and makes future extensions easier.

  • Introduce storagePool interface and storagePoolForDeviceClass factory
  • Add volumeGroupAdapter and thinPoolAdapter (which embed VG/ThinPool) to implement storagePool
  • Use storagePool methods in lvservice/vgservice, eliminating dc.Type switches
  • Rename ThinPool.Free to Usage; move overprovision logic into ThinPoolUsage.FreeBytes
  • Remove calcThinPoolFreeBytes utility

@cupnes cupnes moved this from To do to In progress in Development Jun 13, 2025
@molpako molpako marked this pull request as ready for review June 13, 2025 05:54
@molpako molpako requested a review from a team as a code owner June 13, 2025 05:54
@molpako molpako force-pushed the refactor/abstraction-deviceclass branch from 67c1364 to deffae4 Compare June 19, 2025 08:07
@molpako molpako requested a review from peng225 June 19, 2025 08:13
Copy link
Contributor

@peng225 peng225 left a comment

Choose a reason for hiding this comment

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

The e2e test failed. Could you take a look?

@molpako
Copy link
Contributor Author

molpako commented Jun 19, 2025

@peng225 The timeout appeared to be just a flaky failure, but I have retried the test.

@molpako molpako requested a review from peng225 June 19, 2025 09:55
@@ -287,6 +288,17 @@ type ThinPoolUsage struct {
SizeBytes uint64
}

func (t ThinPoolUsage) Free(overprovisionRatio float64) (uint64, error) {
Copy link
Member

Choose a reason for hiding this comment

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

How about renaming this function like this?

Suggested change
func (t ThinPoolUsage) Free(overprovisionRatio float64) (uint64, error) {
func (t ThinPoolUsage) FreeBytes(overprovisionRatio float64) (uint64, error) {

It's to clarify that this function is to return the remaining space in bytes. Free means deallocate something in many cases and it might confuse developers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, that sounds better!

@molpako molpako force-pushed the refactor/abstraction-deviceclass branch from deffae4 to 9f03694 Compare June 20, 2025 08:08
@molpako molpako requested a review from satoru-takeuchi June 20, 2025 08:29
@@ -79,7 +79,7 @@ func ValidateDeviceClasses(deviceClasses []*lvmdTypes.DeviceClass) error {
return fmt.Errorf("thinpool name should not be empty: %s", dc.Name)
}

if dc.ThinPoolConfig.OverprovisionRatio < 1.0 {
if dc.ThinPoolConfig.OverprovisionRatio <= 1.0 {
Copy link
Member

Choose a reason for hiding this comment

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

@llamerada-jp I have one question. The proposal of thinpool support describes "allowed values are greater than 1.0". On the other hands, this code allows 1.0 for this parameter. Furthermore, L83 describes "should be greater than 1.0". Could you tell me which is the original intention?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a difficult question.
Looking at the discussion at the time, it seems that 1.0 was finally accepted. However, since the comments and specifications have not been updated, it is likely that this difference has not been taken into consideration.
https://github.com/topolvm/topolvm/pull/442/files#r830792492
Since the current implementation allows values of 1.0, if there are sites that already have 1.0 set, an error will occur. If there is no technical reason to reject 1.0, I think it is better to avoid taking the risk of changing the check condition in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I won't modify the check condition in this PR.

@peng225 peng225 moved this from In progress to Review in progress in Development Jun 23, 2025
@molpako molpako force-pushed the refactor/abstraction-deviceclass branch from 9f03694 to af6579d Compare June 25, 2025 02:32
@molpako molpako requested a review from satoru-takeuchi June 25, 2025 04:03
peng225
peng225 previously approved these changes Jun 25, 2025
This cleans up duplicated branch logic, improves abstraction, and makes future extensions easier.
- Introduce storagePool interface and storagePoolForDeviceClass factory
- Add volumeGroupAdapter and thinPoolAdapter (which embed VG/ThinPool) to implement storagePool
- Use storagePool methods in lvservice/vgservice, eliminating dc.Type switches
- Rename ThinPool.Free to Usage; move overprovision logic into ThinPoolUsage.Free
- Remove calcThinPoolFreeBytes utility

Signed-off-by: Kyori Sakao <sakaok@cybozu.co.jp>
@molpako molpako force-pushed the refactor/abstraction-deviceclass branch from af6579d to 9fe4a53 Compare June 25, 2025 08:09
@satoru-takeuchi satoru-takeuchi merged commit 632afc8 into main Jun 27, 2025
24 checks passed
@satoru-takeuchi satoru-takeuchi deleted the refactor/abstraction-deviceclass branch June 27, 2025 01:10
@github-project-automation github-project-automation bot moved this from Review in progress to Done in Development Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants