From patchwork Tue Jul 4 11:20:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9824603 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 E398D602F0 for ; Tue, 4 Jul 2017 11:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D50C92844E for ; Tue, 4 Jul 2017 11:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9A9B28469; Tue, 4 Jul 2017 11:20:29 +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 62A0A2844E for ; Tue, 4 Jul 2017 11:20:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752331AbdGDLU3 (ORCPT ); Tue, 4 Jul 2017 07:20:29 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35104 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752315AbdGDLU1 (ORCPT ); Tue, 4 Jul 2017 07:20:27 -0400 Received: by mail-wr0-f196.google.com with SMTP id z45so47131777wrb.2; Tue, 04 Jul 2017 04:20:26 -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:in-reply-to:references; bh=ARrs8xmarVhyipn97VQs2O17w/yiZVXF/MxfINQMmr8=; b=vEcxxiPT58ng0ndruDsA5PyypB93BgwnUprwOO56gvIJqgN/ocURo8lLmWw8Y0E3ZS LwYloDQ+g9OBp4YPbr2Y0WiDJK5HIQiBa9xiwkmC4tgCmM2WEGBfLJRoXd8NTf1LgeLq FvsU52T3qbQeAEJEK49qsXsMSPFWHTe2nKE+l0qJWAKTgcoHc5VMQC2lXmG5MVViedlK pG5+hXJTVaz/g+Q8Ck3AGLuR1gONas1txgVO9n95TzwqYRGKb0t1j9IGHYyq9RnHEEi3 dWY6L9RTtA8Lrnr2xp8gxNT2FKe5G46Talvxx2Mz70PLsAeOBb+QUQLZFtq5ww9IOCX9 JnfA== 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=ARrs8xmarVhyipn97VQs2O17w/yiZVXF/MxfINQMmr8=; b=opRk3EgDyDRURSgXazHn5yJf7oeAbu9PBfqzAR5Fs/Y5EIOOTKQ2PoAzd44xDhqvaY j+X7DzJIr7+UU8Z+/U8tvsGFn0wUX2xVzOcbbfuEtTTpZHAcou5hIsCfnZ2lc5M16kC5 MRiXCrvVn3tiNp+zFhncgsZAfEryImfTB6TyKPdSlsVb5FS6i+V7duHvjMiDKwIaViFZ nVs8WSGLBG7jJ6q9tJTnVsPFLoxVxWAP6+Ro8n3t9Qf/L4Rt5paty5eD4xwMwwAlwcr2 CeadCk7fvUazlW/KCYQVcWYlRXrbPl5xYGQrkdSRm1sTd5iUY6+44QEq6xraG3TDNjE7 dywg== X-Gm-Message-State: AKS2vOwjcf2I2j4xtJdiKakK3ZDt9HQR/DUnmHZBKnIlhz+3Kj4J9ynV 4EW+UgaJWE7MaZ7A X-Received: by 10.223.136.37 with SMTP id d34mr37866313wrd.160.1499167225764; Tue, 04 Jul 2017 04:20:25 -0700 (PDT) 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 l20sm14121449wre.25.2017.07.04.04.20.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 04:20:25 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 6/6] overlay: test dropping nlink below zero Date: Tue, 4 Jul 2017 14:20:34 +0300 Message-Id: <1499167234-22779-7-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499167234-22779-1-git-send-email-amir73il@gmail.com> References: <1499167234-22779-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 nlink of overlay inode could be dropped indefinety by adding un-accounted lower hardlinks underneath a mounted overlay and trying to remove them. Signed-off-by: Amir Goldstein --- tests/overlay/034 | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/overlay/034.out | 2 ++ tests/overlay/group | 1 + 3 files changed, 94 insertions(+) create mode 100755 tests/overlay/034 create mode 100644 tests/overlay/034.out diff --git a/tests/overlay/034 b/tests/overlay/034 new file mode 100755 index 0000000..cb023bf --- /dev/null +++ b/tests/overlay/034 @@ -0,0 +1,91 @@ +#! /bin/bash +# FS QA Test 034 +# +# Test overlay nlink when adding lower hardlinks. +# +# nlink of overlay inode could be dropped indefinety by adding +# unaccounted lower hardlinks underneath a mounted overlay and +# trying to remove them. +# +#----------------------------------------------------------------------- +# 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 + +# Remove all files from previous tests +_scratch_mkfs + +# Create lower hardlink +lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER +mkdir -p $lowerdir +touch $lowerdir/0 +ln $lowerdir/0 $lowerdir/1 + +_scratch_mount + +# Copy up lower hardlink - nlink should be 2 +touch $SCRATCH_MNT/0 + +# Add lower hardlinks while overlay is mounted +ln $lowerdir/0 $lowerdir/2 +ln $lowerdir/0 $lowerdir/3 + +# Unlink un-accounted lowers to drive nlink to 0 +rm $SCRATCH_MNT/2 +rm $SCRATCH_MNT/3 + +# Check for getting ENOENT for trying to link !I_LINKABLE with nlink 0 +ln $SCRATCH_MNT/0 $SCRATCH_MNT/4 + +# Unlink all hardlink to drive nlink below 0 +rm $SCRATCH_MNT/0 +rm $SCRATCH_MNT/1 +rm $SCRATCH_MNT/4 + +# Verify that orphan index is cleaned on mount +_scratch_cycle_mount +ls $OVL_BASE_SCRATCH_MNT/$OVL_WORK/index 2>/dev/null + +echo "Silence is golden" +status=0 +exit diff --git a/tests/overlay/034.out b/tests/overlay/034.out new file mode 100644 index 0000000..4c8873c --- /dev/null +++ b/tests/overlay/034.out @@ -0,0 +1,2 @@ +QA output created by 034 +Silence is golden diff --git a/tests/overlay/group b/tests/overlay/group index 35cd5a5..b55ed0c 100644 --- a/tests/overlay/group +++ b/tests/overlay/group @@ -36,3 +36,4 @@ 031 auto quick whiteout 032 auto quick copyup hardlink 033 auto quick copyup hardlink +034 auto quick copyup hardlink