From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/6] xfs: don't continue on error in xfs_fsync
Date: Wed, 2 Sep 2026 09:07:19 -0700 [thread overview]
Message-ID: <20260902160719.GP1933798@frogsfrogsfrogs> (raw)
In-Reply-To: <20260902054942.111988-3-hch@lst.de>
On Wed, Sep 02, 2026 at 08:49:16AM +0300, Christoph Hellwig wrote:
> As soon as we get an error from cache flushing or log forcing, there
> is no point in continuing as the data integrity is already impacted.
> Return the error instead of continuing to do more work.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/xfs_file.c | 19 +++++++++----------
> 1 file changed, 9 insertions(+), 10 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index 426a67b813a7..0d31fea67a2c 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -130,8 +130,8 @@ xfs_file_fsync(
> {
> struct xfs_inode *ip = XFS_I(file->f_mapping->host);
> struct xfs_mount *mp = ip->i_mount;
> - int error, err2;
> int log_flushed = 0;
> + int error;
>
> trace_xfs_file_fsync(ip);
>
> @@ -154,15 +154,17 @@ xfs_file_fsync(
> error = blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
> else if (mp->m_logdev_targp != mp->m_ddev_targp)
> error = blkdev_issue_flush(mp->m_ddev_targp->bt_bdev);
> + if (error)
> + return error;
Hmm so at this point dirty writeback was pushed out and failed, so now
already we've lost data. No point in continuing, agreed...
>
> /*
> * If the inode has a inode log item attached, it may need the journal
> * flushed to persist any changes the log item might be tracking.
> */
> if (ip->i_itemp) {
> - err2 = xfs_fsync_flush_log(ip, datasync, &log_flushed);
> - if (err2 && !error)
> - error = err2;
> + error = xfs_fsync_flush_log(ip, datasync, &log_flushed);
> + if (error)
> + return error;
...so at this point we failed to push the log to disk and possibly
lost file metadata. Agreed that we might as well give up...
> }
>
> /*
> @@ -178,14 +180,11 @@ xfs_file_fsync(
> if (!log_flushed) {
> struct xfs_buftarg *file_targp = xfs_inode_buftarg(ip);
>
> - if (mp->m_logdev_targp == file_targp) {
> - err2 = blkdev_issue_flush(file_targp->bt_bdev);
> - if (err2 && !error)
> - error = err2;
> - }
> + if (mp->m_logdev_targp == file_targp)
> + return blkdev_issue_flush(file_targp->bt_bdev);
...and same here if the bdev flush fails.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> }
>
> - return error;
> + return 0;
> }
>
> static int
> --
> 2.53.0
>
>
next prev parent reply other threads:[~2026-09-02 16:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 5:49 fix and then optimize cache flushes for the RT device Christoph Hellwig
2026-09-02 5:49 ` [PATCH 1/6] xfs: also flush the RT device cache in xlog_write_iclog Christoph Hellwig
2026-09-02 16:01 ` Darrick J. Wong
2026-09-02 5:49 ` [PATCH 2/6] xfs: don't continue on error in xfs_fsync Christoph Hellwig
2026-09-02 16:07 ` Darrick J. Wong [this message]
2026-09-02 5:49 ` [PATCH 3/6] xfs: clean up xfs_fsync_flush_log a bit Christoph Hellwig
2026-09-02 16:07 ` Darrick J. Wong
2026-09-02 5:49 ` [PATCH 4/6] xfs: avoid extra cache flushes for multi-device file systems in xfs_fsync Christoph Hellwig
2026-09-02 16:12 ` Darrick J. Wong
2026-09-02 5:49 ` [PATCH 5/6] xfs: optimize cache flushing for CIL commits on multi-device file systems Christoph Hellwig
2026-09-02 16:15 ` Darrick J. Wong
2026-09-02 5:49 ` [PATCH 6/6] xfs: flush multiple device caches in parallel in xlog_write_iclog Christoph Hellwig
2026-09-02 16:18 ` Darrick J. Wong
2026-09-03 5:44 ` 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=20260902160719.GP1933798@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--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