From patchwork Tue Mar 18 17:57:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 3854991 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E5699BF549 for ; Wed, 19 Mar 2014 17:52:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7EF920131 for ; Wed, 19 Mar 2014 17:52:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8B8B2012E for ; Wed, 19 Mar 2014 17:52:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757386AbaCRR5f (ORCPT ); Tue, 18 Mar 2014 13:57:35 -0400 Received: from mail-wi0-f181.google.com ([209.85.212.181]:54398 "EHLO mail-wi0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756973AbaCRR5d (ORCPT ); Tue, 18 Mar 2014 13:57:33 -0400 Received: by mail-wi0-f181.google.com with SMTP id hm4so4067535wib.14 for ; Tue, 18 Mar 2014 10:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tS9RP2QMQfCxVfxeCWM7DyewJCfUF0tLtHjV6g9T8ls=; b=BvEwsTui6eO1XSbzoX57MQ+mrcPE9lz89jTlbCsDRxvwVf6Ph9+kZMR4z8M73RIqjH covPceUbbAQK6G8JxVNJcT9hOh+dzhY75CqIFNMa2tEucM9MAuGrTC55uBy6Q92ZqqMU tDBaTrueKvGM6RZAZiIS3nFfYwd86dXENhE0lkjredx1lMNToOiazWl41vapPMXW72Q5 joCZxXC/JrYRHh1Si9Dlb8mB7cWz6VJn6zXxqiWeCNR3HX9wuOavUzkHzD6LFaw1nAWG b2IK/zduyqWXWlxCuUN0jtj1KPhAHyNgDrRrg9C/dQyKs2gMtJAGIZcUVYMNHiK0OoMJ 25JA== X-Received: by 10.194.60.37 with SMTP id e5mr24239657wjr.32.1395165452276; Tue, 18 Mar 2014 10:57:32 -0700 (PDT) Received: from debian-vm3.lan (bl10-140-160.dsl.telepac.pt. [85.243.140.160]) by mx.google.com with ESMTPSA id lz3sm36762554wic.1.2014.03.18.10.57.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Mar 2014 10:57:31 -0700 (PDT) From: Filipe David Borba Manana To: xfs@oss.sgi.com Cc: linux-btrfs@vger.kernel.org, jbacik@fb.com, Filipe David Borba Manana Subject: [PATCH v3] xfstests: add test for btrfs send regarding directory moves/renames Date: Tue, 18 Mar 2014 17:57:24 +0000 Message-Id: <1395165444-24772-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1394983466-20497-1-git-send-email-fdmanana@gmail.com> References: <1394983466-20497-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Regression test for a btrfs incremental send issue where the kernel entered an infinite loop building a path string. This happened when either of the 2 following cases happened: 1) A directory was made a child of another directory which has a lower inode number and has a pending move/rename operation; 2) A directory was made a child of another directory which has a higher inode number, but the new parent wasn't moved nor renamed. Instead some other ancestor higher in the hierarchy, with an higher inode number too, was moved/renamed too. This issue is fixed by the following linux kernel btrfs patch: Btrfs: fix incremental send's decision to delay a dir move/rename Btrfs: part 2, fix incremental send's decision to delay a dir move/rename Signed-off-by: Filipe David Borba Manana --- V2: Added more tests. V3: Added more tests for more complex cases. tests/btrfs/045 | 214 +++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/045.out | 1 + tests/btrfs/group | 1 + 3 files changed, 216 insertions(+) create mode 100755 tests/btrfs/045 create mode 100644 tests/btrfs/045.out diff --git a/tests/btrfs/045 b/tests/btrfs/045 new file mode 100755 index 0000000..85201e3 --- /dev/null +++ b/tests/btrfs/045 @@ -0,0 +1,214 @@ +#! /bin/bash +# FS QA Test No. btrfs/045 +# +# Regression test for a btrfs incremental send issue where the kernel entered +# an infinite loop building a path string. This happened when either of the +# 2 following cases happened: +# +# 1) A directory was made a child of another directory which has a lower inode +# number and has a pending move/rename operation; +# +# 2) A directory was made a child of another directory which has a higher inode +# number, but the new parent wasn't moved nor renamed. Instead some other +# ancestor higher in the hierarchy, with an higher inode number too, was +# moved/renamed too. +# +# This issue is fixed by the following linux kernel btrfs patch: +# +# Btrfs: fix incremental send's decision to delay a dir move/rename +# Btrfs: part 2, fix incremental send's decision to delay a dir move/rename +# +#----------------------------------------------------------------------- +# Copyright (c) 2014 Filipe Manana. All Rights Reserved. +# +# 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=`mktemp -d` +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -fr $tmp +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux +_require_scratch +_require_fssum +_need_to_be_root + +rm -f $seqres.full + +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +# case 1), mentioned above +mkdir -p $SCRATCH_MNT/a/b +mkdir $SCRATCH_MNT/a/c +mkdir $SCRATCH_MNT/a/b/d +touch $SCRATCH_MNT/a/file1 +touch $SCRATCH_MNT/a/b/file2 +mv $SCRATCH_MNT/a/file1 $SCRATCH_MNT/a/b/d/file3 +ln $SCRATCH_MNT/a/b/d/file3 $SCRATCH_MNT/a/b/file4 +mkdir $SCRATCH_MNT/a/b/f +mv $SCRATCH_MNT/a/b $SCRATCH_MNT/a/c/b2 +touch $SCRATCH_MNT/a/c/b2/d/file5 + +# case 2), mentioned above +mkdir -p $SCRATCH_MNT/a/x1/x2 +mkdir $SCRATCH_MNT/a/Z +mkdir -p $SCRATCH_MNT/a/x1/x2/x3/x4/x5 + +# case 2) again, but a more complex scenario +mkdir -p $SCRATCH_MNT/_a/_b/_c/_d +mkdir $SCRATCH_MNT/_a/_b/_c/_d/_e +mkdir $SCRATCH_MNT/_a/_b/_c/_d/_f +mv $SCRATCH_MNT/_a/_b/_c/_d/_e $SCRATCH_MNT/_a/_b/_c/_d/_f/_E2 +mkdir $SCRATCH_MNT/_a/_b/_c/_g +mv $SCRATCH_MNT/_a/_b/_c/_d $SCRATCH_MNT/_a/_b/_D2 + +# Filesystem looks like: +# +# . (ino 256) +# |-- a/ (ino 257) +# | |-- c/ (ino 259) +# | | |-- b2/ (ino 258) +# | | |-- d/ (ino 260) +# | | | |-- file3 (ino 261) +# | | | |-- file5 (ino 264) +# | | | +# | | |-- file2 (ino 262) +# | | |-- file4 (ino 261) +# | | |-- f/ (ino 263) +# | | +# | |-- x1/ (ino 265) +# | | |-- x2/ (ino 266) +# | | |-- x3/ (ino 268) +# | | |-- x4/ (ino 269) +# | | |-- x5/ (ino 270) +# | | +# | |-- Z/ (ino 267) +# | +# |-- _a/ (ino 271) +# |-- _b/ (ino 272) +# |-- _c/ (ino 273) +# | |-- _g/ (ino 277) +# | +# |-- _D2/ (ino 274) +# |-- _f/ (ino 276) +# |-- _E2/ (ino 275) + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1 + +# case 1), mentioned above +ln $SCRATCH_MNT/a/c/b2/file4 $SCRATCH_MNT/a/c/b2/f/file6 +mv $SCRATCH_MNT/a/c/b2/d/file5 $SCRATCH_MNT/a/c/file7 +touch $SCRATCH_MNT/a/c/b2/d/file8 +touch $SCRATCH_MNT/a/c/b2/file9 +ln $SCRATCH_MNT/a/c/b2/file9 $SCRATCH_MNT/a/c/b2/file10 +mv $SCRATCH_MNT/a/c/b2/f $SCRATCH_MNT/a/f2 +mv $SCRATCH_MNT/a/c $SCRATCH_MNT/a/c2 +mv $SCRATCH_MNT/a/c2/b2 $SCRATCH_MNT/a/f2/b3 +mv $SCRATCH_MNT/a/c2 $SCRATCH_MNT/a/f2/b3/c3 +touch $SCRATCH_MNT/a/f2/b3/c3/file11 +mv $SCRATCH_MNT/a $SCRATCH_MNT/a2 + +# case 2), mentioned above +mv $SCRATCH_MNT/a2/x1/x2/x3 $SCRATCH_MNT/a2/Z/X33 +mv $SCRATCH_MNT/a2/x1/x2 $SCRATCH_MNT/a2/Z/X33/x4/x5/X22 + +# case 2) again, but a more complex scenario +mkdir $SCRATCH_MNT/_a/_o +mv $SCRATCH_MNT/_a/_b/_c/_g $SCRATCH_MNT/_a/_b/_D2/_f/_G2 +mv $SCRATCH_MNT/_a/_b/_D2 $SCRATCH_MNT/_a/_b/_dd +mv $SCRATCH_MNT/_a/_b/_c $SCRATCH_MNT/_a/_C2 +mv $SCRATCH_MNT/_a/_b/_dd/_f $SCRATCH_MNT/_a/_o/_FF +mv $SCRATCH_MNT/_a/_b $SCRATCH_MNT/_a/_o/_FF/_E2/_BB + +# Filesystem now looks like: +# +# . (ino 256) +# |-- a2/ (ino 257) +# | |-- f2/ (ino 263) +# | | |-- file6 (ino 261) +# | | |-- b3/ (ino 258) +# | | |-- d/ (ino 260) +# | | | |-- file3 (ino 261) +# | | | |-- file8 (ino 278) +# | | | +# | | |-- file2 (ino 262) +# | | |-- file4 (ino 261) +# | | |-- file9 (ino 279) +# | | |-- file10 (ino 279) +# | | | +# | | |-- c3/ (ino 259) +# | | |-- file7 (ino 264) +# | | |-- file11 (ino 280) +# | | +# | |-- x1/ (ino 265) +# | |-- Z/ (ino 267) +# | |-- X33/ (ino 268) +# | |-- x4/ (ino 269) +# | |-- x5/ (ino 270) +# | |-- X22/ (ino 266) +# | +# |-- _a/ (ino 271) +# |-- _o/ (ino 281) +# | |-- _FF/ (ino 276) +# | |-- _E2/ (ino 275) +# | | |-- _BB/ (ino 272) +# | | |-- dd/ (ino 274) +# | | +# | |-- G2/ (ino 277) +# |-- C2/ (ino 273) + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2 + +run_check $FSSUM_PROG -A -f -w $tmp/1.fssum $SCRATCH_MNT/mysnap1 +run_check $FSSUM_PROG -A -f -w $tmp/2.fssum -x $SCRATCH_MNT/mysnap2/mysnap1 \ + $SCRATCH_MNT/mysnap2 + +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $tmp/1.snap + +_run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \ + -f $tmp/2.snap + +_check_scratch_fs + +_scratch_unmount +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $tmp/1.snap +run_check $FSSUM_PROG -r $tmp/1.fssum $SCRATCH_MNT/mysnap1 + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $tmp/2.snap +run_check $FSSUM_PROG -r $tmp/2.fssum $SCRATCH_MNT/mysnap2 + +_check_scratch_fs + +status=0 +exit diff --git a/tests/btrfs/045.out b/tests/btrfs/045.out new file mode 100644 index 0000000..5b0d489 --- /dev/null +++ b/tests/btrfs/045.out @@ -0,0 +1 @@ +QA output created by 045 diff --git a/tests/btrfs/group b/tests/btrfs/group index 4589043..9b41895 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -47,3 +47,4 @@ 042 auto quick 043 auto quick 044 auto quick +045 auto quick