From patchwork Sun Jan 28 09:07:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10187739 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 49E7C60383 for ; Sun, 28 Jan 2018 09:06:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39BE3287EF for ; Sun, 28 Jan 2018 09:06:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C1BA28814; Sun, 28 Jan 2018 09:06:41 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 8DCFA287EF for ; Sun, 28 Jan 2018 09:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751169AbeA1JGj (ORCPT ); Sun, 28 Jan 2018 04:06:39 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:44760 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750808AbeA1JGc (ORCPT ); Sun, 28 Jan 2018 04:06:32 -0500 Received: by mail-wr0-f193.google.com with SMTP id v31so4002749wrc.11; Sun, 28 Jan 2018 01:06:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hDygJWXij77wgHNUzrGHzGhjqiyT7JjjTZrt2wgr9uQ=; b=bKj1tz0ygIZmBKIRgDTfsjE1CuMwEEPTx0yIpKXeuphTWM4adIuQI+cfFafwzgI+q1 Pb+/PugVKYwCczyMclFtLZttUyHGLCiU1V6FlQxkzzWLfBvGYFW4czN0SM7h4tovS/mo S3NzV2qTH8SUyD1sdLlI5LM4Z1UtUd880JKLqkyiiaRbyzeE16/dIZfSttmA2/EvrwFV zV+iDvdMu0P+E9P1/SO0tKY3oD9OauJYyJl7FFB+ja+IOyZpLSfqgz75b1/k9UGcdjGq KpzKkXpPdsq9qPlkKxsXHyU+2os1g98ZD4d3weRNCDd65H9UaslKZew2db0zzUpoBjL9 s72w== 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=hDygJWXij77wgHNUzrGHzGhjqiyT7JjjTZrt2wgr9uQ=; b=unAfGzD8janijzXHjcb6+VaTf4DU/8X11UdMqd/Pkfdg6jiw0ahVgh+PiXyt1AuI7C GGAkMnMc812YczFXPinxfBaKnkT8vn8mjKeypTs8ENhWEjKv1ctwUkHAqT3/jMiLcuQC zQ7itat4ZHBgT5ZNEf92JBjBFXX6PV4bBVj71CuTMHDj6etksaMVTd03MA1G89qwRuST NzD3o97D7vvcDlDB8nonQKKbuePzjofeWlDiXR7AAqX0iBy9lAn8insqeBK0qKMwYBp9 h2yE9ZwpNU30lFNiHYoX8R0yk1C9q8jdrm1mCxOhcnLFgeJiLdusWcc/F47SD7k7IlrL cbug== X-Gm-Message-State: AKwxyteFUKr68dIFZjDlGEmMIDTLEDTvfH26MFLgIjM5rWjzOqFs8H+e lfTUhPKN3KXXmoxm/GRijfU= X-Google-Smtp-Source: AH8x226Nz61HDaGHIhcM6ASc675hLiTQlny8FeMkVynDXW6atfL9yWHIiF5jcimvB3MvZNGOti++yQ== X-Received: by 10.223.135.249 with SMTP id c54mr2545186wrc.124.1517130390350; Sun, 28 Jan 2018 01:06:30 -0800 (PST) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id 78sm6584085wmm.22.2018.01.28.01.06.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 28 Jan 2018 01:06:29 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: zhangyi , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2] overlay: add a test for multiple redirects to the same lower dir Date: Sun, 28 Jan 2018 11:07:30 +0200 Message-Id: <1517130450-7586-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 Multiple redirects to the same lower dir will falsely return the same st_ino/st_dev for two different upper dirs and will cause 'diff' to falsely report that content of directories is the same when it is not. This test checks that overalyfs detects and fails lookup of a multiply redirected dir. The check for multiply redirected dir was implemented by kernel commit 31747eda41ef ("ovl: hash directory inodes for fsnotify"). Signed-off-by: Amir Goldstein --- Eryu, Originally, I wrote this test to check directory indexing, which is only enabled by nfs_export feature. When I posted v1 of this test, I questioned whether the inconsistency checked by this test is something that overlayfs driver should check on lookup or we should leave that check entirely to fsck.overlay. Since I posted v1 of this test, the following happenend: 1. A bug was reported with overlayfs+inotify 2. A fix I posted for the overlayfs+inotify bug had a nice by-product of detecting multiply redirected dirs on lookup 3. A later NFS export patch I posted, 0aceb53e73be ("ovl: do not pass overlay dentry to ovl_get_inode()") had subtly broken the overlayfs+inotify fix, although the LTP test case I wrote wasn't good enough to detect that breakage 4. The multiply redirected test did detect the breakage of the "by-prodyct", leading me to post a fix for the breakage ("ovl: fix regression in fsnotify of overlay merge dir") At this time, both overlayfs+inotify bug fix and the breaking commit are on overlayfs-next, so this test is expected to: - fail on upstream - fail on overlayfs-next with nfs_export=off - pass on overlayfs-next with nfs_export=on After applying the breakage fix, this test in expected to pass with any overlayfs configuration. In other words, besides different expectations and naming a fix commit in the test header, there are no changes since v1 posting. Amir. tests/overlay/049 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/049.out | 2 + tests/overlay/group | 1 + 3 files changed, 112 insertions(+) create mode 100755 tests/overlay/049 create mode 100644 tests/overlay/049.out diff --git a/tests/overlay/049 b/tests/overlay/049 new file mode 100755 index 0000000..b6a9b67 --- /dev/null +++ b/tests/overlay/049 @@ -0,0 +1,109 @@ +#! /bin/bash +# FS QA Test 049 +# +# Test multiple redirects to the same lower dir. +# +# Multiple redirects to the same lower dir will falsely return the same +# st_ino/st_dev for two different upper dirs and will cause 'diff' to +# falsely report that content of directories is the same when it is not. +# +# This test checks that overlayfs detects and fails lookup of a multiply +# redirected dir. +# +# The check for multiply redirected dir was implemented by kernel commit +# 31747eda41ef ("ovl: hash directory inodes for fsnotify") +# +#----------------------------------------------------------------------- +# 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" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* +} + +# Rename lower dir to create a redirected upper dir and +# touch lower file to create copy up with origin xattr +create_redirect() +{ + local redirect=$1 + + mkdir -p $lowerdir/origin + touch $lowerdir/origin/file + + _scratch_mount -o redirect_dir=on + touch $SCRATCH_MNT/origin/file + mv $SCRATCH_MNT/origin $SCRATCH_MNT/$redirect + + $UMOUNT_PROG $SCRATCH_MNT +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +rm -f $seqres.full + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_scratch_feature redirect_dir + +# remove all files from previous runs +_scratch_mkfs + +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER + +# Create redirected dir with copied up file +create_redirect redirect1 +# Duplicate the redirected dir and copied up file +cp -a $upperdir/redirect1 $upperdir/redirect2 + +# Diverge the content of the two copies of file +# and the content of two copies of redirected dir +echo right >> $upperdir/redirect1/file +touch $upperdir/redirect1/right +echo wrong >> $upperdir/redirect2/file +touch $upperdir/redirect2/wrong + +_scratch_mount -o "redirect_dir=on" + +# If both copies of file/dir use the same st_dev/st_ino in overlay +# diff won't detect that their content differs +diff -q $SCRATCH_MNT/redirect1/file $SCRATCH_MNT/redirect2/file &>/dev/null && \ + echo "diff on files inside duplicate redirect parent doesn't know right from wrong!" + +diff -q $SCRATCH_MNT/redirect1 $SCRATCH_MNT/redirect2 &> /dev/null && \ + echo "diff on duplicate redirect dirs doesn't know right from wrong!" + +# success, all done +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/049.out b/tests/overlay/049.out new file mode 100644 index 0000000..c69568a --- /dev/null +++ b/tests/overlay/049.out @@ -0,0 +1,2 @@ +QA output created by 049 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index edea64a..4e138b9 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -49,3 +49,4 @@ 044 auto quick copyup hardlink nonsamefs 047 auto quick copyup hardlink 048 auto quick copyup hardlink +049 auto quick copyup redirect