From: Amir Goldstein <amir73il@gmail.com>
To: Zorro Lang <zlang@redhat.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
Ruiwen Zhao <ruiwen@google.com>,
linux-unionfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH v2 2/2] overlay: add test for rename of lower symlink with NOATIME attr
Date: Thu, 21 Sep 2023 17:31:02 +0300 [thread overview]
Message-ID: <20230921143102.127526-3-amir73il@gmail.com> (raw)
In-Reply-To: <20230921143102.127526-1-amir73il@gmail.com>
Test for a regression in copy up of symlink that has the S_NOATIME
inode flag.
This is a regression from v5.15 reported by Ruiwen Zhao:
https://lore.kernel.org/linux-unionfs/CAKd=y5Hpg7J2gxrFT02F94o=FM9QvGp=kcH1Grctx8HzFYvpiA@mail.gmail.com/
In the bug report, the symlink has the S_NOATIME inode flag because it is
on an NFS/FUSE filesystem that sets S_NOATIME for all inodes.
The reproducer uses another technique to create a symlink with
S_NOATIME inode flag by using chattr +A inheritance on filesystems
that inherit chattr flags to symlinks.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
tests/overlay/082 | 66 +++++++++++++++++++++++++++++++++++++++++++
tests/overlay/082.out | 2 ++
2 files changed, 68 insertions(+)
create mode 100755 tests/overlay/082
create mode 100644 tests/overlay/082.out
diff --git a/tests/overlay/082 b/tests/overlay/082
new file mode 100755
index 00000000..97ef445e
--- /dev/null
+++ b/tests/overlay/082
@@ -0,0 +1,66 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2023 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 082
+#
+# Test for a regression in copy up of symlink that has the noatime inode
+# attribute.
+#
+# kernel commit 72db82115d2b ("ovl: copy up sync/noatime fileattr flags")
+# from v5.15 introduced the regression.
+#
+. ./common/preamble
+_begin_fstest auto quick copyup symlink atime
+
+# real QA test starts here
+_supported_fs overlay
+_fixed_by_kernel_commit ab048302026d \
+ "ovl: fix failed copyup of fileattr on a symlink"
+
+_require_scratch
+_require_chattr_inherit A
+
+# remove all files from previous runs
+_scratch_mkfs
+
+# prepare lower test dir with NOATIME flag
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+mkdir -p $lowerdir/testdir
+$CHATTR_PROG +A $lowerdir/testdir >> $seqres.full 2>&1 ||
+ echo "failed to set No_Atime flag on $lowerdir/testdir"
+
+# The NOATIME is inherited to children symlink in ext4/fs2fs
+# (and on tmpfs on recent kernels).
+# The overlayfs test will not fail unless base fs is
+# one of those filesystems.
+#
+# The problem with this inheritence is that the NOATIME flag is inherited
+# to a symlink and the flag does take effect, but there is no way to query
+# the flag (lsattr) or change it (chattr) on a symlink, so overlayfs will
+# fail when trying to copy up NOATIME flag from lower to upper symlink.
+#
+touch $lowerdir/testdir/foo
+ln -sf foo $lowerdir/testdir/lnk
+$LSATTR_PROG -l $lowerdir/testdir/foo >> $seqres.full
+
+before=$(stat -c %x $lowerdir/testdir/lnk)
+echo "symlink atime before readlink: $before" >> $seqres.full 2>&1
+cat $lowerdir/testdir/lnk
+after=$(stat -c %x $lowerdir/testdir/lnk)
+echo "symlink atime after readlink: $after" >> $seqres.full 2>&1
+
+[ "$before" == "$after" ] || \
+ _notrun "base fs $OVL_BASE_FSTYP does not inherit No_Atime flag on symlink"
+
+# mounting overlay
+_scratch_mount
+
+# moving symlink will try to copy up lower symlink flags
+# and fails with error ENXIO, if the bug is reproduced
+mv $SCRATCH_MNT/testdir/lnk $SCRATCH_MNT/
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/overlay/082.out b/tests/overlay/082.out
new file mode 100644
index 00000000..2977f141
--- /dev/null
+++ b/tests/overlay/082.out
@@ -0,0 +1,2 @@
+QA output created by 082
+Silence is golden
--
2.34.1
prev parent reply other threads:[~2023-09-21 17:23 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 14:31 [PATCH v2 0/2] Test for overlayfs fix in v6.6-rc2 Amir Goldstein
2023-09-21 14:31 ` [PATCH v2 1/2] common: add helper _require_chattr_inherit Amir Goldstein
2023-09-21 15:26 ` Zorro Lang
2023-09-21 15:40 ` Amir Goldstein
2023-09-21 16:23 ` Zorro Lang
2023-09-21 16:46 ` Amir Goldstein
2023-09-21 17:06 ` Zorro Lang
2023-09-21 17:12 ` Amir Goldstein
2023-09-21 14:31 ` Amir Goldstein [this message]
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=20230921143102.127526-3-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=ruiwen@google.com \
--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;
as well as URLs for NNTP newsgroup(s).