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

Handle cgroups when subvolumes/snapshots are deleted when quota support is enabled. #49

Closed
friederschueler opened this issue Sep 30, 2015 · 10 comments
Labels

Comments

@friederschueler
Copy link

@friederschueler friederschueler commented Sep 30, 2015

Hello,

I have enabled quota support and btrfs creates a qgroup with id 0/{subvolid} whenever a subvolume is created. But this qgroup is not deleted when the subvolume is deleted. Could you add an option to delete the correct qgroup when the subvolume is deleted?

@digint
Copy link
Owner

@digint digint commented Sep 30, 2015

First of all, let me say that I don't have much experience with btrfs qgroups, so I'll need your help here.

As far as I see from the documentations, qgroups are deleted like this:

btrfs qgroup destroy <qgroupid> <path>

For a subvolume with ID=123 ("Subvolume ID" from btrfs sub show) of a btrfs filesystem mounted on /mnt/btr_pool, the command to be run should be something like this:

btrfs qgroup destroy "0/123" /mnt/btr_pool/

Can you tell me what exactly the <path> is here? Does it have to be the mount-point of a volume mounted with subvolid=0, or can it be "just anywhere within a btrfs filesystem", e.g. the <target-directory> from the btrbk config line: target send-receive <target-directory>, or <volume-directory> from volume <volume-directory>?

@friederschueler
Copy link
Author

@friederschueler friederschueler commented Sep 30, 2015

Thanks for the quick response. I am not that expierenced using qgroups either and it seems there is not a lot of documentation out there.
On my pure btrfs system:

/etc/btrbk # btrfs subvolume list -a .
ID 257 gen 18326 top level 5 path <FS_TREE>/root
ID 259 gen 18326 top level 5 path <FS_TREE>/snapshots
ID 264 gen 18109 top level 257 path root/home
ID 271 gen 67 top level 257 path root/var/lib/machines

any path, e.g. "." works. I guess it can be just anywhere within a btrfs filesystem.

@digint
Copy link
Owner

@digint digint commented Sep 30, 2015

I added a qgroup branch, with preliminary experimental support for destroying qgroups:

New configuration options:

  • snapshot_qgroup_destroy yes|no: destroys qgroup associated to the source snapshot 0/<subvolume_id> before deleting the snapshot
  • target_qgroup_destroy yes|no: : destroys qgroup associated to the target subvolume 0/<subvolume_id> before deleting the target subvolume

This is not yet tested.

@friederschueler: could you please look at https://github.com/digint/btrbk/blob/qgroup/btrbk, run it with btrbk -l debug dryrun, find and double-check the lines that look like this:

...
[btrfs] qgroup delete
[btrfs]   qgroup_id: 0/331
[btrfs]   subvolume: /tmp/btrbk_test/mnt_source/svol.20150930
Destroy qgroup "0/331" for: /tmp/btrbk_test/mnt_source/svol.20150930
### (dryrun) 'btrfs' 'qgroup' 'destroy' '0/331' '/tmp/btrbk_test/mnt_source/svol.20150930'
...

and tell me what happens when you execute the btrfs qgroup destroy commands?
Does it delete the correct qgroup?

@friederschueler
Copy link
Author

@friederschueler friederschueler commented Oct 1, 2015

Works like a charm! Thanks for the quick added feature.

I tested with dryrun and debug on and checked the commands. They looked good and the normal run deleted all the unnecessary groups without any problems.

I only tested snapshot_qgroup_destroy.

@digint digint added the enhancement label Oct 1, 2015
@digint
Copy link
Owner

@digint digint commented Oct 1, 2015

Great!

I will not merge this branch to master unless I have the time to experiment with btrfs quotas myself, since I simply cannot tell if this feature could possibly destroy unwanted things for people making heavy use of quotas.

Can you tell me if a qgroup "0/id" is also created on a btrfs receive operation? I suspect it is, as soon as quota support is enabled for the receiving subvolume (target-directory in btrbk). If not, target_qgroup_destroy would not make much sense.

@TomJohnZ
Copy link

@TomJohnZ TomJohnZ commented Dec 31, 2016

Hello,

I've been using the qgroup branch successfully for months now; it's really helped keep my subvolume list cleaner. However, it looks like that branch hasn't received update merges in a while. I was wondering if support has been dropped for qgroups, or alternatively if it might get merged into master at some point?

Thanks a lot for all your great work!

@digint
Copy link
Owner

@digint digint commented Jan 2, 2017

Thanks for reminding me, this one got forgotten on last release. Sorry about that.

I merged newest tag v0.24.0 into the qgroup branch (a6cc808), and removed some deprecated calls to run_cmd() in 2ae4557.

Should work as expected.

@TomJohnZ can you please confirm it working on a productive machine?

@TomJohnZ
Copy link

@TomJohnZ TomJohnZ commented Jan 6, 2017

Thanks a lot for the merge! I've been running it for a few days and it looks like it everything's working as expected. I appreciate the help.

@digint
Copy link
Owner

@digint digint commented Oct 2, 2017

Merged "qgroup" branch (now obsolete) to master, with some adaptions: e9a517f

@digint
Copy link
Owner

@digint digint commented Oct 12, 2017

included in btrbk-0.26.0

@digint digint closed this Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.