From patchwork Thu Jul 20 23:03:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Maggard X-Patchwork-Id: 9855791 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 E1316601C8 for ; Thu, 20 Jul 2017 23:03:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D270C20408 for ; Thu, 20 Jul 2017 23:03:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C7294204BD; Thu, 20 Jul 2017 23:03:46 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 588F220408 for ; Thu, 20 Jul 2017 23:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965066AbdGTXDo (ORCPT ); Thu, 20 Jul 2017 19:03:44 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35774 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbdGTXDm (ORCPT ); Thu, 20 Jul 2017 19:03:42 -0400 Received: by mail-pg0-f67.google.com with SMTP id d193so3845722pgc.2; Thu, 20 Jul 2017 16:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Jr4yf4tKBy9pZf4BOLXOProcAl55dVQaBIltyxKbvE0=; b=LTVsZPMH3EdJV/tVqcxYxvU+EPJ85NtOZrH1ed7fiNTg6b3dzCqkWHR14xMTs0kZlU jzpIxsaYI0tvDrHNuXTEB53lvjAp1xt9xVZ4ouUwArXEJlqukBDdEP0IaV+DXFqH2CK5 rWUPrlZ1MnSo2Wn+Msht+mRCjfCHCMvA7cwveIaBPdFCAa9q2ZieUVCpawii+NgnAw/d r3BOyexW9wTZL4DsMFOdbDgfxX/Wm1v2mc/s0pORYQz7j3mUFjocMqMbJ2VNvjnuq0y3 LF80O3hDHE9KFlMnZGRVAYScY6NY4noEosDfglfKF0K1kBdFyGL2Hzzirk4H/XRTp5R9 Zreg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Jr4yf4tKBy9pZf4BOLXOProcAl55dVQaBIltyxKbvE0=; b=d5Jz0s4yGOfbe2Zfl7VHV83HV6LYdgr3n51g4yqlymCSjllja9IngRBoWo4rwCxCvx 2akYq9qU6CtoNZx3ErofME1u1QGeBcQiB6olb/Rra4P9X8G+vzNNchFXaJjBlhIgfYf5 X6B74sKlMTibSi4S3VZ6tgbsslh18hUTDY/W4FQlwxUe4WOVtQnYfC81DutDyUeaZyV4 Dtx5lBlFWZnK9aD6hUvttgfyO1922aEPAAoMiNHoqloX0dGFo0UK/xFXmMsWB0otQ4MM ogOxGLPpcBIXk4akDKL9BRtSBG2T1bXIuWteCcNmJIRM0S/qK5v/8VsFVus8f++FVN/s 1BxQ== X-Gm-Message-State: AIVw113RZEL24MRcTuT2Ga2Xo24BFyqiRgXv8b2mz9cLX0FwJlABe07I 8VnyxYa/uZsRdot3fck= X-Received: by 10.99.119.141 with SMTP id s135mr5376062pgc.369.1500591822060; Thu, 20 Jul 2017 16:03:42 -0700 (PDT) Received: from jmaggard-thinkpad-t450s.infrant-6.com (198-0-192-140-static.hfc.comcastbusiness.net. [198.0.192.140]) by smtp.gmail.com with ESMTPSA id y6sm5943436pgq.41.2017.07.20.16.03.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Jul 2017 16:03:41 -0700 (PDT) From: Justin Maggard X-Google-Original-From: Justin Maggard To: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org Cc: Justin Maggard Subject: [PATCH] btrfs: test if receive with qgroups corrupts metadata Date: Thu, 20 Jul 2017 16:03:33 -0700 Message-Id: <20170720230333.15930-1-jmaggard@netgear.com> X-Mailer: git-send-email 2.13.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This test case does some concurrent send/receives with qgroups enabled. Currently (4.13-rc1) this usually results in btrfs check errors, and often also results in a WARN_ON in record_root_in_trans(). Bisecting points to 6426c7ad697d (btrfs: qgroup: Fix qgroup accounting when creating snapshot) as the culprit. --- tests/btrfs/149 | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/149.out | 17 +++++++++ tests/btrfs/group | 1 + 3 files changed, 119 insertions(+) create mode 100755 tests/btrfs/149 create mode 100644 tests/btrfs/149.out diff --git a/tests/btrfs/149 b/tests/btrfs/149 new file mode 100755 index 0000000..5c1912d --- /dev/null +++ b/tests/btrfs/149 @@ -0,0 +1,101 @@ +#! /bin/bash +# FS QA Test No. btrfs/149 +# +# Test that incremental send/receive operations don't corrupt metadata when +# qgroups are enabled. +# +#----------------------------------------------------------------------- +# +# Copyright (c) 2017 NETGEAR, Inc. 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() +{ + cd / + 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 + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +# Enable quotas +$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT + +# Create 2 source and 4 destination subvolumes +for subvol in subvol1 subvol2 recv1_1 recv1_2 recv2_1 recv2_2; do + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/$subvol +done +mkdir $SCRATCH_MNT/subvol{1,2}/.snapshots + +# Create base snapshots and send them +$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol1 \ + $SCRATCH_MNT/subvol1/.snapshots/1 +$BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol2 \ + $SCRATCH_MNT/subvol2/.snapshots/1 +for recv in recv1_1 recv1_2 recv2_1 recv2_2; do + $BTRFS_UTIL_PROG send $SCRATCH_MNT/subvol1/.snapshots/1 | \ + $BTRFS_UTIL_PROG receive $SCRATCH_MNT/${recv} +done + +# Now do 10 loops of concurrent incremental send/receives +for i in `seq 1 10`; do + prev=$i + curr=$((i+1)) + + $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol1 \ + $SCRATCH_MNT/subvol1/.snapshots/${curr} > /dev/null + ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol1/.snapshots/${prev} \ + $SCRATCH_MNT/subvol1/.snapshots/${curr} 2> /dev/null | \ + $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv1_1) > /dev/null & + ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol1/.snapshots/${prev} \ + $SCRATCH_MNT/subvol1/.snapshots/${curr} 2> /dev/null | \ + $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv1_2) > /dev/null & + + $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT/subvol2 \ + $SCRATCH_MNT/subvol2/.snapshots/${curr} > /dev/null + ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol2/.snapshots/${prev} \ + $SCRATCH_MNT/subvol2/.snapshots/${curr} 2> /dev/null | \ + $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv2_1) > /dev/null & + ($BTRFS_UTIL_PROG send -p $SCRATCH_MNT/subvol2/.snapshots/${prev} \ + $SCRATCH_MNT/subvol2/.snapshots/${curr} 2> /dev/null | \ + $BTRFS_UTIL_PROG receive $SCRATCH_MNT/recv2_2) > /dev/null & + wait +done + +_scratch_unmount + +status=0 +exit diff --git a/tests/btrfs/149.out b/tests/btrfs/149.out new file mode 100644 index 0000000..3ea9101 --- /dev/null +++ b/tests/btrfs/149.out @@ -0,0 +1,17 @@ +QA output created by 149 +Create subvolume '/mnt/scratch/subvol1' +Create subvolume '/mnt/scratch/subvol2' +Create subvolume '/mnt/scratch/recv1_1' +Create subvolume '/mnt/scratch/recv1_2' +Create subvolume '/mnt/scratch/recv2_1' +Create subvolume '/mnt/scratch/recv2_2' +Create a readonly snapshot of '/mnt/scratch/subvol1' in '/mnt/scratch/subvol1/.snapshots/1' +Create a readonly snapshot of '/mnt/scratch/subvol2' in '/mnt/scratch/subvol2/.snapshots/1' +At subvol /mnt/scratch/subvol1/.snapshots/1 +At subvol 1 +At subvol /mnt/scratch/subvol1/.snapshots/1 +At subvol 1 +At subvol /mnt/scratch/subvol1/.snapshots/1 +At subvol 1 +At subvol /mnt/scratch/subvol1/.snapshots/1 +At subvol 1 diff --git a/tests/btrfs/group b/tests/btrfs/group index 8240b53..a84a2bd 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -151,3 +151,4 @@ 146 auto quick 147 auto quick send 148 auto quick rw +149 auto quick metadata qgroup send