Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Leo Martins <loemra.dev@gmail.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Cc: David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
	Filipe Manana <fdmanana@suse.com>,
	Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH v2 0/2] btrfs: don't lose fsynced data to a transaction abort
Date: Thu,  3 Dec 2026 15:56:44 -0800	[thread overview]
Message-ID: <cover.1796341585.git.loemra.dev@gmail.com> (raw)

Fast fsync can sync a file extent item and its checksums to the tree
log while the ordered extent is still waiting to update the subvolume
tree. If the transaction aborts in between, replay can restore a file
mapping whose blocks were overwritten after fsync returned.

If an ordered extent that fast fsync logged fails to complete, patch 1
preserves the log for replay, and for a COW write keeps the new blocks
out of the free space cache. Patch 2 refuses NOCOW writes after a
filesystem error, so they can't overwrite logged data in place. That
covers a preallocated range the failed ordered extent left unwritten,
and an extent shared by a reflink that the cross-ref check can no longer
see after an abort.

The series is based on for-next, which has Josef's "btrfs: data
integrity fixes" v3 [1]. Patch 1 describes the fast fsync prerequisites.

Changes in v2:
- Also handle failed writes into prealloc extents (Sashiko, via
  Filipe) and NOCOW writes in patch 1.
- Check IOERR before marking an extent logged if ordered extent
  completion races fsync.
- New patch 2.
- Fix the discard comment (Filipe).

v1: https://lore.kernel.org/linux-btrfs/54da67463c57f41302f8456a8a7a1190dcb65ae2.1794266796.git.loemra.dev@gmail.com/

[1] https://lore.kernel.org/linux-btrfs/20261120-b4-btrfs-data-integrity-v3-0-4de4b91b826e@toxicpanda.com/

Leo Martins (2):
  btrfs: fix loss of fsynced data when ordered extent completion fails
  btrfs: refuse NOCOW writes after a filesystem error

 fs/btrfs/inode.c    | 100 +++++++++++++++++++++++++++++++++++++-------
 fs/btrfs/tree-log.c |  26 ++++++++----
 2 files changed, 104 insertions(+), 22 deletions(-)


base-commit: 418f7723b545cf064fc584529710b28d1347188e
-- 
2.53.1-Meta


             reply	other threads:[~2026-12-03 23:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 23:56 Leo Martins [this message]
2026-12-03 23:56 ` [PATCH v2 1/2] btrfs: fix loss of fsynced data when ordered extent completion fails Leo Martins
2026-12-04 11:50   ` Filipe Manana
2026-12-03 23:56 ` [PATCH v2 2/2] btrfs: refuse NOCOW writes after a filesystem error Leo Martins
2026-12-04 11:51   ` Filipe Manana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1796341585.git.loemra.dev@gmail.com \
    --to=loemra.dev@gmail.com \
    --cc=dsterba@suse.com \
    --cc=fdmanana@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mason@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox