Skip to content

btrfs: fix logging unwritten extents after failure in write paths

[email protected] linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest6 patches 2 repliesIn review
  2. v32 patches 2 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6btrfs: ensure fast fsync waits for ordered extents after a write failurefs/btrfs/btrfs_inode.h fs/btrfs/file.c fs/btrfs/ordered-data.c+57 -01 reply
2/6btrfs: make btrfs_finish_ordered_extent() return voidfs/btrfs/ordered-data.c fs/btrfs/ordered-data.h+2 -30 replies
3/6btrfs: use a btrfs_inode in the log context (struct btrfs_log_ctx)fs/btrfs/file.c fs/btrfs/tree-log.c fs/btrfs/tree-log.h+9 -90 replies
4/6btrfs: pass a btrfs_inode to btrfs_fdatawrite_range()fs/btrfs/file.c fs/btrfs/file.h fs/btrfs/free-space-cache.c +1 more+12 -120 replies
5/6btrfs: pass a btrfs_inode to btrfs_wait_ordered_range()fs/btrfs/file.c fs/btrfs/free-space-cache.c fs/btrfs/inode.c +4 more+24 -240 replies
6/6btrfs: use a btrfs_inode local variable at btrfs_sync_file()fs/btrfs/file.c+20 -230 replies

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchQu Wenruo
SeriesR-b
1/6R-b
2/6R-b
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/6] btrfs: fix logging unwritten extents after failure in write paths

From: Filipe Manana <[email protected]>

There's a bug where a fast fsync can log extent maps that were not written due to an error in a write path or during writeback. This affects both direct IO writes and buffered writes, and besides the failure depends on a race due to the fact that ordered extent completion happens in a work queue and a fast fsync doesn't wait for ordered extent completion before logging. The details are in the change log of the first patch.

V4: Use a slightly different approach to avoid a deadlock on the inode's
spinlock due to it being used both in irq and non-irq context, pointed out by Qu.
Added some cleanup patches (patches 3, 4, 5 and 6).

V3: Change the approach of patch 1/2 to not drop extent maps at
btrfs_finish_ordered_extent() since that runs in irq context and dropping an extent map range triggers NOFS extent map allocations, which can trigger a reclaim and that can't run in irq context. Updated comments and changelog to distinguish differences between failures for direct IO writes and buffered writes.

V2: Rework solution since other error paths caused the same problem, make
it more generic.
Added more details to change log and comment about what's going on, and why reads aren't affected.

https://lore.kernel.org/linux-btrfs/[email protected]/

V1: https://lore.kernel.org/linux-btrfs/[email protected]/

Filipe Manana (6):
btrfs: ensure fast fsync waits for ordered extents after a write failure
btrfs: make btrfs_finish_ordered_extent() return void
btrfs: use a btrfs_inode in the log context (struct btrfs_log_ctx)
btrfs: pass a btrfs_inode to btrfs_fdatawrite_range()
btrfs: pass a btrfs_inode to btrfs_wait_ordered_range()
btrfs: use a btrfs_inode local variable at btrfs_sync_file()

 fs/btrfs/btrfs_inode.h      | 10 ++++++
 fs/btrfs/file.c             | 63 ++++++++++++++++++++++---------------
 fs/btrfs/file.h             |  2 +-
 fs/btrfs/free-space-cache.c |  4 +--
 fs/btrfs/inode.c            | 16 +++++-----
 fs/btrfs/ordered-data.c     | 40 ++++++++++++++++++++---
 fs/btrfs/ordered-data.h     |  4 +--
 fs/btrfs/reflink.c          |  8 ++---
 fs/btrfs/relocation.c       |  2 +-
 fs/btrfs/tree-log.c         | 10 +++---
 fs/btrfs/tree-log.h         |  4 +--
 11 files changed, 108 insertions(+), 55 deletions(-)
Signature · 1 line
2.43.0