mbox series

[v4,0/2] btrfs: some fiemap fixes

Message ID cover.1708797432.git.fdmanana@suse.com (mailing list archive)
Headers show
Series btrfs: some fiemap fixes | expand

Message

Filipe Manana Feb. 25, 2024, 7:51 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

There's a recent regression with fiemap due to a fix for a deadlock between
fiemap and memory mapped writes when the fiemap buffer is memory mapped to
the same file range, which leads to a race triggering a warning and making
fiemap fail. Plus one more long standing race when using FIEMAP_FLAG_SYNC.
Details in the change logs.

V4: Updated patch 1/2, added a lot more comments about that's going on,
    how each case is dealt with and why, added a missing handling for
    a delalloc case that could result in emmiting overlapping ranges.

V3: Deal with the case where offset == cache->offset which is also
    possible if we had delalloc in the range of a hole or prealloc extent.

V2: Updated patch 1/2 to deal with the case of a hole/prealloc extent
    with multiple delalloc ranges inside it.

Filipe Manana (2):
  btrfs: fix race between ordered extent completion and fiemap
  btrfs: ensure fiemap doesn't race with writes when FIEMAP_FLAG_SYNC is given

 fs/btrfs/extent_io.c | 124 ++++++++++++++++++++++++++++++++++++-------
 fs/btrfs/inode.c     |  22 +++++++-
 2 files changed, 125 insertions(+), 21 deletions(-)

Comments

Josef Bacik Feb. 26, 2024, 4:58 p.m. UTC | #1
On Sun, Feb 25, 2024 at 07:51:23PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> There's a recent regression with fiemap due to a fix for a deadlock between
> fiemap and memory mapped writes when the fiemap buffer is memory mapped to
> the same file range, which leads to a race triggering a warning and making
> fiemap fail. Plus one more long standing race when using FIEMAP_FLAG_SYNC.
> Details in the change logs.
> 
> V4: Updated patch 1/2, added a lot more comments about that's going on,
>     how each case is dealt with and why, added a missing handling for
>     a delalloc case that could result in emmiting overlapping ranges.
> 
> V3: Deal with the case where offset == cache->offset which is also
>     possible if we had delalloc in the range of a hole or prealloc extent.
> 
> V2: Updated patch 1/2 to deal with the case of a hole/prealloc extent
>     with multiple delalloc ranges inside it.
> 
> Filipe Manana (2):
>   btrfs: fix race between ordered extent completion and fiemap
>   btrfs: ensure fiemap doesn't race with writes when FIEMAP_FLAG_SYNC is given
> 

Eesh sorry about that, I must have missed the other test failure when I ran my
fix through CI.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef