-
Notifications
You must be signed in to change notification settings - Fork 19
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
Initial wrapper for BtrfsQgroup and associated methods #1163
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
# Copyright (c) [2020] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "y2storage/storage_class_wrapper" | ||
require "y2storage/disk_size" | ||
|
||
module Y2Storage | ||
# A qgroup of a Btrfs filesystem | ||
# | ||
# This is a wrapper for Storage::BtrfsQgroup. | ||
# | ||
# In Btrfs, the qgroups hold the quota information for a given set of subvolumes. | ||
# Although they can be organized in a tree hierarchy, we are only considering the | ||
# first level (level 0, actually), so they are associated to a single subvolume. | ||
# | ||
# @see man btrfs-quota | ||
# @see man btrfs-qgroup | ||
class BtrfsQgroup < Device | ||
wrap_class Storage::BtrfsQgroup | ||
|
||
storage_forward :storage_id, to: :id | ||
private :storage_id | ||
|
||
# Id of the group including the level and the qgroup id | ||
# | ||
# For qgroups of level 0, the second term (the qgroup id) matches the id of | ||
# the corresponding subvolume. | ||
# | ||
# @return [Array<Integer>] includes two terms, level and id | ||
def id | ||
[storage_id.first, storage_id.second] | ||
end | ||
|
||
# @!method referenced | ||
# Size of the referenced space of the qgroup | ||
# | ||
# @return [DiskSize] zero if the size is not known (the qgroup was created after probing) | ||
shundhammer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
storage_forward :referenced, as: "DiskSize" | ||
|
||
# @!method exclusive | ||
# Size of the exclusive space of the qgroup | ||
# | ||
# @return [DiskSize] zero if the size is not known (the qgroup was created after probing) | ||
storage_forward :exclusive, as: "DiskSize" | ||
|
||
storage_forward :storage_referenced_limit, to: :referenced_limit, as: "DiskSize" | ||
private :storage_referenced_limit | ||
|
||
# Limit of the referenced space for the qgroup | ||
# | ||
# @return [DiskSize] unlimited if there is no quota | ||
def referenced_limit | ||
return DiskSize.unlimited unless to_storage_value.has_referenced_limit | ||
|
||
storage_referenced_limit | ||
end | ||
|
||
# Setter for {#referenced_limit} | ||
# | ||
# @param limit [DiskSize] setting it to DiskSize.Unlimited removes the quota | ||
def referenced_limit=(limit) | ||
if limit.unlimited? | ||
to_storage_value.clear_referenced_limit | ||
else | ||
to_storage_value.referenced_limit = limit.to_i | ||
end | ||
end | ||
|
||
storage_forward :storage_exclusive_limit, to: :exclusive_limit, as: "DiskSize" | ||
private :storage_exclusive_limit | ||
|
||
# @!method exclusive_limit | ||
# Limit of the exclusive space for the qgroup | ||
# | ||
# @return [DiskSize] unlimited if there is no quota | ||
def exclusive_limit | ||
return DiskSize.unlimited unless to_storage_value.has_exclusive_limit | ||
|
||
storage_exclusive_limit | ||
end | ||
|
||
# Setter for {#exclusive_limit} | ||
# | ||
# @param limit [DiskSize] setting it to DiskSize.Unlimited removes the quota | ||
def exclusive_limit=(limit) | ||
if limit.unlimited? | ||
to_storage_value.clear_exclusive_limit | ||
else | ||
to_storage_value.exclusive_limit = limit.to_i | ||
end | ||
end | ||
|
||
protected | ||
|
||
# @see Device#is? | ||
def types_for_is | ||
super << :btrfs_qgroup | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please add
@see man btrfs-quota
which contains some more high-level documentation to make sense of what this is all about.I looked at
man btrfs-qgroup
, and it's a particular useless piece of documentation, written for those who already know everything (like so much of the Btrfs documentation).