mbox series

[v2,0/3] btrfs: fix a couple swapfile support bugs

Message ID cover.1612529182.git.fdmanana@suse.com (mailing list archive)
Headers show
Series btrfs: fix a couple swapfile support bugs | expand

Message

Filipe Manana Feb. 5, 2021, 12:55 p.m. UTC
From: Filipe Manana <fdmanana@suse.com>

The following patchset fixes 2 bugs with the swapfile support, where we can
end up falling back to COW when writing to an active swapfile. The first patch
is actually independent and just makes the nocow buffered IO path more efficient
by eliminating a repeated check for a read-only block group.

V2: Removed the part of optimizing the direct IO nocow path from patch 2,
    because removing the RO block group check from can_nocow_extent() would
    leave the buffered write path that checks if we can fallback to nocow at
    write time (and not writeback time), after hitting ENOSPC when attempting
    to reserve data space, from doing that check. The optimization can still
    be done, but that would require adding more context information to
    can_nocow_extent(), so it could know when it needs to check if the block
    group is RO or not - since things are a bit entangled around that function
    and its callers, I've left it out for now.

Filipe Manana (3):
  btrfs: avoid checking for RO block group twice during nocow writeback
  btrfs: fix race between writes to swap files and scrub
  btrfs: fix race between swap file activation and snapshot creation

 fs/btrfs/block-group.c | 33 ++++++++++++++++++++++++++++++-
 fs/btrfs/block-group.h |  9 +++++++++
 fs/btrfs/ctree.h       |  5 +++++
 fs/btrfs/inode.c       | 44 ++++++++++++++++++++++++++++++++++++------
 fs/btrfs/scrub.c       |  9 ++++++++-
 5 files changed, 92 insertions(+), 8 deletions(-)

Comments

David Sterba Feb. 10, 2021, 10:15 p.m. UTC | #1
On Fri, Feb 05, 2021 at 12:55:35PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> The following patchset fixes 2 bugs with the swapfile support, where we can
> end up falling back to COW when writing to an active swapfile. The first patch
> is actually independent and just makes the nocow buffered IO path more efficient
> by eliminating a repeated check for a read-only block group.
> 
> V2: Removed the part of optimizing the direct IO nocow path from patch 2,
>     because removing the RO block group check from can_nocow_extent() would
>     leave the buffered write path that checks if we can fallback to nocow at
>     write time (and not writeback time), after hitting ENOSPC when attempting
>     to reserve data space, from doing that check. The optimization can still
>     be done, but that would require adding more context information to
>     can_nocow_extent(), so it could know when it needs to check if the block
>     group is RO or not - since things are a bit entangled around that function
>     and its callers, I've left it out for now.
> 
> Filipe Manana (3):
>   btrfs: avoid checking for RO block group twice during nocow writeback
>   btrfs: fix race between writes to swap files and scrub
>   btrfs: fix race between swap file activation and snapshot creation

Added to for-next, thanks. Target merge is 5.12-rc.