All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, guaneryu@gmail.com, zlang@redhat.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 1/4] xfs: make sure syncfs(2) passes back super_operations.sync_fs errors
Date: Mon, 11 Apr 2022 15:54:37 -0700	[thread overview]
Message-ID: <164971767699.169983.772317637668809854.stgit@magnolia> (raw)
In-Reply-To: <164971767143.169983.12905331894414458027.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

This is a regression test to make sure that nonzero error returns from
a filesystem's ->sync_fs implementation are actually passed back to
userspace when the call stack involves syncfs(2).

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 tests/xfs/839     |   42 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/839.out |    2 ++
 2 files changed, 44 insertions(+)
 create mode 100755 tests/xfs/839
 create mode 100644 tests/xfs/839.out


diff --git a/tests/xfs/839 b/tests/xfs/839
new file mode 100755
index 00000000..9bfe93ef
--- /dev/null
+++ b/tests/xfs/839
@@ -0,0 +1,42 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2022 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 839
+#
+# Regression test for kernel commits:
+#
+# 5679897eb104 ("vfs: make sync_filesystem return errors from ->sync_fs")
+# 2d86293c7075 ("xfs: return errors in xfs_fs_sync_fs")
+#
+# During a code inspection, I noticed that sync_filesystem ignores the return
+# value of the ->sync_fs calls that it makes.  sync_filesystem, in turn is used
+# by the syncfs(2) syscall to persist filesystem changes to disk.  This means
+# that syncfs(2) does not capture internal filesystem errors that are neither
+# visible from the block device (e.g. media error) nor recorded in s_wb_err.
+# XFS historically returned 0 from ->sync_fs even if there were log failures,
+# so that had to be corrected as well.
+#
+# The kernel commits above fix this problem, so this test tries to trigger the
+# bug by using the shutdown ioctl on a clean, freshly mounted filesystem in the
+# hope that the EIO generated as a result of the filesystem being shut down is
+# only visible via ->sync_fs.
+#
+. ./common/preamble
+_begin_fstest auto quick shutdown
+
+# real QA test starts here
+
+# Modify as appropriate.
+_require_xfs_io_command syncfs
+_require_scratch_nocheck
+_require_scratch_shutdown
+
+# Reuse the fs formatted when we checked for the shutdown ioctl, and don't
+# bother checking the filesystem afterwards since we never wrote anything.
+_scratch_mount
+$XFS_IO_PROG -x -c 'shutdown -f ' -c syncfs $SCRATCH_MNT
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/839.out b/tests/xfs/839.out
new file mode 100644
index 00000000..f275cdcc
--- /dev/null
+++ b/tests/xfs/839.out
@@ -0,0 +1,2 @@
+QA output created by 839
+syncfs: Input/output error


  reply	other threads:[~2022-04-11 22:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 22:54 [PATCHSET 0/4] fstests: new tests for kernel 5.18 Darrick J. Wong
2022-04-11 22:54 ` Darrick J. Wong [this message]
2022-04-12  9:37   ` [PATCH 1/4] xfs: make sure syncfs(2) passes back super_operations.sync_fs errors Zorro Lang
2022-04-12 17:28     ` Darrick J. Wong
2022-04-14 14:43       ` Zorro Lang
2022-04-14 15:42         ` Darrick J. Wong
2022-04-14 18:58           ` Zorro Lang
2022-04-11 22:54 ` [PATCH 2/4] generic: ensure we drop suid after fallocate Darrick J. Wong
2022-04-12 11:52   ` Zorro Lang
2022-04-13  7:58     ` Amir Goldstein
2022-04-13 15:44       ` Zorro Lang
2022-04-14 15:50         ` Darrick J. Wong
2022-04-14 19:10           ` Zorro Lang
2022-04-15 13:42             ` Amir Goldstein
2022-04-16 14:01               ` Zorro Lang
2022-04-16 17:30                 ` Amir Goldstein
2022-04-17 15:40               ` Eryu Guan
2022-04-19 17:18                 ` Darrick J. Wong
2022-04-15  8:54           ` Amir Goldstein
2022-04-11 22:54 ` [PATCH 3/4] generic: test that linking into a directory fails with EDQUOT Darrick J. Wong
2022-04-12 17:17   ` Zorro Lang
2022-04-12 17:52     ` Darrick J. Wong
2022-04-14 19:12       ` Zorro Lang
2022-04-11 22:54 ` [PATCH 4/4] generic: test that renaming " Darrick J. Wong
2022-04-12 17:29   ` Zorro Lang
2022-04-12 17:58     ` Darrick J. Wong
2022-04-14 19:13       ` Zorro Lang

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=164971767699.169983.772317637668809854.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=guaneryu@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.