mbox series

[0/3] btrfs: fix fsync failure with SQL Server workload

Message ID cover.1621851896.git.fdmanana@suse.com (mailing list archive)
Headers show
Series btrfs: fix fsync failure with SQL Server workload | expand

Message

Filipe Manana May 24, 2021, 10:35 a.m. UTC
From: Filipe Manana <fdmanana@suse.com>

This patchset fixes a fsync failure (-EIO) and transaction abort during
a workload for Microsoft's SQL Server running in a Docker container as
reported at:

https://lore.kernel.org/linux-btrfs/93c4600e-5263-5cba-adf0-6f47526e7561@in.tum.de/

It also adds an optimization for the workload, by removing lots of fsyncs
that trigger the slow code path and replacing them with ones that use the
fast path, reducing the workload's runtime by about -12% on my test box.

Filipe Manana (3):
  btrfs: fix fsync failure and transaction abort after writes to
    prealloc extents
  btrfs: fix misleading and incomplete comment of btrfs_truncate()
  btrfs: don't set the full sync flag when truncation does not touch
    extents

 fs/btrfs/ctree.h            |  2 +-
 fs/btrfs/file-item.c        | 98 ++++++++++++++++++++++++++++---------
 fs/btrfs/free-space-cache.c |  2 +-
 fs/btrfs/inode.c            | 65 +++++++++++++++++-------
 fs/btrfs/tree-log.c         |  5 +-
 5 files changed, 128 insertions(+), 44 deletions(-)

Comments

Anand Jain May 24, 2021, 2:31 p.m. UTC | #1
On 24/5/21 6:35 pm, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> This patchset fixes a fsync failure (-EIO) and transaction abort during
> a workload for Microsoft's SQL Server running in a Docker container as
> reported at:
> 
> https://lore.kernel.org/linux-btrfs/93c4600e-5263-5cba-adf0-6f47526e7561@in.tum.de/
> 
> It also adds an optimization for the workload, by removing lots of fsyncs
> that trigger the slow code path and replacing them with ones that use the
> fast path, reducing the workload's runtime by about -12% on my test box.
> 
> Filipe Manana (3):
>    btrfs: fix fsync failure and transaction abort after writes to
>      prealloc extents
>    btrfs: fix misleading and incomplete comment of btrfs_truncate()
>    btrfs: don't set the full sync flag when truncation does not touch
>      extents
> 
>   fs/btrfs/ctree.h            |  2 +-
>   fs/btrfs/file-item.c        | 98 ++++++++++++++++++++++++++++---------
>   fs/btrfs/free-space-cache.c |  2 +-
>   fs/btrfs/inode.c            | 65 +++++++++++++++++-------
>   fs/btrfs/tree-log.c         |  5 +-
>   5 files changed, 128 insertions(+), 44 deletions(-)
> 


Patch 3/3 needs conflict fix on latest misc-next in ctree.h.

Tested-by: Anand Jain <anand.jain@oracle.com>

For the whole series.
Test arch=aarch64 pagesize=64k.

Thanks, Anand
David Sterba May 25, 2021, 3:02 p.m. UTC | #2
On Mon, May 24, 2021 at 11:35:52AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> This patchset fixes a fsync failure (-EIO) and transaction abort during
> a workload for Microsoft's SQL Server running in a Docker container as
> reported at:
> 
> https://lore.kernel.org/linux-btrfs/93c4600e-5263-5cba-adf0-6f47526e7561@in.tum.de/
> 
> It also adds an optimization for the workload, by removing lots of fsyncs
> that trigger the slow code path and replacing them with ones that use the
> fast path, reducing the workload's runtime by about -12% on my test box.
> 
> Filipe Manana (3):
>   btrfs: fix fsync failure and transaction abort after writes to
>     prealloc extents
>   btrfs: fix misleading and incomplete comment of btrfs_truncate()
>   btrfs: don't set the full sync flag when truncation does not touch
>     extents

Added to misc-next, thanks. I've marked the first patch for 5.4+. It
applies cleanly up to 4.4 but I'm not sure if this is safe given the
amount of other fixes that are mentioned in the patch and other fsync
related fixes that have been applied.
Filipe Manana May 25, 2021, 3:20 p.m. UTC | #3
On Tue, May 25, 2021 at 4:05 PM David Sterba <dsterba@suse.cz> wrote:
>
> On Mon, May 24, 2021 at 11:35:52AM +0100, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > This patchset fixes a fsync failure (-EIO) and transaction abort during
> > a workload for Microsoft's SQL Server running in a Docker container as
> > reported at:
> >
> > https://lore.kernel.org/linux-btrfs/93c4600e-5263-5cba-adf0-6f47526e7561@in.tum.de/
> >
> > It also adds an optimization for the workload, by removing lots of fsyncs
> > that trigger the slow code path and replacing them with ones that use the
> > fast path, reducing the workload's runtime by about -12% on my test box.
> >
> > Filipe Manana (3):
> >   btrfs: fix fsync failure and transaction abort after writes to
> >     prealloc extents
> >   btrfs: fix misleading and incomplete comment of btrfs_truncate()
> >   btrfs: don't set the full sync flag when truncation does not touch
> >     extents
>
> Added to misc-next, thanks. I've marked the first patch for 5.4+. It
> applies cleanly up to 4.4 but I'm not sure if this is safe given the
> amount of other fixes that are mentioned in the patch and other fsync
> related fixes that have been applied.

Should work on any 4.4+ kernel.
It's independent of the other mentioned fixes, as those were mostly
related to shared extents, except for one which was for the checksums
tree and unrelated to fsyncs.
I didn't add a Fixes tag because it's a really old thing, either
introduced when the fast fsync path was first added or when fallocate
was added, or somewhere in between.
The fsync failure and transaction abort only happen since the tree
checker was changed to detect overlapping checksum items (5.10, commit
ad1d8c439978ede77cbf73cbdd11bafe810421a5),
before that any issue would only happen at log replay time. 5.4+
sounds very reasonable to me. Thanks.