From patchwork Mon Oct 30 12:06:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10032369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C9F16039A for ; Mon, 30 Oct 2017 12:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C7532882D for ; Mon, 30 Oct 2017 12:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FC0328845; Mon, 30 Oct 2017 12:07:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDBFF2882D for ; Mon, 30 Oct 2017 12:07:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753028AbdJ3MHg (ORCPT ); Mon, 30 Oct 2017 08:07:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:54983 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753024AbdJ3MHf (ORCPT ); Mon, 30 Oct 2017 08:07:35 -0400 Received: by mail-wm0-f68.google.com with SMTP id r68so15970374wmr.3; Mon, 30 Oct 2017 05:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PGYG2q9uwGW+eKAWicj6uDGgVIKLG9UVOPROBI+YUe0=; b=EQs7/kIgzFE2wO4249e8hyVB7pnwE4xX9GmgUlpwv2jioqpqowsm+VMY1fFW8mhwqQ /lO+hxJ7F72fxLn8myl8ZccVWNvBBfb4NZd3WQMCwa/ZoL9tNORVyAwYv2wLi46nvy+K WXXL+xFZN9KV7O8cp5kub9jOMKcvDjjarhSbOVNKzKcHkxEyDzq4Ixfv5vBmHfs3PaMz uCnx7en0wgBrRD1DDTIzth3CC4A8ijnZr6s6hvNk8RiC9+gcBSHO2+k2zB+nYYuodvpc p9olj88mkHZOgtXMhwvasSnGritbseqQbqWfpIqVnLOi6DYEKkwhDj5aJ54P0Fqxii4x mWmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PGYG2q9uwGW+eKAWicj6uDGgVIKLG9UVOPROBI+YUe0=; b=m42cDuf8NNr/hNS8YXWGbEMCh9I9o/Ee/NyLdIw35Ik8He1sdZEEubK/s0Em6Y4qSt T/BreOrdDOZtSgHam3wtx81/mXwlyl7rUb/60Rf+LsPpGAmdk5Rxbu5kDfdWx/EdMI6M 8uTKzr3EH46P/dGjcysEQf+rc73m3FY0WutPZHuzFqjvRvIBqDzOYCpslPDrYPxRlhLY J4rMwyGuOLq5zkmQB21CFZhAwnC40NYy0l8KUL6De9IRPR0WP+bd9BSz5Itms72by/Ql PGNnhPtCqenMvYRqgPBA1lsSuVGtc063p1yVvXgyEvQSjoPP76zKzts8vxZJdGEOuOAF m+7g== X-Gm-Message-State: AMCzsaUd+jip5iW5nogDpcZHVv22xhLFAMiGfV+n7Uy+AAE9XYZ2MBma md32ot2Vr/aX0ParnGnGn/0= X-Google-Smtp-Source: ABhQp+Sonlg+TIHOP4ljpO1NITbCyACK7Vv3TlzsDslhBGPL+ND2bcc1ycHOq51Ccp4O7QpTGDqcFQ== X-Received: by 10.80.164.24 with SMTP id u24mr11104994edb.11.1509365253884; Mon, 30 Oct 2017 05:07:33 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id v32sm10424043edm.76.2017.10.30.05.07.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Oct 2017 05:07:33 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] overlay: test creating lower hardlinks for copied up files Date: Mon, 30 Oct 2017 14:06:56 +0200 Message-Id: <1509365216-10796-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP kernel v4.13 introduced the index=on feature for not breaking hardlinks on copy-up. With the index feature enabled a regression was introduced - lower files that are hardlined while overlay is offline can result in lookup error after overlay in mounted. The regression was fixed by upstream commit 6eaf011144af ovl: fix EIO from lookup of non-indexed upper that was merged to v4.14-rc7. This test verifies that behavior is sane after creating lower hardlinks for copied up files while overlayfs is offline. Signed-off-by: Amir Goldstein --- Eryu, This is a regression test for a fix that was just merged to v4.14-rc7. The test requires and enables index=on, so it would fail on kernels prior to v4.14-rc7 regardless if they are complied with CONFIG_OVERLAY_FS_INDEX=y or not. Amir. tests/overlay/042 | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/042.out | 2 + tests/overlay/group | 1 + 3 files changed, 140 insertions(+) create mode 100755 tests/overlay/042 create mode 100644 tests/overlay/042.out diff --git a/tests/overlay/042 b/tests/overlay/042 new file mode 100755 index 0000000..29858d6 --- /dev/null +++ b/tests/overlay/042 @@ -0,0 +1,137 @@ +#! /bin/bash +# FS QA Test 042 +# +# Test creating lower hardlinks for copied up files. +# +# kernel v4.13 introduced the index=on feature for not breaking +# hardlinks on copy-up. With the index feature enabled a regression was +# introduced - lower files that are hardlined while overlay is offline +# can result in lookup error after overlay in mounted. +# The regression was fixed by upstream commit +# 6eaf011144af ovl: fix EIO from lookup of non-indexed upper +# that was merged to v4.14-rc7. +# +# This test verifies that behavior is sane after creating lower hardlinks +# for copied up files while overlayfs is offline. +# +#----------------------------------------------------------------------- +# Copyright (C) 2017 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch +# Without overlay index feature hardlinks are broken on copy up +_require_scratch_feature index + +# Remove all files from previous tests +_scratch_mkfs + +# Create lower file +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +mkdir -p $lowerdir +touch $lowerdir/0 + +# Disable overlay index feature to copy up with no index +_scratch_mount -o index=off + +# Copy up lower and create upper hardlink with no index +ln $SCRATCH_MNT/0 $SCRATCH_MNT/1 + +$UMOUNT_PROG $SCRATCH_MNT + +# Add lower hardlinks while overlay is offline +ln $lowerdir/0 $lowerdir/2 +ln $lowerdir/0 $lowerdir/3 + +# Enable overlay index feature to lookup copied up upper aliases +_scratch_mount -o index=on + +# Stat upper hardlink that were created with no index and whose copy up +# origin is now an hardlink - expect same st_ino +ino0=$(stat -c '%i' $SCRATCH_MNT/0) +ino1=$(stat -c '%i' $SCRATCH_MNT/1) +[[ $ino0 == $ino1 ]] || \ + echo "Mismatch inode number for non-indexed upper hardlinks" + +# Copy up lower and create new upper hardlink with index, because +# lower is a hardlink and index is enabled. The new hardlinks are not +# associated with the hardlinks that were created when lower was not +# a hardlink. +ln $SCRATCH_MNT/2 $SCRATCH_MNT/4 + +# Mount cycle to reset inode/dentry cache +_scratch_cycle_mount index=on + +# Stat files that were copied up with index and whose copy up origin +# is now an hardlink - expect same st_ino as lower aliases and different +# st_ino from non-indexed upper aliases. +ino0=$(stat -c '%i' $SCRATCH_MNT/0) +ino1=$(stat -c '%i' $SCRATCH_MNT/1) +ino2=$(stat -c '%i' $SCRATCH_MNT/2) +ino3=$(stat -c '%i' $SCRATCH_MNT/3) +ino4=$(stat -c '%i' $SCRATCH_MNT/4) +[[ $ino0 == $ino1 ]] || \ + echo "Mismatch inode number for non-indexed upper hardlinks" +[[ $ino2 == $ino4 ]] || \ + echo "Mismatch inode number for indexed upper hardlinks" +[[ $ino2 == $ino3 ]] || \ + echo "Mismatch inode number for indexed upper and lower hardlinks" +[[ $ino2 != $ino0 ]] || \ + echo "Unexpected matching inode number for indexed and non-indexed upper hardlinks" + +# Mount cycle to reset inode/dentry cache +_scratch_cycle_mount index=on + +# Unlink all hardlinks - if overlay inode nlink is 0, this will trigger +# WARN_ON() in drop_nlink() +rm $SCRATCH_MNT/0 +rm $SCRATCH_MNT/1 +rm $SCRATCH_MNT/2 +rm $SCRATCH_MNT/3 +rm $SCRATCH_MNT/4 + +# Verify that orphan index is cleaned on mount +_scratch_cycle_mount index=on +ls $OVL_BASE_SCRATCH_MNT/$OVL_WORK/index + +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/042.out b/tests/overlay/042.out new file mode 100644 index 0000000..85eac7a --- /dev/null +++ b/tests/overlay/042.out @@ -0,0 +1,2 @@ +QA output created by 042 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 8629325..782c39f 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -44,3 +44,4 @@ 039 auto quick atime 040 auto quick 041 auto quick copyup nonsamefs +042 auto quick copyup hardlink