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

modules/btrfs: add GetDefaultSubvolumeID #1222

Merged

Conversation

jelly
Copy link
Contributor

@jelly jelly commented Nov 17, 2023

libblockdev provides a method to get the default subvolume id since 2014, with no way to change it. This method does not require any administrative privileges but requires it for setting.

This feels more logical as a property but it requires a method call and I intend to also add a Setter for this. But that requires a libblockdev patch.

P.S. I hope the tests succeed. I'm unable to get the tests running on Arch Linux as it uses lsb_release and targetcli. Targetcli is not available as a package.

<!--
GetDefaultSubvolumeID:
@options: Additional options.
@since: 2.11.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: not sure if this is correct.

Copy link
Member

Choose a reason for hiding this comment

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

The version number? Yes, that's correct.

@jelly jelly marked this pull request as ready for review November 17, 2023 17:34
@StorageGhoul
Copy link

Can one of the admins verify this patch?

@vojtechtrefny
Copy link
Member

Jenkins, ok to test.

Copy link
Member

@vojtechtrefny vojtechtrefny left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

fstype = self.get_property(dev.obj, '.Block', 'IdType')
fstype.assertEqual('btrfs')

default_id = dev.obj.GetDefaultSubvolumeID(self.no_options,
Copy link
Member

Choose a reason for hiding this comment

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

You can use the _temp_mount context manager to mount the volume for this operation, the tests are now failing because the device is not mounted.

Copy link
Member

@tbzatek tbzatek left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

As long as getting the value requires a separate libblockdev call and perhaps some I/O, I'd suggest to leave it as a method, rather than a property.

libblockdev provides a method to get the default subvolume id since
2014, with no way to change it. This method does not require any
administrative privileges but requires it for setting.
@jelly jelly force-pushed the expose-default-btrfs-subvol-id branch from 142202c to c1c6adb Compare November 20, 2023 19:13
@jelly
Copy link
Contributor Author

jelly commented Nov 20, 2023

Looks good, thanks!

As long as getting the value requires a separate libblockdev call and perhaps some I/O, I'd suggest to leave it as a method, rather than a property.

Right, it would indeed be a bit wasteful and it's fine for us if it's a method 👍

@tbzatek
Copy link
Member

tbzatek commented Nov 21, 2023

Right, it would indeed be a bit wasteful and it's fine for us if it's a method 👍

Well, theoretically, since this is a plugin that needs to be activated first, any expensive I/O done on every uevent for btrfs devices may not be that much of a problem. At the end it depends on how often would you read the value.

@tbzatek tbzatek merged commit b6966b7 into storaged-project:master Nov 21, 2023
9 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.

4 participants