Skip to content
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] Let lvm create metadata volume automatically #171

Closed
wants to merge 1 commit into from

Conversation

rhvgoyal
Copy link
Collaborator

Fixes #169

Right now we create lvm metadata volume first and then data volume and then
pass it to lvm to convert it into a thin pool (lvconvert). This means lvm
internally creates an spare logical volume (used during repair) and needs
free space in volume group for that spare volume. But lvm does not tell
how big an spare volume will be so caller does not know how much free space
to leave in volume group. And that means if user passes in DATA_SIZE=100%FREE
by the time we call lvconvert, there is no free space left and lvconvert
fails. And we leave the system in uncleaned state (metadata and data volumes
behind).

Dusty came up with idea that why not let lvm create metadata, data and spare
volume. That way docker-storage-setup does not have to deal with how much
free space to leave. Also use option --poolmetadatasize option to specify
size of metadata, so that we retain control on how big metadata volume
should be.

This should allow users to pass in DATA_SIZE as 100%FREE. Though lvm
developers say it is not a good idea to fill up volume group completely
and leave some space free so that later either metadata, data or spare
volume can grow as need be.

This patch changes behavior of MIN_DATA_SIZE. Previously we will make sure
free space in VG is more than MIN_DATA_SIZE before creating data volume
(and after crating metadata volume). Now we do the same check before
creating metadata volume. Given metadata volume is very small (.1% of data
size). This can be considered sort of round off error and should not
be a real problem.

Reported-by: Dusty Mabe [email protected]
Signed-off-by: Vivek Goyal [email protected]

@rhvgoyal
Copy link
Collaborator Author

@cgwalters @rhatdan @shishir-a412ed PTAL

VG_SIZE=$(vgs --noheadings --nosuffix --units s -o vg_size $VG)
META_SIZE=$(( $VG_SIZE / 1000 + 1 ))
if [ -z "$META_SIZE" ];then
Fatal "Failed to calculate size of metadata volume"
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't need to do any of the above. let LVM do this for us as it will automatically create the metadata LV for us.

If we want to allow the user to specify META_SIZE in the future, then we can by simply exposing the --poolmetadatasize argument to them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am doing this so that I can give very clear error message to user if we screw up calculating the size of metadata volume. I don't know what error message will lvm emit if META_SIZE="". I can try though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I get following from lvm if META_SIZE="".

Invalid argument for --poolmetadatasize: s

I guess not bad. Will get rid of above check.

Copy link
Contributor

Choose a reason for hiding this comment

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

no, what I am saying is that we don't need any of the lines. We don't need to calculate META_SIZE at all and we don't need to pass that information in to the lvcreate command.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dustymabe I don't want to change existing behavior of the script until and unless we have a good reason to do so. As of now script calculates the metadata size and there is no reason to change it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dustymabe We can easily change it if our calculations become a problem. We had a long conversation in the past about how big a metadata lvm should be and we did not have a good answer. So we decided on .1%. Given it seems to be working reasonably well, I don't see an incentive to change it.

Even if we have to do it, it should be done in a separate PR and this PR should not be blocked because of that.

Copy link
Contributor

Choose a reason for hiding this comment

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

We had a long conversation in the past about how big a metadata lvm should be and we did not have a good answer.

Even more of a reason to let the tool decide.

Even if we have to do it, it should be done in a separate PR and this PR should not be blocked because of that.

I can accept that. if we leave it like this then we should probably add the 'if statement' back

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am not sure why do you think that lvm will necessarily do a better job of figuring out metadata volume size better. So I don't agree with Even more of a reason to let the tool decide. You are assuming that lvm always makes good decisions on this.

Ok, I can add back META_SIZE being empty check.

Copy link
Member

Choose a reason for hiding this comment

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

Offhand I think I agree with this:

Even if we have to do it, it should be done in a separate PR and this PR should not be blocked because of that. 

Copy link
Contributor

Choose a reason for hiding this comment

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

@cgwalters, yes, if we do something we should do it in a separate PR. The question is, should we do it (remove the calculation and specification of meta data lv size) or not?

@rhvgoyal
Copy link
Collaborator Author

Got rid of META_SIZE check. Also started using --type=thin-pool in lvconvert command instead of --thin. Suggested by lvm developers.

Right now we create lvm metadata volume first and then data volume and then
pass it to lvm to convert it into a thin pool (lvconvert). This means lvm
internally creates an spare logical volume (used during repair) and needs
free space in volume group for that spare volume. But lvm does not tell
how big an spare volume will be so caller does not know how much free space
to leave in volume group. And that means if user passes in DATA_SIZE=100%FREE
by the time we call lvconvert, there is no free space left and lvconvert
fails. And we leave the system in uncleaned state (metadata and data volumes
behind).

Dusty came up with idea that why not let lvm create metadata, data and spare
volume. That way docker-storage-setup does not have to deal with how much
free space to leave. Also use option --poolmetadatasize option to specify
size of metadata, so that we retain control on how big metadata volume
should be. 

This should allow users to pass in DATA_SIZE as 100%FREE. Though lvm
developers say it is not a good idea to fill up volume group completely
and leave some space free so that later either metadata, data or spare
volume can grow as need be. 

This patch changes behavior of MIN_DATA_SIZE. Previously we will make sure
free space in VG is more than MIN_DATA_SIZE before creating data volume
(and after crating metadata volume). Now we do the same check before
creating metadata volume. Given metadata volume is very small (.1% of data
size). This can be considered sort of round off error and should not
be a real problem.

Reported-by: Dusty Mabe <[email protected]>
Signed-off-by: Vivek Goyal <[email protected]>
@rhvgoyal
Copy link
Collaborator Author

@dustymabe Added META_SIZE check back. PTAL.

@rhvgoyal
Copy link
Collaborator Author

@rhatdan @cgwalters PTAL

@cgwalters
Copy link
Member

@rh-atomic-bot r+ c93c2e3

@rh-atomic-bot
Copy link

⌛ Testing commit c93c2e3 with merge 516cb9c...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: cgwalters
Pushing 516cb9c to master...

@rh-atomic-bot rh-atomic-bot changed the title Let lvm create metadata volume automatically [merged] Let lvm create metadata volume automatically Nov 17, 2016
@cgwalters
Copy link
Member

This is obviously a lot nicer!

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.

4 participants