Skip to content

btrfs: updates to delayed refs accounting and space reservation

[email protected] linux-btrfs 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest21 patches 3 repliesIn review
  2. v121 patches 22 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21btrfs: fix race when refilling delayed refs block reservefs/btrfs/delayed-ref.c+34 -30 replies
2/21btrfs: prevent transaction block reserve underflow when starting transactionfs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h fs/btrfs/transaction.c+4 -110 replies
3/21btrfs: pass a space_info argument to btrfs_reserve_metadata_bytes()fs/btrfs/block-rsv.c fs/btrfs/delalloc-space.c fs/btrfs/delayed-ref.c +3 more+20 -180 replies
4/21btrfs: remove unnecessary logic when running new delayed referencesfs/btrfs/extent-tree.c+3 -140 replies
5/21btrfs: remove the refcount warning/check at btrfs_put_delayed_ref()fs/btrfs/delayed-ref.h+0 -10 replies
6/21btrfs: return -EUCLEAN for delayed tree ref with a ref count not equals to 1fs/btrfs/extent-tree.c+3 -30 replies
7/21btrfs: remove redundant BUG_ON() from __btrfs_inc_extent_ref()fs/btrfs/extent-tree.c+3 -40 replies
8/21btrfs: remove refs_to_add argument from __btrfs_inc_extent_ref()fs/btrfs/extent-tree.c+4 -50 replies
9/21btrfs: remove refs_to_drop argument from __btrfs_free_extent()fs/btrfs/extent-tree.c+5 -50 replies
10/21btrfs: initialize key where it's used when running delayed data reffs/btrfs/extent-tree.c+8 -60 replies
11/21btrfs: remove pointless 'ref_root' variable from run_delayed_data_ref()fs/btrfs/extent-tree.c+3 -50 replies
12/21btrfs: log message if extent item not found when running delayed extent opfs/btrfs/extent-tree.c+4 -10 replies
13/21btrfs: use a single variable for return value at run_delayed_extent_op()fs/btrfs/extent-tree.c+5 -80 replies
14/21btrfs: use a single variable for return value at lookup_inline_extent_backref()fs/btrfs/extent-tree.c+15 -180 replies
15/21btrfs: return -EUCLEAN if extent item is missing when searching inline backreffs/btrfs/extent-tree.c+1 -10 replies
16/21btrfs: simplify check for extent item overrun at lookup_inline_extent_backref()fs/btrfs/extent-tree.c+11 -110 replies
17/21btrfs: allow to run delayed refs by bytes to be released instead of countfs/btrfs/block-group.c fs/btrfs/extent-tree.c fs/btrfs/extent-tree.h +2 more+43 -420 replies
18/21btrfs: reserve space for delayed refs on a per ref basisfs/btrfs/delayed-ref.c fs/btrfs/disk-io.c fs/btrfs/extent-tree.c+38 -240 replies
19/21btrfs: remove pointless initialization at btrfs_delayed_refs_rsv_release()fs/btrfs/delayed-ref.c+1 -10 replies
20/21btrfs: stop doing excessive space reservation for csum deletionfs/btrfs/block-group.c fs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h +4 more+45 -260 replies
21/21btrfs: always reserve space for delayed refs when starting transactionfs/btrfs/block-rsv.c fs/btrfs/delayed-ref.c fs/btrfs/transaction.c +1 more+132 -322 replies

Reviews trailers per patch

20 of 21 patches have a Reviewed-by or Acked-by.

PatchJosef Bacik
1/21
2/21R-b
3/21R-b
4/21R-b
5/21R-b
6/21R-b
7/21R-b
8/21R-b
9/21R-b
10/21R-b
11/21R-b
12/21R-b
13/21R-b
14/21R-b
15/21R-b
16/21R-b
17/21R-b
18/21R-b
19/21R-b
20/21R-b
21/21R-b

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

Read the v2 thread

Cover letter [PATCH v2 00/21] btrfs: updates to delayed refs accounting and space reservation

From: Filipe Manana <[email protected]>

The following are some fixes, improvements and cleanups around delayed refs. Mostly about space accouting and reservation and were motivated by a case hit by a SLE (SUSE Linux Enterprise) user where a filesystem became unmountable and unusable because it fails a RW mount with -ENOSPC when attempting to do any orphan cleanup. The problem was that the device had no available space for allocating new block groups and the available metadata space was about 1.5M, too little to commit any transaction, but enough to start a transaction, as during the transaction commit we need to COW more than we accounted for when starting the transaction (running delayed refs generates more delayed refs to update the extent tree for example). Starting any transaction there, either to do orphan cleanup, attempt to reclaim data block groups, unlink, etc, always failed during the transaction commit and result in transaction aborts.

We have some cases where we use and abuse of the global block reserve because we don't reserve enough space when starting a transaction or account delayed refs properly, and can therefore lead to exhaustion of metadata space in case we don't have more unallocated space to allocate a new metadata block group.

More details on the individual changelogs.

There are more cases that will be addressed later and depend on this patchset, but they'll be sent later and separately.

Filipe Manana (21):
btrfs: fix race when refilling delayed refs block reserve
btrfs: prevent transaction block reserve underflow when starting transaction
btrfs: pass a space_info argument to btrfs_reserve_metadata_bytes()
btrfs: remove unnecessary logic when running new delayed references
btrfs: remove the refcount warning/check at btrfs_put_delayed_ref()
btrfs: return -EUCLEAN for delayed tree ref with a ref count not equals to 1
btrfs: remove redundant BUG_ON() from __btrfs_inc_extent_ref()
btrfs: remove refs_to_add argument from __btrfs_inc_extent_ref()
btrfs: remove refs_to_drop argument from __btrfs_free_extent()
btrfs: initialize key where it's used when running delayed data ref
btrfs: remove pointless 'ref_root' variable from run_delayed_data_ref()
btrfs: log message if extent item not found when running delayed extent op
btrfs: use a single variable for return value at run_delayed_extent_op()
btrfs: use a single variable for return value at lookup_inline_extent_backref()
btrfs: return -EUCLEAN if extent item is missing when searching inline backref
btrfs: simplify check for extent item overrun at lookup_inline_extent_backref()
btrfs: allow to run delayed refs by bytes to be released instead of count
btrfs: reserve space for delayed refs on a per ref basis
btrfs: remove pointless initialization at btrfs_delayed_refs_rsv_release()
btrfs: stop doing excessive space reservation for csum deletion
btrfs: always reserve space for delayed refs when starting transaction

 fs/btrfs/block-group.c    |  11 +-
 fs/btrfs/block-rsv.c      |  18 ++--
 fs/btrfs/delalloc-space.c |   3 +-
 fs/btrfs/delayed-ref.c    | 132 +++++++++++++++++-------
 fs/btrfs/delayed-ref.h    |  15 ++-
 fs/btrfs/disk-io.c        |   3 +-
 fs/btrfs/extent-tree.c    | 208 +++++++++++++++++++-------------------
 fs/btrfs/extent-tree.h    |   4 +-
 fs/btrfs/space-info.c     |  29 ++----
 fs/btrfs/space-info.h     |   2 +-
 fs/btrfs/transaction.c    | 143 ++++++++++++++++++++------
 fs/btrfs/transaction.h    |   3 +
 12 files changed, 357 insertions(+), 214 deletions(-)
Signature · 1 line
2.40.1