[PATCH v2 0/2] btrfs: add sysfs interface for qgroup

Qu Wenruo
2020-06-28T05:07:23Z

This patchset will add the following sysfs interfaces for qgroup:

/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/reference
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/exclusive
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/max_reference
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/max_exclusive
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/limit_flags
^^^ Above are already in "btrfs qgroup show" command output ^^^

/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/rsv_data
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/rsv_meta_pertrans
/sys/fs/btrfs/<UUID>/qgroups/<qgroup_id>/rsv_meta_prealloc

These interfaces are mostly for debug purpose, to give us a clear view
of which part is leaking.

Changelog:
v2:
- Add a new patch to change the return value type of
btrfs_qgroup_level()

- Fix the wrong btrfs_sysfs_add_one_qgroup() call timming
That function needs to allocate memory, thus can't be called in
add_qgroup_rb() where some call sites are holding a spin lock.
Delay btrfs_sysfs_add_one_qgroup() after add_qgroup_rb() until the
spin lock is released.

- Skip qgroup sysfs interface for qgroup selftest
This makes no sense for selftest to initialize the sysfs interface
and since we don't initialize fs_devices->kobj either, it's not
possible to utilize the sysfs interface in selftest.

- Use proper helpers for qgroup BTRFS_ATTRs

- Use more human-readable names in qgroup sysfs entries

- Remove the unneeded completion for qgroup

Qu Wenruo (2):
btrfs: use __u16 for the return value of btrfs_qgroup_level()
btrfs: qgroup: add sysfs interface for debug

fs/btrfs/ctree.h | 1 +
fs/btrfs/qgroup.c | 46 +++++++---
fs/btrfs/qgroup.h | 11 +++
fs/btrfs/sysfs.c | 151 ++++++++++++++++++++++++++++++++
fs/btrfs/sysfs.h | 6 ++
include/uapi/linux/btrfs_tree.h | 4 +-
6 files changed, 207 insertions(+), 12 deletions(-)

--
2.27.0