Skip to content

Btrfs: backref walking rewrite

Jan Schmidt linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest10 patches 2 repliesIn review
  2. v110 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- nested locking is now allowed implicitly, not only when path->nested is set
- force-pushed new version to mentioned git repo
---
Arne Jansen (6):
Btrfs: generic data structure to build unique lists
Btrfs: mark delayed refs as for cow
Btrfs: always save ref_root in delayed refs
Btrfs: add nested locking mode for paths
Btrfs: add sequence numbers to delayed refs
Btrfs: put back delayed refs that are too new

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10Btrfs: generic data structure to build unique listsfs/btrfs/Makefile fs/btrfs/ulist.c fs/btrfs/ulist.h+289 -10 replies
2/10Btrfs: added helper btrfs_next_item()fs/btrfs/ctree.h+7 -00 replies
3/10Btrfs: mark delayed refs as for cowfs/btrfs/ctree.c fs/btrfs/ctree.h fs/btrfs/delayed-ref.c +9 more+155 -1140 replies
4/10Btrfs: always save ref_root in delayed refsfs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h+12 -180 replies
5/10Btrfs: add nested locking mode for pathsfs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/locking.c+54 -20 replies
6/10Btrfs: add sequence numbers to delayed refsfs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h fs/btrfs/transaction.c+108 -00 replies
7/10Btrfs: put back delayed refs that are too newfs/btrfs/delayed-ref.c fs/btrfs/extent-tree.c+47 -230 replies
8/10Btrfs: add waitqueue instead of doing busy waiting for more delayed refsfs/btrfs/delayed-ref.c fs/btrfs/delayed-ref.h fs/btrfs/extent-tree.c +1 more+74 -10 replies
9/10Btrfs: added btrfs_find_all_roots()fs/btrfs/backref.c fs/btrfs/backref.h+788 -00 replies
10/10Btrfs: new backref walking codefs/btrfs/backref.c fs/btrfs/ioctl.c fs/btrfs/scrub.c+107 -2620 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 00/10] Btrfs: backref walking rewrite

This patch series is a major rewrite of the backref walking code. The patch series Arne sent some weeks ago for quota groups had a very interesting function, find_all_roots. I took this from him together with the bits needed for find_all_roots to work and replaced a major part of the code in backref.c with it.

It can be pulled from
git://git.jan-o-sch.net/btrfs-unstable for-chris
There's also a gitweb for that repo on

	http://git.jan-o-sch.net/?p=btrfs-unstable

My old backref code had several problems:
- it relied on a consistent state of the trees in memory
- it ignored delayed refs
- it only featured rudimentary locking
- it could miss some references depending on the tree layout

The biggest advantage is, that we're now able to do reliable backref resolving, even on busy file systems. So we've got benefits for:
- the existing "btrfs inspect-internal" commands
- aforementioned qgroups (patches on the list)
- "btrfs send" (currently in development)
- snapshot-aware defrag
- ... possibly more to come

Splitting the needed bits out of Arne's code was a quite intrusive operation. In case this goes into 3.3, any of us will soon make a rebased version of the qgroup patch set. Things corrected/changed in Arne's code along the way:
- don't assume INODE_ITEMs and the corresponding EXTENT_DATA items are in the same leaf (use the correct EXTENT_DATA_KEY for tree searches)
- don't assume all EXTENT_DATA items with the same backref for the same inode are in the same leaf (__resolve_indirect_refs can now add more refs)
- added missing key and level to prelim lists for shared block refs
- delayed ref sequence locking ability without wasting sequence numbers
- waitqueue instead of busy waiting for more delayed refs

As this touches a critical part of the file system, I also did some speed benchmarks. It turns out that dbench shows no performance decrease on my hardware. I can do more tests if desired.

By the way: this patch series fixes xfstest 278 (to be published soon) :-)

-Jan

---
Changelog v1->v2:
- nested locking is now allowed implicitly, not only when path->nested is set
- force-pushed new version to mentioned git repo
---
Arne Jansen (6):
Btrfs: generic data structure to build unique lists
Btrfs: mark delayed refs as for cow
Btrfs: always save ref_root in delayed refs
Btrfs: add nested locking mode for paths
Btrfs: add sequence numbers to delayed refs
Btrfs: put back delayed refs that are too new

Jan Schmidt (4):
Btrfs: added helper btrfs_next_item()
Btrfs: add waitqueue instead of doing busy waiting for more delayed
refs
Btrfs: added btrfs_find_all_roots()
Btrfs: new backref walking code

 fs/btrfs/Makefile      |    2 +-
 fs/btrfs/backref.c     | 1131 +++++++++++++++++++++++++++++++++++++-----------
 fs/btrfs/backref.h     |    5 +
 fs/btrfs/ctree.c       |   42 +-
 fs/btrfs/ctree.h       |   24 +-
 fs/btrfs/delayed-ref.c |  153 +++++--
 fs/btrfs/delayed-ref.h |  104 ++++-
 fs/btrfs/disk-io.c     |    3 +-
 fs/btrfs/extent-tree.c |  187 ++++++--
 fs/btrfs/extent_io.c   |    1 +
 fs/btrfs/extent_io.h   |    2 +
 fs/btrfs/file.c        |   10 +-
 fs/btrfs/inode.c       |    2 +-
 fs/btrfs/ioctl.c       |   13 +-
 fs/btrfs/locking.c     |   53 +++-
 fs/btrfs/relocation.c  |   18 +-
 fs/btrfs/scrub.c       |    7 +-
 fs/btrfs/transaction.c |    9 +-
 fs/btrfs/tree-log.c    |    2 +-
 fs/btrfs/ulist.c       |  220 ++++++++++
 fs/btrfs/ulist.h       |   68 +++
 21 files changed, 1638 insertions(+), 418 deletions(-)
 create mode 100644 fs/btrfs/ulist.c
 create mode 100644 fs/btrfs/ulist.h
Signature · 1 line
1.7.3.4