From patchwork Sat Feb 28 21:04:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 5906251 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9DE689F269 for ; Sat, 28 Feb 2015 21:05:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 96ED42025B for ; Sat, 28 Feb 2015 21:05:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6DFD6203C1 for ; Sat, 28 Feb 2015 21:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752223AbbB1VFY (ORCPT ); Sat, 28 Feb 2015 16:05:24 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:60162 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751220AbbB1VFX (ORCPT ); Sat, 28 Feb 2015 16:05:23 -0500 Received: from debian3.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Sat, 28 Feb 2015 14:05:14 -0700 From: Filipe Manana To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH] fstests: btrfs test for incremental send with directory renames Date: Sat, 28 Feb 2015 21:04:50 +0000 Message-Id: <1425157490-24776-1-git-send-email-fdmanana@suse.com> X-Mailer: git-send-email 2.1.3 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Test for incremental send where the difference between the parent and child snapshots is that a directory A was renamed and a directory B was renamed to the name directory A had before (in the parent snapshot), but directory A's rename must happen before some other directory C is renamed. This issue was fixed by the following linux kernel btrfs patch: Btrfs: incremental send, don't rename a directory too soon Signed-off-by: Filipe Manana Reviewed-by: David Sterba --- tests/btrfs/083 | 159 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/083.out | 2 + tests/btrfs/group | 1 + 3 files changed, 162 insertions(+) create mode 100755 tests/btrfs/083 create mode 100644 tests/btrfs/083.out diff --git a/tests/btrfs/083 b/tests/btrfs/083 new file mode 100755 index 0000000..e4b6767 --- /dev/null +++ b/tests/btrfs/083 @@ -0,0 +1,159 @@ +#! /bin/bash +# FS QA Test No. btrfs/083 +# +# Test for incremental send where the difference between the parent and child +# snapshots is that a directory A was renamed and a directory B was renamed to +# the name directory A had before (in the parent snapshot), but directory A's +# rename must happen before some other directory C is renamed. +# +# This issue was fixed by the following linux kernel btrfs patch: +# +# Btrfs: incremental send, don't rename a directory too soon +# +#----------------------------------------------------------------------- +# Copyright (C) 2015 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 +_need_to_be_root + +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 + +mkdir $SCRATCH_MNT/a +mkdir $SCRATCH_MNT/b +mkdir $SCRATCH_MNT/c +touch $SCRATCH_MNT/a/file + +mkdir $SCRATCH_MNT/d +mkdir $SCRATCH_MNT/e +touch $SCRATCH_MNT/e/file2 +mkdir $SCRATCH_MNT/f + +# Filesystem looks like: +# +# . (ino 256) +# |---- a/ (ino 257) +# | |---- file (ino 260) +# | +# |---- b/ (ino 258) +# |---- c/ (ino 259) +# |---- d/ (ino 261) +# |---- e/ (ino 262) +# | |--- file2 (ino 263) +# | +# |---- f/ (ino 264) +# +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1 + +# Now make inode 257 a child of inode 259 and rename inode 258 to the name that +# inode 257 had before. When the incremental send processes inode 257, it can't +# do the rename immediately because inode 259 must be renamed first, so inode's +# 257 rename is delayed and happens after the rename for inode 259 is done. +# Since send processes inodes by ascending order of their number, inode 258 +# can't be renamed before inode 257 is renamed and therefore must be delayed +# as well. So the send stream must issue rename commands in the following order: +# +# 1 - rename inode 259 ('c' -> 'x') +# 2 - rename inode 257 ('a' -> 'x/y') +# 3 - rename inode 258 ('b' -> 'a') +# +# Before the fix mentioned above, the send stream attempted to rename inode 258 +# before inode 257 was renamed, resulting in a client error mentioning +# 'directory not empty'. +# +# Same logic applies to 'd', 'e' and 'f', but the difference is that in the +# second snapshot 'e' is associated to an inode with a lower inode number than +# in the first snapshot. +# +mv $SCRATCH_MNT/c $SCRATCH_MNT/x +mv $SCRATCH_MNT/a $SCRATCH_MNT/x/y +mv $SCRATCH_MNT/b $SCRATCH_MNT/a + +mv $SCRATCH_MNT/f $SCRATCH_MNT/f2 +mv $SCRATCH_MNT/e $SCRATCH_MNT/f2/e2 +mv $SCRATCH_MNT/d $SCRATCH_MNT/e + +# Filesystem now looks like: +# +# +# . (ino 256) +# |---- a/ (ino 258) +# |---- x/ (ino 259) +# | |---- y/ (ino 257) +# | |----- file (ino 260) +# | +# |---- e/ (ino 261) +# |---- f2/ (ino 264) +# | |----- e2/ (ino 262) +# |---- file2 (ino 263) + +_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/083.out b/tests/btrfs/083.out new file mode 100644 index 0000000..0beba30 --- /dev/null +++ b/tests/btrfs/083.out @@ -0,0 +1,2 @@ +QA output created by 083 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index fd2fa76..fe82a9c 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -85,3 +85,4 @@ 080 auto snapshot 081 auto quick clone 082 auto quick remount +083 auto quick send