Skip to content

Btrfs: make ranged fsyncs always respect the given range

[email protected] linux-btrfs 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 4 repliesIn review
  2. v24 patches 0 repliesSuperseded
  3. v13 patches 0 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4Btrfs: fix missing file extent item for hole after ranged fsyncfs/btrfs/file.c+10 -00 replies
2/4Btrfs: add helper to get the end offset of a file extent itemfs/btrfs/ctree.h fs/btrfs/file-item.c fs/btrfs/inode.c +2 more+34 -760 replies
3/4Btrfs: factor out inode items copy loop from btrfs_log_inode()fs/btrfs/tree-log.c+141 -1360 replies
4/4Btrfs: make ranged full fsyncs more efficientfs/btrfs/file.c fs/btrfs/tree-log.c+79 -270 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchJosef Bacik
SeriesR-b
1/4
2/4
3/4
4/4

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

Read the v3 thread

Cover letter [PATCH v3 0/4] Btrfs: make ranged fsyncs always respect the given range

From: Filipe Manana <[email protected]>

This patchset fixes a bug when not using NO_HOLES and makes ranged fsyncs respect the given file range when using the NO_HOLES feature.

The bug is about missing file extents items representing a hole after doing a ranged fsync on a file and replaying the log.

Btrfs doesn't respect the given range for a fsync when the inode's has the "need full sync" bit set - it treats the fsync as a full ranged one, operating on the whole file, doing more IO and cpu work then needed.

That behaviour was needed to fix a corruption bug. Commit 0c713cbab6200b ("Btrfs: fix race between ranged fsync and writeback of adjacent ranges") fixed that bug by turning the ranged fsync into a full ranged one.

Later the hole detection code of fsync was simplified a lot in order to fix another bug when using the NO_HOLES feature - done by commit 0e56315ca147b3 ("Btrfs: fix missing hole after hole punching and fsync when using NO_HOLES"). That commit now makes it easy to avoid turning the ranged fsyncs into non-ranged fsyncs.

This patchset does those two changes. The first patch fixes the bug mentioned before, patches 2 and 3 are preparation cleanups for patch 4, which is the one that makes fsync respect the given file range when using NO_HOLES.

V3: Updated patch one so that the ranged is set to full before locking the
inode. To make sure we do writeback and wait for ordered extent completion as much as possible before locking the inode. Remaining patches are unchanged.

V2: Added one more patch to the series, which is the first patch, that
fixes the bug regarding missing holes after doing a ranged fsync.

The remaining patches remain the same, only patch 4 had a trivial conflict when rebasing against patch 1 and got its changelog updated. Now all fstests pass with version 2 of this patchset.

Filipe Manana (4):
Btrfs: fix missing file extent item for hole after ranged fsync
Btrfs: add helper to get the end offset of a file extent item
Btrfs: factor out inode items copy loop from btrfs_log_inode()
Btrfs: make ranged full fsyncs more efficient

 fs/btrfs/ctree.h     |   1 +
 fs/btrfs/file-item.c |  40 ++++--
 fs/btrfs/file.c      |  23 ++--
 fs/btrfs/inode.c     |  10 +-
 fs/btrfs/send.c      |  44 +-----
 fs/btrfs/tree-log.c  | 379 +++++++++++++++++++++++++++++----------------------
 6 files changed, 261 insertions(+), 236 deletions(-)
Signature · 1 line
2.11.0