On Mon, Mar 09, 2020 at 12:41:04PM +0000, fdmanana@xxxxxxxxxx wrote:
> From: Filipe Manana <fdmanana@xxxxxxxx>
>
> 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
Moved from for-next to misc-next, thanks.