Skip to content

btrfs: qgroup: Fix the long existing regression of btrfs/153

Qu Wenruo linux-btrfs 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 3 repliesIn review
  2. v33 patches 9 repliesSuperseded
  3. v23 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches15 repliesSuperseded

Changes in v4 from the cover letter

- Use rbtree_iterate_from_safe() wrapper to replace the while() loop
- Use proper variable names to replace single letter variable names
- Use proper btrfs_root bit with wait_queue_head to replace mutex

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: qgroup: allow btrfs_qgroup_reserve_data() to revert the range it just set without releasing other existing rangesfs/btrfs/qgroup.c+75 -151 reply
2/3btrfs: qgroup: try to flush qgroup space when we get -EDQUOTfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/qgroup.c+98 -81 reply
3/3btrfs: qgroup: remove the ASYNC_COMMIT mechanism in favor of qgroup reserve retry-after-EDQUOTfs/btrfs/ctree.h fs/btrfs/disk-io.c fs/btrfs/qgroup.c +2 more+2 -620 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchJosef Bacik
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/3] btrfs: qgroup: Fix the long existing regression of btrfs/153

Since commit c6887cd11149 ("Btrfs: don't do nocow check unless we have to"), btrfs/153 always fails with early EDQUOT.

This is caused by the fact that:
- We always reserved data space for even NODATACOW buffered write This is mostly to improve performance, and not pratical to revert.

- Btrfs qgroup data and meta reserved space share the same limit So it's not ensured to return EDQUOT just for that data reservation, metadata reservation can also get EDQUOT, means we can't go the same solution as that commit.

This patchset will solve it by doing extra qgroup space flushing when EDQUOT is hit.

This is a little like what we do in ticketing space reservation system, but since there are very limited ways for qgroup to reclaim space, currently it's still handled in qgroup realm, not reusing the ticketing system yet.

By this, this patch could solve the btrfs/153 problem, while still keep btrfs qgroup space usage under the limit.

The only cost is, when we're near qgroup limit, we will cause more dirty inodes flush and transaction commit, much like what we do when the metadata space is near exhausted.
So the cost should be still acceptable.

Changelog:
v2:
- Use existing ulist infrastructure
Thanks to the advice from Josef, we can just iterate the ulist nodes inside the failure range to remove the offending nodes. And since already dirtied range won't show up in the current extent changeset, we won't clear existing range.
This saves around 100 new lines

- Remove the use of "Revert" in the 3rd cleanup patch We're not reverting to fix some regression, but just remove some deprecated mechanism which was designed to partially solve the problem.

v3:
- Fix a variable shadowing bug
In the 2nd patch, there was a variable shadowing bug, which overrides the @start and @len parameter.

- Update the commit message for the first patch
To make the cause more obvious

- Use cleaner if condition before try_flush_qgroup()

v4:
- Use rbtree_iterate_from_safe() wrapper to replace the while() loop
- Use proper variable names to replace single letter variable names
- Use proper btrfs_root bit with wait_queue_head to replace mutex

Qu Wenruo (3):
btrfs: qgroup: allow btrfs_qgroup_reserve_data() to revert the range
it just set without releasing other existing ranges
btrfs: qgroup: try to flush qgroup space when we get -EDQUOT
btrfs: qgroup: remove the ASYNC_COMMIT mechanism in favor of qgroup
reserve retry-after-EDQUOT

 fs/btrfs/ctree.h       |   9 +-
 fs/btrfs/disk-io.c     |   2 +-
 fs/btrfs/qgroup.c      | 234 ++++++++++++++++++++++++++++++-----------
 fs/btrfs/transaction.c |   1 -
 fs/btrfs/transaction.h |  14 ---
 5 files changed, 175 insertions(+), 85 deletions(-)
Signature · 1 line
2.27.0