From patchwork Tue Jul 4 11:40: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: 9824649 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 29ACB60237 for ; Tue, 4 Jul 2017 11:40:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C9032811E for ; Tue, 4 Jul 2017 11:40:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 115CB283B4; Tue, 4 Jul 2017 11:40:35 +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 9540F2811E for ; Tue, 4 Jul 2017 11:40:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752040AbdGDLke (ORCPT ); Tue, 4 Jul 2017 07:40:34 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33228 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752051AbdGDLkd (ORCPT ); Tue, 4 Jul 2017 07:40:33 -0400 Received: by mail-wm0-f67.google.com with SMTP id j85so25714303wmj.0; Tue, 04 Jul 2017 04:40:32 -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=ASRcz665w2/bnnpKc3lHQBLO/h7VDqEZhXiGoALa7uqbeEL8wYdpb18hCJdydMmi1t 61K3lgKQR7l0Cmct0J5VqT14TfnKDwiTf/bQDJwJq7gIihMT8A2Ex8eeozPmpRjmPyKm KWAAG2EDUMEMfqFTrycwDpA0+Bqdb7sC/zSzEUh6FErsasosAgJx4+D55lGBYBywcpqz pjk5Zz59HC26Z/TBrNVwe77rKgPeWjeKsvTN73i6yQLR+4P8oXwpcXjppwkFOFI1IquP +Kipwwm1rWuBKrsecXWMiV3LUkocE3Z7iNPrlrIfp9lUwBFy2SE00+Pps0XoXAaA+gv4 BEhQ== 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=epWPe57FHPJMo37DRtx57QH55b7d3cPL/pFoGjRJ8B52qbsWyHICC1WtPd/JJWkvvy bDCmVkHXs0pU1+hqUpQGFj1ntj8dQGang/PsdKr3zB5O8yWxppTeu/fAjhyxmIhwDLbn 7dBualVtHqbC3mvHv7hQj4VCqygIbYyjx7+ulQw1Cjf44neGA8kZw2BnI9dCSve93WxW xmp+e44QP4ccaYXgefgvsAmhMUAC14sw0c1fNwp0z7QJNFOWKNOxjHLO6OPSKQRTveBd uQgXXcdIErFg6ZhvF8QNbcwByVL/MU4RO7GvbW3cGYe2Lnung/SerWqyGfDjDLE0f/3E GNEw== X-Gm-Message-State: AIVw111wRGqPw1S/ZLwTzBbP/rmy8XPAT72Vj55FKZJvf8N3KPZ2HibA Sxq33Ditg2FplQ== X-Received: by 10.28.225.5 with SMTP id y5mr1373907wmg.18.1499168431922; Tue, 04 Jul 2017 04:40:31 -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 90sm18842912wrk.38.2017.07.04.04.40.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jul 2017 04:40:31 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v2 7/7] overlay: test dropping nlink below zero Date: Tue, 4 Jul 2017 14:40:34 +0300 Message-Id: <1499168434-23859-8-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499168434-23859-1-git-send-email-amir73il@gmail.com> References: <1499168434-23859-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