From patchwork Tue Nov 28 16:42:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10080769 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 05C9A60234 for ; Tue, 28 Nov 2017 16:42:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07FEE294C8 for ; Tue, 28 Nov 2017 16:42:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F07D2294DB; Tue, 28 Nov 2017 16:42:05 +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 75105294C8 for ; Tue, 28 Nov 2017 16:42:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932072AbdK1QmE (ORCPT ); Tue, 28 Nov 2017 11:42:04 -0500 Received: from mail-wm0-f41.google.com ([74.125.82.41]:40748 "EHLO mail-wm0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753683AbdK1QmB (ORCPT ); Tue, 28 Nov 2017 11:42:01 -0500 Received: by mail-wm0-f41.google.com with SMTP id v19so703614wmh.5; Tue, 28 Nov 2017 08:42:01 -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:in-reply-to:references; bh=Ut7rxaeo6StcFLJErSUZq0dMphQzO9vPmbmbj5v1I1s=; b=mCJcz7TeqPB1Dp+Rjd+FEQpmLusycju7lbncRsfhp2CnMF5oP73Aio1wedXelf5McC KYnAkUHcFXvZbgX+R7rZtxTtN+uKLUQhaVO/doyA4CzPRLJ4/3oahScFiber6C02DSkR Tr371siy9nlonrZmM3z7bNL710JKtdJsS+S1SXqElSbj1oTx0Dcr2bJKGgXHJsKZXk2S F5WlyFpGbhIwZNvwSMIhcOxgqdTfVKJnYBV6trwhM78X7t+Lrt7MiqaFIkcPO2Qfd6/9 9D5A0rPvMYGyeWD/rFiEhyVUyol/hVrXk6NBcs1gcXeWLkpCiMr3uFEAK6E9NT/JNW80 +PGQ== 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:in-reply-to :references; bh=Ut7rxaeo6StcFLJErSUZq0dMphQzO9vPmbmbj5v1I1s=; b=YFSQSImb4v1CYVKnLcsGjUyKDkgQpEdlvRMPGnPJukcoyZF0bWg1efwTKMTiaDAKxS MynSF9C1nEk/qnQdbE6xtSm5mpEE5SEWLQ9X28lIHrGPjYsTHh0G0laNDc9cUX3RScVP fmTQVdN/YKm78wpkP1uha7CNabFboI/Bw3VuU3HAr3EM8ShxMOZtLRoG+3n0L0hdi5dg EjyA1G1yFVNjoTluPOXnbcSDh8dOGdfIezY//4BdIOzC2+3jFKwvCPVDgxUVCPdwOIhv ckq+zFNLPOv/UsDDlMOcDuLmcbJSjeolRC4SiTehQN4M585CT6jbGSIQT34mZO/t23uR SM2Q== X-Gm-Message-State: AJaThX7Ry0YlvmNtVXx1zlIsli5Vxuwgx/Rzcu4LA3mmxD377LOM9YaE /yy+BYkJsDyXDfJDilzMfQ4= X-Google-Smtp-Source: AGs4zMb21hAEOL8MrUpqtJNk8SQBANOT77CvyJP4gUs0VuO+ZDZuex6UjI6R5fI/Co20pW3AxCOjGA== X-Received: by 10.28.178.85 with SMTP id b82mr174182wmf.47.1511887320311; Tue, 28 Nov 2017 08:42:00 -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 r14sm70183446wrb.43.2017.11.28.08.41.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Nov 2017 08:41:59 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Vivek Goyal , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/3] overlay: regression test for hardlink breakage after unlink and mount cycle Date: Tue, 28 Nov 2017 18:42:00 +0200 Message-Id: <1511887322-29254-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511887322-29254-1-git-send-email-amir73il@gmail.com> References: <1511887322-29254-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP - file A and B are hardlinked in lower - modify A to trigger copy up and index lower - unlink A and mount cycle - check that B still contains the modified data Signed-off-by: Amir Goldstein --- tests/overlay/047 | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/047.out | 16 ++++++++ tests/overlay/group | 1 + 3 files changed, 124 insertions(+) create mode 100755 tests/overlay/047 create mode 100644 tests/overlay/047.out diff --git a/tests/overlay/047 b/tests/overlay/047 new file mode 100755 index 0000000..ad1aabe --- /dev/null +++ b/tests/overlay/047 @@ -0,0 +1,107 @@ +#! /bin/bash +# FSQA Test No. 047 +# +# Test hardlink breakage after unlink and mount cycle +# +# - file A and B are hardlinked in lower +# - modify A to trigger copy up and index lower +# - unlink A and mount cycle +# - check that B still contains the modified data +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2016-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() +{ + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs overlay +_supported_os Linux +_require_scratch +_require_scratch_feature index + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +# Create 2 hardlinked files in lower +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +mkdir -p $lowerdir +echo "zero" >> $lowerdir/foo +ln $lowerdir/foo $lowerdir/bar + + +# Enable overlay index feature to prevent breaking hardlinks on copy up +_scratch_mount -o index=on + + +rm -f $tmp.* + +foo=$SCRATCH_MNT/foo +bar=$SCRATCH_MNT/bar + +FILES="$foo $bar" + +echo "== Before copy up ==" +cat $foo + +# Modify content of one of the hardlinks +echo "one" >> $bar + +echo "== After write one ==" +cat $foo + +# Unlink the copied up hardlink +rm $bar + +echo "== After unlink one ==" +cat $foo + +# Verify that the hardlinks survive a mount cycle +_scratch_cycle_mount index=on + +echo "== After mount cycle ==" +cat $foo + +# Drop caches to get the copied up hardlink out of cache +echo 3 > /proc/sys/vm/drop_caches + +# Modify content of the other hardlink +echo "two" >> $foo + +echo "== After write two ==" +cat $foo + +status=0 +exit diff --git a/tests/overlay/047.out b/tests/overlay/047.out new file mode 100644 index 0000000..298e116 --- /dev/null +++ b/tests/overlay/047.out @@ -0,0 +1,16 @@ +QA output created by 047 +== Before copy up == +zero +== After write one == +zero +one +== After unlink one == +zero +one +== After mount cycle == +zero +one +== After write two == +zero +one +two diff --git a/tests/overlay/group b/tests/overlay/group index b32c6cd..3e31d2d 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 +047 auto quick copyup hardlink