From patchwork Fri Aug 1 10:51:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4662101 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 2CE00C0338 for ; Fri, 1 Aug 2014 09:52:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49EC820218 for ; Fri, 1 Aug 2014 09:52:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 423B42020F for ; Fri, 1 Aug 2014 09:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750852AbaHAJwM (ORCPT ); Fri, 1 Aug 2014 05:52:12 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:44889 "EHLO victor.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750738AbaHAJwL (ORCPT ); Fri, 1 Aug 2014 05:52:11 -0400 Received: from debian-vm3.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP (NOT encrypted); Fri, 01 Aug 2014 03:52:05 -0600 From: Filipe Manana To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Filipe Manana Subject: [PATCH v2] xfstests: add regression test for btrfs send with orphans Date: Fri, 1 Aug 2014 11:51:53 +0100 Message-Id: <1406890313-11780-1-git-send-email-fdmanana@suse.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406848268-20620-1-git-send-email-fdmanana@suse.com> References: <1406848268-20620-1-git-send-email-fdmanana@suse.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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Regression test for a btrfs issue where we create a RO snapshot to use for a send operation, which fails with a -ESTALE error, due to the presence of orphan inodes accessible through the snapshot's commit root but no longer present through the main root. This issue is fixed by the following linux kernel btrfs patch: Btrfs: update commit root on snapshot creation after orphan cleanup Signed-off-by: Filipe Manana --- V2: Replaced a > redirect with a >> redirect to $seqres.full, and added a sleep. tests/btrfs/057 | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/057.out | 1 + tests/btrfs/group | 1 + 3 files changed, 86 insertions(+) create mode 100755 tests/btrfs/057 create mode 100644 tests/btrfs/057.out diff --git a/tests/btrfs/057 b/tests/btrfs/057 new file mode 100755 index 0000000..1e313e9 --- /dev/null +++ b/tests/btrfs/057 @@ -0,0 +1,84 @@ +#! /bin/bash +# FS QA Test No. btrfs/057 +# +# Regression test for a btrfs issue where we create a RO snapshot to use for +# a send operation which fails with a -ESTALE error, due to the presence of +# orphan inodes accessible through the snapshot's commit root but no longer +# present through the main root. +# +# This issue is fixed by the following linux kernel btrfs patch: +# +# Btrfs: update commit root on snapshot creation after orphan cleanup +# +#----------------------------------------------------------------------- +# Copyright (C) 2014 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() +{ + if [ ! -z $XFS_IO_PID ]; then + kill $XFS_IO_PID > /dev/null 2>&1 + fi + 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 +# Requiring flink command tests for the presence of the -T option used +# to pass O_TMPFILE to open(2). +_require_xfs_io_command "flink" +_need_to_be_root + +rm -f $seqres.full + +_scratch_mkfs >/dev/null 2>&1 +_scratch_mount + +# Create a tmpfile file, write some data to it and leave it open, so that our +# main subvolume has an orphan inode item. +$XFS_IO_PROG -T $SCRATCH_MNT >>$seqres.full 2>&1 < <( + echo "pwrite 0 65536" + read +) & +XFS_IO_PID=$! + +# Give it some time to the xfs_io process to create the tmpfile. +sleep 3 + +# With the tmpfile open, create a RO snapshot and use it for a send operation. +# The send operation used to fail with -ESTALE due to the presence of the +# orphan inode. +_run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap +_run_btrfs_util_prog send $SCRATCH_MNT/mysnap -f /dev/null + +status=0 +exit diff --git a/tests/btrfs/057.out b/tests/btrfs/057.out new file mode 100644 index 0000000..b26eefe --- /dev/null +++ b/tests/btrfs/057.out @@ -0,0 +1 @@ +QA output created by 057 diff --git a/tests/btrfs/group b/tests/btrfs/group index 2da7127..ebc38c5 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -59,3 +59,4 @@ 054 auto quick 055 auto quick 056 auto quick +057 auto quick