public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@redhat.com>
Cc: kjell.m.randa@gmail.com, xfs <linux-xfs@vger.kernel.org>,
	fstests <fstests@vger.kernel.org>
Subject: [PATCH] xfs: add a test for v1 inodes with nonzero nlink and onlink fields
Date: Wed, 21 Aug 2024 22:05:40 -0700	[thread overview]
Message-ID: <20240822050540.GP865349@frogsfrogsfrogs> (raw)
In-Reply-To: <20240812224009.GD6051@frogsfrogsfrogs>

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

Add a regression test for XFS V1 inodes that have both nlink and onlink
fields set to 1.

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

diff --git a/tests/xfs/1890 b/tests/xfs/1890
new file mode 100755
index 0000000000..c3813fca67
--- /dev/null
+++ b/tests/xfs/1890
@@ -0,0 +1,39 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2024 Oracle.  All Rights Reserved.
+#
+# FS QA Test No. 1890
+#
+# Regression test for V1 inodes that have di_onlink and di_nlink set to 1.
+#
+. ./common/preamble
+_begin_fstest auto
+
+_fixed_by_kernel_commit XXXXXXXXXXXX \
+	"xfs: fix di_onlink checking for V1/V2 inodes",
+
+_require_scratch_nocheck	# we'll do our own checking
+_require_xfs_nocrc
+
+_scratch_mkfs -m crc=0 >> $seqres.full
+_scratch_xfs_db -x \
+	-c 'sb' \
+	-c 'addr rbmino' \
+	-c 'print core.nlinkv2 core.onlink' \
+	-c 'write -d core.version 1' \
+	-c 'write -d core.nlinkv1 1' \
+	-c 'print core.version core.nlinkv1'
+
+# repair doesn't flag this combination
+_scratch_xfs_repair -n &>> $seqres.full || echo "xfs_repair -n failed??"
+
+# Prior to kernel commit 40cb8613d612 ("xfs: check unused nlink fields in the
+# ondisk inode"), the kernel accepted V1 format inode where both the new and
+# old nlink fields are set to 1.  With that commit applied, it stopped
+# accepting that combination and will refuse to mount.  Hence we need the fix
+# mentioned above.
+_scratch_mount
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/1890.out b/tests/xfs/1890.out
new file mode 100644
index 0000000000..166ae90286
--- /dev/null
+++ b/tests/xfs/1890.out
@@ -0,0 +1,7 @@
+QA output created by 1890
+core.nlinkv2 = 1
+core.onlink = 0
+core.version = 1
+core.nlinkv1 = 1
+core.version = 1
+core.nlinkv1 = 1

  parent reply	other threads:[~2024-08-22  5:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12 22:40 [PATCH] xfs: fix di_onlink checking for V1/V2 inodes Darrick J. Wong
2024-08-13  5:46 ` Christoph Hellwig
2024-08-22  5:04   ` Darrick J. Wong
2024-08-22  5:25     ` Chandan Babu R
2024-08-22  5:31       ` Christoph Hellwig
2024-08-22  5:40         ` Chandan Babu R
2024-08-22  5:05 ` Darrick J. Wong [this message]
2024-08-22  6:32   ` [PATCH] xfs: add a test for v1 inodes with nonzero nlink and onlink fields 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=20240822050540.GP865349@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=kjell.m.randa@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox