From patchwork Sun May 25 02:45: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: 4238171 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 6512CBF90B for ; Sun, 25 May 2014 01:58:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64E39202C8 for ; Sun, 25 May 2014 01:58:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5777B20295 for ; Sun, 25 May 2014 01:58:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751430AbaEYB6J (ORCPT ); Sat, 24 May 2014 21:58:09 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:45057 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751322AbaEYB6I (ORCPT ); Sat, 24 May 2014 21:58:08 -0400 Received: by mail-wi0-f177.google.com with SMTP id f8so2632091wiw.10 for ; Sat, 24 May 2014 18:58:06 -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; bh=/f26RCbMrfMHtK66oydi/mcVi/zzZF/Z+8X94DCNNJI=; b=fXbjENHGqs7eLDaRALhCl1cirUcaQ1m27CsWPt2LWdgLv3u2+TzQUVJX+ggA/0FshF bzuiYGW4rtnGaKZ845TpgZAtRiXD3SfrMhkGQmoz9hSuWd/wIYJNUaBJh+YcoBDvWl0F RlscnHm1nKQpLriPvO32gYOtihXVjMEDFddUYG/la7Qic5fHLMX/2qmWuZ1ejfl2lOMU bLVz1+99YNFxFtxoIN+wM35Dgi/f/6bOsUr4s15ucu7/9qpX5P0vpR8c0Yf0Sfyb+neg ksX9bCKnJGsMSJnVLx7z0UE4cBEpO/tZlaHM1AMb1nNFa4qa+bmNA3pOnX66BLB2CFFI vZhA== X-Received: by 10.180.185.244 with SMTP id ff20mr15299063wic.42.1400983086929; Sat, 24 May 2014 18:58:06 -0700 (PDT) Received: from debian-vm3.lan (bl10-252-12.dsl.telepac.pt. [85.243.252.12]) by mx.google.com with ESMTPSA id dk10sm11015839wib.1.2014.05.24.18.58.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 24 May 2014 18:58:06 -0700 (PDT) From: Filipe David Borba Manana To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe David Borba Manana Subject: [PATCH] xfstests: test for btrfs send when nested subvols/snapshots exist Date: Sun, 25 May 2014 03:45:24 +0100 Message-Id: <1400985924-16431-1-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 difference between the snapshots used by the incremental send consists of one of these cases: 1) First snapshot has a directory with name X and in the second snapshot that directory doesn't exist anymore but a subvolume/snapshot with the same name (X) exists; 2) First snapshot has a subvolume/snapshot with name X and in the second snapshot that subvolume/snapshot doesn't exist anymore (might have been replaced by a directory with the same name or not). This issue is fixed by the following linux kernel btrfs patches: Btrfs: send, don't error in the presence of subvols/snapshots Btrfs: set dead flag on the right root when destroying snapshot Signed-off-by: Filipe David Borba Manana --- tests/btrfs/054 | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/054.out | 1 + tests/btrfs/group | 1 + 3 files changed, 111 insertions(+) create mode 100755 tests/btrfs/054 create mode 100644 tests/btrfs/054.out diff --git a/tests/btrfs/054 b/tests/btrfs/054 new file mode 100755 index 0000000..215861c --- /dev/null +++ b/tests/btrfs/054 @@ -0,0 +1,109 @@ +#! /bin/bash +# FS QA Test No. btrfs/054 +# +# Regression test for a btrfs incremental send issue where the difference +# between the snapshots used by the incremental send consists of one of +# these cases: +# +# 1) First snapshot has a directory with name X and in the second snapshot +# that directory doesn't exist anymore but a subvolume/snapshot with +# the same name (X) exists; +# +# 2) First snapshot has a subvolume/snapshot with name X and in the second +# snapshot that subvolume/snapshot doesn't exist anymore (might have been +# replaced by a directory with the same name or not). +# +# This issue is fixed by the following linux kernel btrfs patches: +# +# Btrfs: send, don't error in the presence of subvols/snapshots +# Btrfs: set dead flag on the right root when destroying snapshot +# +#----------------------------------------------------------------------- +# 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=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -fr $send_files_dir + rm -fr $tmp +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs btrfs +_supported_os Linux +_require_scratch +_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 >/dev/null 2>&1 +_scratch_mount + +mkdir $SCRATCH_MNT/testdir +_run_btrfs_util_prog subvolume create $SCRATCH_MNT/first_subvol + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap1 + +# Replace the directory testdir with a subvolume that has the same name. +rmdir $SCRATCH_MNT/testdir +_run_btrfs_util_prog subvolume create $SCRATCH_MNT/testdir + +# Delete the subvolume first_subvol and create a directory with the same name. +_run_btrfs_util_prog subvolume delete $SCRATCH_MNT/first_subvol +mkdir $SCRATCH_MNT/first_subvol + +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap2 + +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap1 -f $send_files_dir/1.snap +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap2 -p $SCRATCH_MNT/mysnap1 \ + -f $send_files_dir/2.snap + +_scratch_unmount +_check_scratch_fs + +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/1.snap +[ -e $SCRATCH_MNT/first_subvol ] && \ + echo "Subvolume first_subvol was not supposed to be replicated by full send!" + +_run_btrfs_util_prog receive $SCRATCH_MNT -f $send_files_dir/2.snap +[ -e $SCRATCH_MNT/testdir ] && \ + echo "Directory testdir was supposed to be deleted after incremental send!" + +_check_scratch_fs + +status=0 +exit diff --git a/tests/btrfs/054.out b/tests/btrfs/054.out new file mode 100644 index 0000000..03e258b --- /dev/null +++ b/tests/btrfs/054.out @@ -0,0 +1 @@ +QA output created by 054 diff --git a/tests/btrfs/group b/tests/btrfs/group index ea49c5c..b668485 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -56,3 +56,4 @@ 051 auto quick 052 auto quick 053 auto quick +054 auto quick