Skip to content

btrfs: more optimizations for lseek and fiemap

[email protected] linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9btrfs: remove leftover setting of EXTENT_UPTODATE state in an inode's io_treefs/btrfs/extent-io-tree.h fs/btrfs/extent_io.c+3 -230 replies
2/9btrfs: add an early exit when searching for delalloc range for lseek/fiemapfs/btrfs/file.c+16 -60 replies
3/9btrfs: skip unnecessary delalloc searches during lseek/fiemapfs/btrfs/file.c+7 -10 replies
4/9btrfs: search for delalloc more efficiently during lseek/fiemapfs/btrfs/file.c+48 -1040 replies
5/9btrfs: remove no longer used btrfs_next_extent_map()fs/btrfs/extent_map.c fs/btrfs/extent_map.h+0 -310 replies
6/9btrfs: allow passing a cached state record to count_range_bits()fs/btrfs/extent-io-tree.c fs/btrfs/extent-io-tree.h fs/btrfs/file.c +1 more+49 -60 replies
7/9btrfs: update stale comment for count_range_bits()fs/btrfs/extent-io-tree.c+23 -30 replies
8/9btrfs: use cached state when looking for delalloc ranges with fiemapfs/btrfs/extent_io.c fs/btrfs/file.c fs/btrfs/file.h+18 -40 replies
9/9btrfs: use cached state when looking for delalloc ranges with lseekfs/btrfs/ctree.h fs/btrfs/file.c+33 -80 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/9] btrfs: more optimizations for lseek and fiemap

From: Filipe Manana <[email protected]>

Here follows a few more optimizations for lseek and fiemap. Starting with coreutils 9.0, cp no longer uses fiemap to determine where holes are in a file, instead it uses lseek's SEEK_HOLE and SEEK_DATA modes of operation. For very sparse files, or files with lot of delalloc, this can be very slow (when compared to ext4 or xfs). This aims to improve that.

The cp pattern is not specific to cp, it's common to iterate over all allocated regions of a file sequentially with SEEK_HOLE and SEEK_DATA, for either the whole file or just a section. Another popular program that does the same is tar, when using its --sparse / -S command line option (I use it like that for doing vm backups for example).

The details are in the changelogs of each patch, and results are on the changelog of the last patch in the series. There's still much more room for further improvement, but that won't happen too soon as it will require broader changes outside the lseek and fiemap code.

Filipe Manana (9):
btrfs: remove leftover setting of EXTENT_UPTODATE state in an inode's io_tree
btrfs: add an early exit when searching for delalloc range for lseek/fiemap
btrfs: skip unnecessary delalloc searches during lseek/fiemap
btrfs: search for delalloc more efficiently during lseek/fiemap
btrfs: remove no longer used btrfs_next_extent_map()
btrfs: allow passing a cached state record to count_range_bits()
btrfs: update stale comment for count_range_bits()
btrfs: use cached state when looking for delalloc ranges with fiemap
btrfs: use cached state when looking for delalloc ranges with lseek

 fs/btrfs/ctree.h          |   1 +
 fs/btrfs/extent-io-tree.c |  73 +++++++++++--
 fs/btrfs/extent-io-tree.h |  10 +-
 fs/btrfs/extent_io.c      |  30 +++---
 fs/btrfs/extent_map.c     |  29 -----
 fs/btrfs/extent_map.h     |   2 -
 fs/btrfs/file.c           | 221 ++++++++++++++++++--------------------
 fs/btrfs/file.h           |   1 +
 fs/btrfs/inode.c          |   2 +-
 9 files changed, 190 insertions(+), 179 deletions(-)
Signature · 1 line
2.35.1