From patchwork Tue Nov 28 16:42:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10080771 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 E59D760234 for ; Tue, 28 Nov 2017 16:42:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E78122936F for ; Tue, 28 Nov 2017 16:42:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC1F0294B7; Tue, 28 Nov 2017 16:42:07 +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 AD741294C6 for ; Tue, 28 Nov 2017 16:42:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932075AbdK1QmF (ORCPT ); Tue, 28 Nov 2017 11:42:05 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:44810 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752730AbdK1QmD (ORCPT ); Tue, 28 Nov 2017 11:42:03 -0500 Received: by mail-wm0-f43.google.com with SMTP id t8so788499wmc.3; Tue, 28 Nov 2017 08:42:02 -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=+HeteSrolqIK7n10thN/pNrqLN0NvqhMijpk4ehG3kQ=; b=sdkdGIRYlWuV/cwGcyz614waFgAkmoP6jZSxB5kNBdRmM+lymxg4NTfRtoYIjJCcrG 5HwhS8p8kcX2i95EnmYaEDcFwOjVSw2JZeanFEEi7eWvEvMBTrYzgB3kPokfth63lJA0 Tiu1sY/fkB7SUs4X6scxCPYLuzqUmD3uAK1ioIHe0l01P9heg5pmum/vG7kiUOpt6bw+ MdzCRdEos2rgtjox6Ni8zfWNnGEdB23Haju9WBPLJquYcSrA/nNX6yspYIxTG374JSIP 0cq9PvtsDiyqGvAJa2kNwVWHsNyNm0ZBDGtkae2IHHezM/IL9RmyRSo3kCpWqrcbCAY/ WRnw== 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=+HeteSrolqIK7n10thN/pNrqLN0NvqhMijpk4ehG3kQ=; b=IcG+bPdO1Xb0wZqoSqG8Mm8bbxdUMc3qSXT8n3mx2jcAd5kMYk5yCPR8htKSgJvkXN nJg1kOPOWqemJU2OgBjtv8v5c7187lQN/ns56HQ+xZvSzmKhBud2Tyjf1C946uFKLQbp 4GZGXL5A5p+VBcz+Or/Rlk/tiEKWyELSPxFJAdurQKTgbG98qipKIGPb1apw5xHXyMra tV/wOpV9JJwrUZqMdSUOfrm6tmiHQpORm4SSsLNp7+pCrTm3rZhll2jpEwQc9Vq9oduM aMjV3+J52fcZsMajPL9+zlWuby3DliUVoOGtabBrd71+HbLIxD0RvQpmvPkY9GjB6W+i nygQ== X-Gm-Message-State: AJaThX5ldlV3LKOGcNPr4kCbdgyxOWbU2FO6RoDz1PM9llW0LQMFtwYj sLfG9WtHjU4Hn/fRG3WqjP6uLA== X-Google-Smtp-Source: AGs4zMZhG8J7auFRFHiP/dn8oCFyfVRnvPJ/BValbHrV+HuuFg7eobBCZvOD47nbGoKoe9ZZOms88w== X-Received: by 10.28.136.15 with SMTP id k15mr180945wmd.147.1511887321714; Tue, 28 Nov 2017 08:42:01 -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.42.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Nov 2017 08:42:01 -0800 (PST) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , Vivek Goyal , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 2/3] overlay: regression test for orphan index cleanup on mount Date: Tue, 28 Nov 2017 18:42:01 +0200 Message-Id: <1511887322-29254-3-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 Test nlink accounting of overlay hardlinks with offline modifications. nlink of overlay inode should account for the union of lower and upper hardlinks. Orphan index inodes with union nlink 0 should be cleaned on mount. Signed-off-by: Amir Goldstein --- tests/overlay/048 | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/048.out | 18 +++++++ tests/overlay/group | 1 + 3 files changed, 160 insertions(+) create mode 100755 tests/overlay/048 create mode 100644 tests/overlay/048.out diff --git a/tests/overlay/048 b/tests/overlay/048 new file mode 100755 index 0000000..4b2c58f --- /dev/null +++ b/tests/overlay/048 @@ -0,0 +1,141 @@ +#! /bin/bash +# FS QA Test 048 +# +# Test nlink accounting of overlay hardlinks with offline modifications. +# +# nlink of overlay inode should account for the union of lower and upper +# hardlinks. Orphan index inodes with union nlink 0 should be cleaned on +# mount. +# +#----------------------------------------------------------------------- +# 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 +_require_scratch_feature index + +report_nlink() +{ + when=$1 + + # mount and check nlink after overlay offline modification + _scratch_mount -o index=on + + # List + echo "== $when offline ==" + for f in $HARDLINKS; do + _ls_l $SCRATCH_MNT/$f | awk '{ print $2, $9 }' | _filter_scratch + done + + $UMOUNT_PROG $SCRATCH_MNT +} + +# Create lower hardlinks +create_hardlinks() +{ + mkdir -p $lowerdir + touch $lowerdir/0 + ln $lowerdir/0 $lowerdir/1 + ln $lowerdir/0 $lowerdir/2 +} + +test_hardlinks_offline() +{ + HARDLINKS=`seq 0 2` + report_nlink "all upper" + + # Unlink copied up hardlink + rm $upperdir/0 + HARDLINKS=`seq 1 2` + report_nlink "unlink upper" + + # Link to copied up hardlink + ln $upperdir/2 $upperdir/3 + HARDLINKS=`seq 1 3` + report_nlink "link upper" + + # Rename over copied up hardlink + touch $upperdir/new + mv $upperdir/new $upperdir/1 + HARDLINKS=`seq 2 3` + report_nlink "rename over upper" + + # Unlink new upper hardlink + rm $upperdir/3 + HARDLINKS=2 + report_nlink "unlink new upper" + + # Unlink last upper and drop union nlink to zero + rm $upperdir/2 + + HARDLINKS= + report_nlink "unlink last lower" + + # Verify that orphan index is cleaned when dropping nlink to zero + ls $workdir/index +} + +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +upperdir=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER +workdir=$OVL_BASE_SCRATCH_MNT/$OVL_WORK + +# Remove all files from previous tests +_scratch_mkfs + +# Create lower hardlinks +create_hardlinks + +# Enable overlay index feature to prevent breaking hardlinks on copy up +_scratch_mount -o index=on + +# Copy up and index hardlinks +touch $SCRATCH_MNT/0 +touch $SCRATCH_MNT/1 +touch $SCRATCH_MNT/2 + +# Perform the rest of the changes offline +$UMOUNT_PROG $SCRATCH_MNT + +test_hardlinks_offline + +status=0 +exit diff --git a/tests/overlay/048.out b/tests/overlay/048.out new file mode 100644 index 0000000..0527dec --- /dev/null +++ b/tests/overlay/048.out @@ -0,0 +1,18 @@ +QA output created by 048 +== all upper offline == +3 SCRATCH_MNT/0 +3 SCRATCH_MNT/1 +3 SCRATCH_MNT/2 +== unlink upper offline == +2 SCRATCH_MNT/1 +2 SCRATCH_MNT/2 +== link upper offline == +3 SCRATCH_MNT/1 +3 SCRATCH_MNT/2 +3 SCRATCH_MNT/3 +== rename over upper offline == +2 SCRATCH_MNT/2 +2 SCRATCH_MNT/3 +== unlink new upper offline == +1 SCRATCH_MNT/2 +== unlink last lower offline == diff --git a/tests/overlay/group b/tests/overlay/group index 3e31d2d..7e541e4 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -48,3 +48,4 @@ 043 auto quick copyup nonsamefs 044 auto quick copyup hardlink nonsamefs 047 auto quick copyup hardlink +048 auto quick copyup hardlink