From patchwork Thu Sep 21 14:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13394354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE924E7D0A4 for ; Thu, 21 Sep 2023 19:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231157AbjIUTBq (ORCPT ); Thu, 21 Sep 2023 15:01:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230391AbjIUTBT (ORCPT ); Thu, 21 Sep 2023 15:01:19 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C66A88AC6; Thu, 21 Sep 2023 10:39:16 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-523100882f2so1471344a12.2; Thu, 21 Sep 2023 10:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695317954; x=1695922754; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=D5iXvHpoNdFLaDpVKrTwt1qO8piu2NWVNt1TPpkdWGE=; b=Mfz2G237KQX1VDC6TVsZsS5Yz9GJ2WA+w4tsdZ1c2jpX4VeAIgnlgTHMo0hkLuwA5R cAqKTgNE9r456hyIEwy9ZnuOtVOHWgR1p+og4uVvhvUzfXGDAhMRKNsgbvEOvAf/GtK+ cFXTGdJV/Hmbc1q5UHI2DUb0m2QietdFJLbW1TRDQqVxaAemtQZGIvuhw8h2lA317OTR Hq33vFsmmbPENvlFt51cBMdec5u7jsWscJMfUjeJu30da2CSRkBiflr/jO60UlyUItFl 1aT2iYy/lOisLI3vFfFmUT3i08ZK7Hak0A5qcUZESNheSga+NPGCRqkgdGBmHztJONvO hCEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695317954; x=1695922754; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D5iXvHpoNdFLaDpVKrTwt1qO8piu2NWVNt1TPpkdWGE=; b=pyXhuiXuaGlBUv8fXPxmThlZBSiNM/pQBhZBvBlBCH707/J9tq7QJu36SVKggGm8sY EqpJ6jI4OZ8lMSwCnXPwaYoiJt9INbDayXvOZH/Yu4jB0zK/s55dp8iDnPeGSgOecMJ8 ShfY1U13d417y98wSsS1/tUQf24jXMfiWyxEQM3awKzwQYGvngu1EyZ4f06+judcdai6 miJLKDsYzYCnXAeYvOne2bvs9k+qr7d1PiBXGgFazl2zaW+1l4FtLN/iUhXPTv4OQAAj j9/xG49p1Yl+sSRMfeAq6ZIMd+j6GiGt0oWfSl5IUwT9KLeyZQ/c8hP1gWHTtGh9fK1b lZpA== X-Gm-Message-State: AOJu0Yy/xiDKiIDDORlXuprRxLfL93kK6GqutMbAIQZgRN5k3TVrSVX8 do2Yac8wExvtOKkVCQXhrE8dOZlwHh0= X-Google-Smtp-Source: AGHT+IFscQSijhqoaczFLa9ImDHpCdMV5THADMXs1J3lDyiybvsmRGBT5FwcgkasJ559b+DDJ/SmzA== X-Received: by 2002:a05:600c:3782:b0:402:f55e:ac11 with SMTP id o2-20020a05600c378200b00402f55eac11mr5121997wmr.20.1695306667924; Thu, 21 Sep 2023 07:31:07 -0700 (PDT) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id y2-20020a7bcd82000000b00403bbe69629sm2099334wmj.31.2023.09.21.07.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 07:31:07 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: Miklos Szeredi , Ruiwen Zhao , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2 1/2] common: add helper _require_chattr_inherit Date: Thu, 21 Sep 2023 17:31:01 +0300 Message-Id: <20230921143102.127526-2-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921143102.127526-1-amir73il@gmail.com> References: <20230921143102.127526-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org Similar to _require_chattr, but also checks if an attribute is inheritted from parent dir to children. Signed-off-by: Amir Goldstein --- common/rc | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/common/rc b/common/rc index 1618ded5..00cfd434 100644 --- a/common/rc +++ b/common/rc @@ -4235,23 +4235,57 @@ _require_test_lsattr() _notrun "lsattr not supported by test filesystem type: $FSTYP" } +_check_chattr_inherit() +{ + local attribute=$1 + local path=$2 + local inherit=$3 + + touch $path + $CHATTR_PROG "+$attribute" $path > $tmp.chattr 2>&1 + local ret=$? + if [ -n "$inherit" ]; then + touch "$path/$inherit" + fi + $CHATTR_PROG "-$attribute" $path > $tmp.chattr 2>&1 + if [ "$ret" -ne 0 ]; then + _notrun "file system doesn't support chattr +$attribute" + fi + cat $tmp.chattr >> $seqres.full + rm -f $tmp.chattr + return $ret +} + _require_chattr() { if [ -z "$1" ]; then echo "Usage: _require_chattr " exit 1 fi - local attribute=$1 + _check_chattr_inherit $1 $TEST_DIR/syscalltest +} - touch $TEST_DIR/syscalltest - chattr "+$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1 - local ret=$? - chattr "-$attribute" $TEST_DIR/syscalltest > $TEST_DIR/syscalltest.out 2>&1 - if [ "$ret" -ne 0 ]; then - _notrun "file system doesn't support chattr +$attribute" +_require_chattr_inherit() +{ + if [ -z "$1" ]; then + echo "Usage: _require_chattr_inherit " + exit 1 fi - cat $TEST_DIR/syscalltest.out >> $seqres.full - rm -f $TEST_DIR/syscalltest.out + local attribute=$1 + local testdir="$TEST_DIR/chattrtest" + mkdir -p $testdir + _check_chattr_inherit $attribute $testdir testfile || \ + return + + local testfile="$TEST_DIR/chattrtest/testfile" + local lsattrout=($($LSATTR_PROG $testfile 2>> $seqres.full)) + echo ${lsattrout[*]} >> $seqres.full + echo ${lsattrout[0]} | grep -q $attribute || \ + _notrun "file system doesn't inherit chattr +$attribute" + + $CHATTR_PROG "-$attribute" $testfile >> $seqres.full 2>&1 + rm -f $testfile + rmdir $testdir } _get_total_inode() From patchwork Thu Sep 21 14:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 13394152 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34A88E7D0A2 for ; Thu, 21 Sep 2023 17:23:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229473AbjIURYB (ORCPT ); Thu, 21 Sep 2023 13:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbjIURXm (ORCPT ); Thu, 21 Sep 2023 13:23:42 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E103B444DC; Thu, 21 Sep 2023 10:13:36 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c00c0f11b2so19101951fa.1; Thu, 21 Sep 2023 10:13:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695316415; x=1695921215; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GKT1xX/9LF4huDE0b1Wt9eblC8UcJ/pJ2jSIojgaJLo=; b=fIKdivjCx8oID7T526jApoeRvOdkj6FS9oMNu6GgsW2BGZ6Sk+q7oslzLUObfYzzD4 x9/dBpsl6fuV+3Jcc+gTlKsxoUw6ghU1RfZWPlTj5yLXXTGxIS3EeEQ1mwUvnJkFivVP hayaFXg+K2dzEWc2wg12M9hPxeuTPIMSed5nrFPNwaBj0xoqz/P+jKkCQy+F2ccRGIuv khghqiBgSZcYHfm7HB8eRfVc0kjkfI+yU9yrRA+ptr+enzK+pXyJBF7xx6qIcT6WJ7m1 QZHjrRM+Pj0P+bxrOx7yj7Y8xufi8KxBdJxa+BcB25zXxAsAdqFCJeMGqksd762s6JxP GMDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695316415; x=1695921215; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GKT1xX/9LF4huDE0b1Wt9eblC8UcJ/pJ2jSIojgaJLo=; b=q5SQW5UIBtUhcz9QuvdzsG5dWIEtloegmjbUo+uEtnj6llLc4xgWJIOtcdmUI0/grT glJ1MtAvPAbU20oASdz34NmnZIwHHZYngUPZW4ouS1MBc1B//OFCd31ACX9tQaeWACUU vrMXMdxIe2ofklaCOkLJTuyxKEfC1V448adXYaos/l76/7qnKYrF9Dj9ryIPGS+A6Vbd 1+KBpziBTsrWvUUldpdUkz11lz5arwkwyMrn0xv3LofVnvU/Sc5ShD0grU5p5CpzJEib 0Xygg/eN2QFVnT01KGoJXcVfGSRQgVJVuDfubFFEmkGKIp3QkC81qEJX2s162+DngRMU kz6Q== X-Gm-Message-State: AOJu0YxhfvkVpN1CH7buaPQpZo0MD8FgQI2RgQUR0zp9ofJCCSFcEF7F SfztHjI1gte/yEsNZMZxMPFJf9pE33Q= X-Google-Smtp-Source: AGHT+IFhYxvMbp7ER2Xfi0Rd4cqRcTLN3tXvf+Bb5iMo0jweZDdHh1BEmgTvohZ1YLltIbfB+kQjUA== X-Received: by 2002:a1c:4b0e:0:b0:404:737a:17d with SMTP id y14-20020a1c4b0e000000b00404737a017dmr5479774wma.9.1695306669212; Thu, 21 Sep 2023 07:31:09 -0700 (PDT) Received: from amir-ThinkPad-T480.lan ([5.29.249.86]) by smtp.gmail.com with ESMTPSA id y2-20020a7bcd82000000b00403bbe69629sm2099334wmj.31.2023.09.21.07.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 07:31:08 -0700 (PDT) From: Amir Goldstein To: Zorro Lang Cc: Miklos Szeredi , Ruiwen Zhao , 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 Message-Id: <20230921143102.127526-3-amir73il@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230921143102.127526-1-amir73il@gmail.com> References: <20230921143102.127526-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org 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 --- 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