Skip to content

Commit

Permalink
drop qgroupid in share create when quotas are disabled rockstor#2506
Browse files Browse the repository at this point in the history
Previously we passed our -1/-1 'quotas disabled' flag value
to btrfs subvol create and it was silently ignored. This no
longer works: resulting in an error: 'invalid qgroupid ...'.
So drop the use of '-i qgroupid' when our flag value is
found. Includes updated docstrings for the altered code.

Also includes contextual fix re typo in two log entries
that advice on quota indeterminate remedial action:
"btrfs qgroup disable" corrected to "btrfs quota disable"
  • Loading branch information
phillxnet committed Mar 6, 2023
1 parent 4b7cc88 commit afb4e58
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,23 @@ def subvol_info(mnt_pt):

def add_share(pool, share_name, qid):
"""
share is a subvolume in btrfs.
Wrapper for 'btrfs subvol create' pool_mnt/share_name that will contextually also
include a Rockstor native qgroup option, e.g. '-i 2015/6', if our -1/-1 flag value
for quotas disabled is not found.
A Rockstor 'share' is a btrfs 'subvolume'.
:param pool: pool object
:param share_name: string for proposed share (btrfs subvol) name.
:return run_command(generated_command) or True if given pool subvol already exists.
"""
root_pool_mnt = mount_root(pool)
subvol_mnt_pt = root_pool_mnt + "/" + share_name
# Ensure our root_pool_mnt is not immutable, see: remove_share()
toggle_path_rw(root_pool_mnt, rw=True)
if not is_subvol(subvol_mnt_pt):
sub_vol_cmd = [BTRFS, "subvolume", "create", "-i", qid, subvol_mnt_pt]
if qid == PQGROUP_DEFAULT: # Quotas disabled
sub_vol_cmd = [BTRFS, "subvolume", "create", subvol_mnt_pt]
else:
sub_vol_cmd = [BTRFS, "subvolume", "create", "-i", qid, subvol_mnt_pt]
return run_command(sub_vol_cmd)
return True

Expand Down Expand Up @@ -1223,7 +1232,7 @@ def qgroup_max(mnt_pt):
):
logger.info(
"Mount Point: {} has indeterminate quota status, skipping "
"qgroup show.\nTry 'btrfs qgroup disable {}'.".format(mnt_pt, mnt_pt)
"qgroup show.\nTry 'btrfs quota disable {}'.".format(mnt_pt, mnt_pt)
)
return -1
# otherwise we raise an exception as normal.
Expand Down Expand Up @@ -1316,7 +1325,7 @@ def qgroup_destroy(qid, mnt_pt):
):
logger.info(
"Mount Point: {} has indeterminate quota status, skipping "
"qgroup show.\nTry 'btrfs qgroup disable {}'.".format(mnt_pt, mnt_pt)
"qgroup show.\nTry 'btrfs quota disable {}'.".format(mnt_pt, mnt_pt)
)
return False
# otherwise we raise an exception as normal
Expand Down

0 comments on commit afb4e58

Please sign in to comment.