From patchwork Thu Nov 23 14:27:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10072911 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 8F26060353 for ; Thu, 23 Nov 2017 14:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83D2E2A0C2 for ; Thu, 23 Nov 2017 14:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7894A2A0C6; Thu, 23 Nov 2017 14:26:39 +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 80DF02A0C2 for ; Thu, 23 Nov 2017 14:26:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752750AbdKWO0g (ORCPT ); Thu, 23 Nov 2017 09:26:36 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34647 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752737AbdKWO0g (ORCPT ); Thu, 23 Nov 2017 09:26:36 -0500 Received: by mail-wr0-f193.google.com with SMTP id k18so12802453wre.1; Thu, 23 Nov 2017 06:26:35 -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=6+7429EZU024UQ6uFV6EzPVkjSI3/aCTlwKJKuZ7orU=; b=WoQgaOtzu7jZj8Ly+4I7RnPNz+mcjLi6S3aNOgReXnuM0KYkGoct1nm8xqQWugSds5 nm6jRlnPwiZoyyKNrCUw5b9yoFBR5gUR9SDNJMzhOZnG9/nR4Gzc4GO5MbDjdjdCfoFf bS4h71xiUuorydKN3R6UfuIF11gV1Uc8jBBKg3MnbLvvFBenoMCXsEVQsk4VAvyCGd50 vJIqV/usK5o7Nb1ochByzD2SWMIPM1yYNq250pMgXok2PK96fgtz8Y4mhAN5X+AKrw1J ohcC8la5BWnTxVGlYBFf1G21ZaNqnUT8VbP0ONp34s2+Wa5c9kfRYT4TyI9zYXgPs+lT pwHQ== 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=6+7429EZU024UQ6uFV6EzPVkjSI3/aCTlwKJKuZ7orU=; b=Vm1YTaXqhU4GKhI/nxs2UOmCMgnGz0JmC3I6BrENg+7nUctVJWZ+sns1hCMuEwKNWA 9awjlYbvlwboKeBBn1Qp3r6HxClhB30R1fb2D2yPcDR6XgY3RLPoVyM14Vmkg6uwT7s8 PfRnPB0GV3QGDsMjo9h/MODEtcjPkZA9MhvLpeL6mZ9vz2Ir+QqhOKThvoNsIoQSQk69 OnPCLkthsmlgTesvseKrJGf3v8VcRZUtRpf77iQ85VoI0S0/KEnz74E3QERP0RwLHxHh qnBB+XDb/8yCUDvej76iBq4tB+uwvkv8VdGQ3BIGUEIYZS9NMUvs+2MqfzVUrleIODWb kV3g== X-Gm-Message-State: AJaThX5+hzLqGFGEbghJqEzRKlqMidGp2tvvyWRmiG7Th17LLKOsTOcc sNN9B9k6i67kHuU/5tQBDb8= X-Google-Smtp-Source: AGs4zMb+pKuNzCfd9N47Ze65rsgN4DJ0gtBVYap2MhGKr7h3DqJIEWp8Cgff66nrclr9nAoqcDD5Wg== X-Received: by 10.223.152.178 with SMTP id w47mr20482979wrb.254.1511447194478; Thu, 23 Nov 2017 06:26:34 -0800 (PST) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id g7sm25558025wra.38.2017.11.23.06.26.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Nov 2017 06:26:33 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , zhangyi , Chandan Rajendra , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH] overlay: add a test for multiple redirects to the same lower dir Date: Thu, 23 Nov 2017 16:27:04 +0200 Message-Id: <1511447224-2301-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 is a test for a regression introduced in kernel v4.12 by commit 72b608f08528 ("ovl: constant st_ino/st_dev across copy up"), but also the first xfstest to require the redirect_dir feature that was introduced as an opt-in feature in kernel v4.10. Signed-off-by: Amir Goldstein --- Eryu, This test is for a "bug" that has not been acknoledges by Miklos as a kernel bug yet. It may well fall within the jurisdiction of fsck.overlayfs. IMO, cp -a of upper files and dirs qualifies to the statement in Documentation/filesystems/overlayfs.txt: "Offline changes, when the overlay is not mounted, are allowed to either the upper or the lower trees." So unless Miklos objects to ever fixing this "bug"? I suggest that we include the failing test until kernel is fixed. Incidently, I already have patches for 'verify' feature [1], which I intend to post after the merge window closes. With 'verify' feature enabled this test passes. Amir. [1] https://github.com/amir73il/linux/commits/ovl-index-all tests/overlay/049 | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/049.out | 2 + tests/overlay/group | 1 + 3 files changed, 107 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..701a649 --- /dev/null +++ b/tests/overlay/049 @@ -0,0 +1,104 @@ +#! /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. +# +#----------------------------------------------------------------------- +# 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 b32c6cd..cf21750 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -47,3 +47,4 @@ 042 auto quick copyup hardlink 043 auto quick copyup nonsamefs 044 auto quick copyup hardlink nonsamefs +049 auto quick copyup redirect