From patchwork Sat Jul 2 12:32:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 9223369 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 44B7460572 for ; Mon, 11 Jul 2016 11:17:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 341F927BFF for ; Mon, 11 Jul 2016 11:17:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2890A2787D; Mon, 11 Jul 2016 11:17:48 +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=-3.5 required=2.0 tests=BAYES_00, DATE_IN_PAST_96_XX, RCVD_IN_DNSWL_HI 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 28A5C2787D for ; Mon, 11 Jul 2016 11:17:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753673AbcGKLRq (ORCPT ); Mon, 11 Jul 2016 07:17:46 -0400 Received: from mail.kernel.org ([198.145.29.136]:35498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753536AbcGKLRp (ORCPT ); Mon, 11 Jul 2016 07:17:45 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1134720204; Mon, 11 Jul 2016 11:17:44 +0000 (UTC) Received: from debian3.lan (bl12-226-64.dsl.telepac.pt [85.245.226.64]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3D8E201F4; Mon, 11 Jul 2016 11:17:41 +0000 (UTC) From: fdmanana@kernel.org To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH 1/3] btrfs: add test for an incremental send after moving directories around Date: Sat, 2 Jul 2016 13:32:08 +0100 Message-Id: <1467462728-14495-1-git-send-email-fdmanana@kernel.org> X-Mailer: git-send-email 2.7.0.rc3 X-Virus-Scanned: ClamAV using ClamSMTP Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana Test that an incremental send operation works after doing radical changes in the directory hierarchy that involve switching the inode that directory entries point to. This test exercises scenarios used to fail in btrfs and are fixed by the following patches for the linux kernel: "Btrfs: send, fix failure to move directories with the same name around" "Btrfs: incremental send, fix invalid paths for rename operations" Signed-off-by: Filipe Manana --- tests/btrfs/124 | 261 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/124.out | 2 + tests/btrfs/group | 1 + 3 files changed, 264 insertions(+) create mode 100755 tests/btrfs/124 create mode 100644 tests/btrfs/124.out diff --git a/tests/btrfs/124 b/tests/btrfs/124 new file mode 100755 index 0000000..38635a3 --- /dev/null +++ b/tests/btrfs/124 @@ -0,0 +1,261 @@ +#! /bin/bash +# FS QA Test No. btrfs/124 +# +# Test that an incremental send operation works after doing radical changes +# in the directory hierarchy that involve switching the inode that directory +# entries point to. +# +#----------------------------------------------------------------------- +# Copyright (C) 2016 SUSE Linux Products GmbH. All Rights Reserved. +# Author: Filipe Manana +# +# 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 -fr $send_files_dir + rm -f $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 + +send_files_dir=$TEST_DIR/btrfs-test-$seq + +rm -f $seqres.full +rm -fr $send_files_dir +mkdir $send_files_dir + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +# case 1 +mkdir -p $SCRATCH_MNT/case_1/d/p1 +mkdir $SCRATCH_MNT/case_1/p1 + +# case 2 +mkdir -p $SCRATCH_MNT/case_2/a +mkdir $SCRATCH_MNT/case_2/d +mkdir $SCRATCH_MNT/case_2/e +mkdir $SCRATCH_MNT/case_2/f +mkdir $SCRATCH_MNT/case_2/ance +mkdir $SCRATCH_MNT/case_2/d/ance +mkdir $SCRATCH_MNT/case_2/a/c +mv $SCRATCH_MNT/case_2/e $SCRATCH_MNT/case_2/d/ance +mv $SCRATCH_MNT/case_2/f $SCRATCH_MNT/case_2/d/ance +mv $SCRATCH_MNT/case_2/ance $SCRATCH_MNT/case_2/d/ance + +# case 3 +mkdir -p $SCRATCH_MNT/case_3/d +mkdir $SCRATCH_MNT/case_3/a +mkdir $SCRATCH_MNT/case_3/waiting_dir +mkdir -p $SCRATCH_MNT/case_3/pre/ance +mkdir $SCRATCH_MNT/case_3/d/ance +mkdir $SCRATCH_MNT/case_3/a/c +mv $SCRATCH_MNT/case_3/waiting_dir $SCRATCH_MNT/case_3/d/ance + +# case 4 +mkdir -p $SCRATCH_MNT/case_4/tmp +mkdir $SCRATCH_MNT/case_4/below_ance +mkdir -p $SCRATCH_MNT/case_4/pre/wait_dir +mkdir $SCRATCH_MNT/case_4/desc +mkdir $SCRATCH_MNT/case_4/ance +mv $SCRATCH_MNT/case_4/below_ance $SCRATCH_MNT/case_4/ance +mkdir $SCRATCH_MNT/case_4/other_dir + +# Filesystem looks like: +# +# . (ino 256) +# |--- case_1/ (ino 257) +# | |---- d/ (ino 258) +# | | |--- p1/ (ino 259) +# | | +# | |---- p1/ (ino 260) +# | +# |--- case_2/ (ino 261) +# | |---- a/ (ino 262) +# | | |---- c/ (ino 268) +# | | +# | |---- d/ (ino 263) +# | |---- ance/ (ino 267) +# | |---- e/ (ino 264) +# | |---- f/ (ino 265) +# | |---- ance/ (ino 266) +# | +# |--- case_3/ (ino 269) +# | |---- a/ (ino 271) +# | | |---- c/ (ino 276) +# | | +# | |---- d/ (ino 270) +# | | |---- ance/ (ino 275) +# | | |---- waiting_dir/ (ino 272) +# | | +# | |---- pre/ (ino 273) +# | |---- ance/ (ino 274) +# | +# |--- case_4/ (ino 277) +# |---- tmp/ (ino 278) +# |---- pre/ (ino 280) +# | |---- wait_dir/ (ino 281) +# | +# |---- desc/ (ino 282) +# |---- ance/ (ino 283) +# | |---- below_ance/ (ino 279) +# | +# |---- other_dir/ (ino 284) +# +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1 + +# case 1 +# +# The directory named "d" (inode 257) has in both snapshots an entry with the +# name "p1" but it refers to different inodes in both snapshots (inode 258 in +# the parent snapshot and inode 259 in the send snapshot). When attempting to +# move inode 258, the operation is delayed because its new parent, inode 259, +# was not yet moved/renamed (as the stream is currently processing inode 258). +# Later on when processing inode 259, btrfs' send also ended up delaying the +# move/rename operation for this inode, so that it would happen after inode 258 +# was processed, creating a circular dependency that resulted in the send stream +# terminating without issuing a rename operations for the inodes 258 and 259. +# +mv $SCRATCH_MNT/case_1/d/p1 $SCRATCH_MNT/case_1/p1 +mv $SCRATCH_MNT/case_1/p1 $SCRATCH_MNT/case_1/d + +# case 2 +# +# When the inode 265 is processed, the path for inode 267 is computed, which at +# that time corresponds to "case_2/d/ance", and it was stored in the name cache +# (to avoid recomputing it again later when needed). +# Later on when processing inode 266, btrfs' send end up orphanizing (renaming +# to a name matching the pattern o--) inode 267 because it has +# the same name as inode 266 and at that time it's a child of the new parent +# directory (inode 263) for inode 266. After the orphanization and while still +# processing inode 266, a rename operation for inode 266 was generated. However +# the source path for that rename operation was incorrect because it ended up +# using the old, pre-orphanization, name of inode 267. +# +mv $SCRATCH_MNT/case_2/a/c $SCRATCH_MNT/case_2 +mv $SCRATCH_MNT/case_2/d/ance $SCRATCH_MNT/case_2/c +mv $SCRATCH_MNT/case_2/c/ance/ance $SCRATCH_MNT/case_2/d +mv $SCRATCH_MNT/case_2/c/ance/f $SCRATCH_MNT/case_2 +mv $SCRATCH_MNT/case_2/c/ance/e $SCRATCH_MNT/case_2/f + +# case 3 +# +# This is similar to cases 1 and 2, but adding more complexity just to exercise +# btrfs' incremental send correctness. +# +mv $SCRATCH_MNT/case_3/d/ance $SCRATCH_MNT/case_3/a +mv $SCRATCH_MNT/case_3/a/c $SCRATCH_MNT/case_3 +mv $SCRATCH_MNT/case_3/a/ance/waiting_dir $SCRATCH_MNT/case_3/c +mv $SCRATCH_MNT/case_3/pre/ance $SCRATCH_MNT/case_3/d +mv $SCRATCH_MNT/case_3/pre $SCRATCH_MNT/case_3/c/waiting_dir + +# case 4 +# +# When attempting to rename inode 283, the incremental send stream included an +# invalid destination path for the rename command. This was due to a missing +# path loop detection in the send code that made the rename of inode 283 happen +# without waiting for the rename of inode 284 to happen first (since it's an +# ancestor in the send snapshot that is beyond the current progress and it was +# also renamed/moved). +# +mv $SCRATCH_MNT/case_4/other_dir $SCRATCH_MNT/case_4/tmp +mv $SCRATCH_MNT/case_4/ance/below_ance $SCRATCH_MNT/case_4/tmp/other_dir +mv $SCRATCH_MNT/case_4/pre/wait_dir $SCRATCH_MNT/case_4/tmp/other_dir +mv $SCRATCH_MNT/case_4/pre $SCRATCH_MNT/case_4/tmp/other_dir/below_ance +mv $SCRATCH_MNT/case_4/desc $SCRATCH_MNT/case_4/tmp/other_dir/wait_dir +mv $SCRATCH_MNT/case_4/ance $SCRATCH_MNT/case_4/tmp/other_dir/wait_dir/desc + +# Filesystem now looks like: +# +# . (ino 256) +# |--- case_1/ (ino 257) +# | |--- d/ (ino 258) +# | |--- p1/ (ino 260) +# | |--- p1/ (ino 259) +# | +# |--- case_2/ (ino 261) +# | |---- a/ (ino 262) +# | |---- c/ (ino 268) +# | | |---- ance/ (ino 267) +# | | +# | |---- d/ (ino 263) +# | | |---- ance/ (ino 266) +# | | +# | |---- f/ (ino 265) +# | |---- e/ (ino 264) +# | +# |--- case_3/ (ino 269) +# | |---- a/ (ino 271) +# | | |---- ance/ (ino 275) +# | | +# | |---- c/ (ino 276) +# | | |---- waiting_dir/ (ino 272) +# | | |---- pre/ (ino 273) +# | | +# | |---- d/ (ino 270) +# | |---- ance/ (ino 274) +# | +# |--- case_4/ (ino 277) +# |---- tmp/ (ino 278) +# |---- other_dir/ (ino 284) +# |---- below_ance/ (ino 279) +# | |---- pre/ (ino 280) +# | +# |---- wait_dir/ (ino 281) +# |---- desc/ (ino 282) +# |---- ance/ (ino 283) +# +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2 + +run_check $FSSUM_PROG -A -f -w $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1 +run_check $FSSUM_PROG -A -f -w $send_files_dir/2.fssum \ + -x $SCRATCH_MNT/mysnap2/mysnap1 $SCRATCH_MNT/mysnap2 + +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap +_run_btrfs_util_prog send -p $SCRATCH_MNT/mysnap1 $SCRATCH_MNT/mysnap2 \ + -f $send_files_dir/2.snap + +# Now recreate the filesystem by receiving both send streams and verify we get +# the same content that the original filesystem had. +_scratch_unmount +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap +run_check $FSSUM_PROG -r $send_files_dir/1.fssum $SCRATCH_MNT/mysnap1 +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap +run_check $FSSUM_PROG -r $send_files_dir/2.fssum $SCRATCH_MNT/mysnap2 + +echo "Silence is golden" +status=0 +exit diff --git a/tests/btrfs/124.out b/tests/btrfs/124.out new file mode 100644 index 0000000..d7339e6 --- /dev/null +++ b/tests/btrfs/124.out @@ -0,0 +1,2 @@ +QA output created by 124 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index 5a26ed7..19f4688 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -126,3 +126,4 @@ 121 auto quick snapshot qgroup 122 auto quick snapshot qgroup 123 auto quick qgroup +124 auto quick send