public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] btrfs: qgroup: remove GFP_ATOMIC usage for ulist
@ 2023-09-02  0:13 Qu Wenruo
  2023-09-02  0:13 ` [PATCH v3 1/6] btrfs: qgroup: iterate qgroups without memory allocation for qgroup_reserve() Qu Wenruo
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Qu Wenruo @ 2023-09-02  0:13 UTC (permalink / raw)
  To: linux-btrfs

[CHANGELOG]
v3:
- Remove the no longer utilized memalloc_nofs_save() calls
- Remove the "@" prefix of variables in the subject line
- Rename iterator2 to nested_iterator and enhance the comments of it

v2:
- Remove the final GFP_ATOMIC ulist usage
  This is done by introducing a new list_head, btrfs_qgroup::iterator2,
  allowing us to do nested iteration.

  This extra nested facility is needed as even if we move the qgroups
  collection into one dedicated function, we're reusing the list for
  iteration which can lead to unnecessary re-visit of the same qgroup.

  Thus we have to support one level of nested iteration.

- Add reviewed by tags from Boris

[REPO]
https://github.com/adam900710/linux/tree/qgroup_mutex

Yep, the branch name shows my previous failed attempt to solve the
problem.

[PROBLEM]
There are quite some GFP_ATOMIC usage for btrfs qgroups, most of them
are for ulists.

Those ulists are just used as a temporary memory to trace the involved
qgroups.

[ENHANCEMENT]
This patchset would address the problem by adding a new list_head called
iterator for btrfs_qgroup.

And all call sites but one of ulist allocation can be migrated to use
the new qgroup_iterator facility to iterate qgroups without any memory
allocation.

There is a special call site in btrfs_qgroup_account_extent() that it
wants to do nested qgroups iteration, thus a nested version is
introduced for this particular call site.

And BTW since we can skip quite some memory allocation failure handling
(since there is no memory allocation), we also save some lines of code.

Qu Wenruo (6):
  btrfs: qgroup: iterate qgroups without memory allocation for
    qgroup_reserve()
  btrfs: qgroup: use qgroup_iterator facility for
    btrfs_qgroup_free_refroot()
  btrfs: qgroup: use qgroup_iterator facility for qgroup_convert_meta()
  btrfs: qgroup: use qgroup_iterator facility for
    __qgroup_excl_accounting()
  btrfs: qgroup: use qgroup_iterator facility to replace tmp ulist of
    qgroup_update_refcnt()
  btrfs: qgroup: use qgroup_iterator_nested facility to replace qgroups
    ulist of qgroup_update_refcnt()

 fs/btrfs/qgroup.c | 337 +++++++++++++++++-----------------------------
 fs/btrfs/qgroup.h |  27 ++++
 2 files changed, 148 insertions(+), 216 deletions(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-09-06 16:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-02  0:13 [PATCH v3 0/6] btrfs: qgroup: remove GFP_ATOMIC usage for ulist Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 1/6] btrfs: qgroup: iterate qgroups without memory allocation for qgroup_reserve() Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 2/6] btrfs: qgroup: use qgroup_iterator facility for btrfs_qgroup_free_refroot() Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 3/6] btrfs: qgroup: use qgroup_iterator facility for qgroup_convert_meta() Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 4/6] btrfs: qgroup: use qgroup_iterator facility for __qgroup_excl_accounting() Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 5/6] btrfs: qgroup: use qgroup_iterator facility to replace tmp ulist of qgroup_update_refcnt() Qu Wenruo
2023-09-02  0:13 ` [PATCH v3 6/6] btrfs: qgroup: use qgroup_iterator_nested facility to replace qgroups " Qu Wenruo
2023-09-06 15:55 ` [PATCH v3 0/6] btrfs: qgroup: remove GFP_ATOMIC usage for ulist David Sterba
2023-09-06 16:07   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox