Linux XFS filesystem development
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Chris Wedgwood <cw@f00f.org>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/9] libxfs: record a failed buffer write when it fails
Date: Mon, 31 Aug 2026 06:39:21 -0700	[thread overview]
Message-ID: <apWECUHmTpoyt9PK@infradead.org> (raw)
In-Reply-To: <19b14aff5aa38738f92c7fef2babefb7f773655b.1788110147.git.cw@f00f.org>

On Thu, Aug 20, 2026 at 10:42:15PM -0700, Chris Wedgwood wrote:
> libxfs_flush_mount() decides whether metadata reached the disk by
> looking at XFS_BUFTARG_LOST_WRITE and XFS_BUFTARG_CORRUPT_WRITE, and its
> comment says a buffer that cannot be written sets them.  It does not.
> The flags are only set from libxfs_buf_prepare_mru(), that is, when a
> still-dirty buffer is later released to the free list.  A write that
> fails during a cache flush leaves the buffer dirty and errored in the
> cache, and cache_flush() discards what libxfs_bflush() returns, so
> nothing records the failure and libxfs_flush_mount() returns success.
> 
> No existing caller can tell: mkfs.xfs and xfs_repair both detect a
> failing write through their own error paths first, so today this is a
> latent contract violation rather than a visible bug.
> 
> It stops being latent with log replay.  Replay flushes the metadata it
> has applied and then retires the log, and the flush result is what says
> the retirement is safe.  Believing a flush that did not happen destroys
> the only remaining copy of that metadata.
> 
> Set the flags where the failure is detected.  Both failure exits, the
> I/O error and the write verifier, go through one helper so the promise
> holds however the write failed.  The stale-buffer exit is left alone: it
> reports a caller bug rather than lost data, and has always done so.
> 
> Measured with an LD_PRELOAD shim that fails pwrite() after a chosen
> number of calls, replaying a log whose recovery needs 558 writes.
> Failing from write 181, which lands in the flush after replay:

Can you wrire this up in xfstests?  Maybe using an environment
variable instead of LD_PRELOAD like some of the other error injection
we do in userspace if that is easier to maintain.

  reply	other threads:[~2026-08-31 13:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-30 17:15 [PATCH 0/9] xfsprogs: add xfs_repair -R --- log replay Chris Wedgwood
2026-08-21  0:22 ` [PATCH 1/9] libxfs: make XBF_DONE actually mark a buffer uptodate Chris Wedgwood
2026-08-31 13:37   ` Christoph Hellwig
2026-08-21  0:26 ` [PATCH 2/9] libxfs: don't corrupt a delwri list when a buffer is queued twice Chris Wedgwood
2026-08-31 13:38   ` Christoph Hellwig
2026-08-21  5:42 ` [PATCH 3/9] libxfs: record a failed buffer write when it fails Chris Wedgwood
2026-08-31 13:39   ` Christoph Hellwig [this message]
2026-08-27  5:08 ` [PATCH 6/9] libxfs-diff: also compare libxlog against the kernel Chris Wedgwood
2026-08-31 13:40   ` Christoph Hellwig
2026-08-31 17:37     ` Darrick J. Wong
2026-09-02 23:25       ` Dave Chinner
2026-08-27  5:08 ` [PATCH 4/9] libxlog: rename xfs_log_recover.c to logscan.c Chris Wedgwood
2026-08-31 13:42   ` Christoph Hellwig
2026-08-27  5:09 ` [PATCH 5/9] libxlog: import the kernel's log recovery, log items and AIL Chris Wedgwood
2026-08-31 13:45   ` Christoph Hellwig
2026-09-02 23:48   ` Dave Chinner
2026-08-27  5:24 ` [PATCH 7/9] libxlog: build the imported kernel code Chris Wedgwood
2026-08-31 13:46   ` Christoph Hellwig
2026-08-27  5:25 ` [PATCH 8/9] xfs_repair: add -R to replay a dirty log before repairing Chris Wedgwood
2026-08-31 13:48   ` Christoph Hellwig
2026-09-02 23:57   ` Dave Chinner
2026-08-27  5:48 ` [PATCH 9/9] xfs_repair: finish deletions the crash interrupted Chris Wedgwood
2026-08-31 13:50   ` Christoph Hellwig
2026-08-31 13:36 ` [PATCH 0/9] xfsprogs: add xfs_repair -R --- log replay Christoph Hellwig

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=apWECUHmTpoyt9PK@infradead.org \
    --to=hch@infradead.org \
    --cc=cw@f00f.org \
    --cc=linux-xfs@vger.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