Skip to contentSkip to conversation

Btrfs: make ranged fsyncs always respect the given range

PATCH Superseded [email protected] 1 participant 1 message Mar 6, 2020 Btrfs file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover 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 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 that. 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.

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      |  11 +-
 fs/btrfs/inode.c     |  10 +-
 fs/btrfs/send.c      |  44 +-----
 fs/btrfs/tree-log.c  | 379 +++++++++++++++++++++++++++++----------------------
 6 files changed, 255 insertions(+), 230 deletions(-)
Signature · 1 line
2.11.0