From patchwork Wed Jun 3 05:05:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 6532101 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 E44759F3D1 for ; Wed, 3 Jun 2015 05:05:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0AFB4206A7 for ; Wed, 3 Jun 2015 05:05:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBE4F206A4 for ; Wed, 3 Jun 2015 05:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750736AbbFCFFl (ORCPT ); Wed, 3 Jun 2015 01:05:41 -0400 Received: from mail-pd0-f181.google.com ([209.85.192.181]:33947 "EHLO mail-pd0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbbFCFFj (ORCPT ); Wed, 3 Jun 2015 01:05:39 -0400 Received: by pdbki1 with SMTP id ki1so148488167pdb.1 for ; Tue, 02 Jun 2015 22:05:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iCWiw/2sW8h9mGmIwsY1j8Sb1wrXGLeQ7kZHerLisCU=; b=S5xtZuy15r5BcayNxBibHoOJSDA9cLIyRt/BUzNjLAOmYGj5Gn+M9lpX2VxhjSpRVv vOYJEx7Ri1pIzTBUW3KUnKfrQa6k05MaxJtFeEvcS9MnE7h05PRsIlQMHUwCi3NTFeXu AsOqj3IpIIKqKVFjqzoBwk+wsCvBjx5V57MEsmMy5rFDPTw9Fy5fyQNOPdAmCU80Usdk zWj0CRTgYGTWnugUmSz+gta9o1pbf8zOLw8vge2lsA8piba5Q1zdmkgNeG8jyKxaLTcg hsOpV5tcnyI82qIfN3svMRU+MqakYhFVlg6yWCJJooyNS9eAjTR6CqIlpkGrZqBSZvpM qy7Q== X-Gm-Message-State: ALoCoQkFFXce8mQDIUe4+75kocoHM8gAfwlv+krUjWv+fsWEwX7mX49//a4og2j4iHXI3LPuQ/rN X-Received: by 10.70.55.199 with SMTP id u7mr56168767pdp.42.1433307939428; Tue, 02 Jun 2015 22:05:39 -0700 (PDT) Received: from mew.localdomain (c-76-104-211-44.hsd1.wa.comcast.net. [76.104.211.44]) by mx.google.com with ESMTPSA id v6sm9508559pdq.80.2015.06.02.22.05.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jun 2015 22:05:38 -0700 (PDT) From: Omar Sandoval To: fstests@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Omar Sandoval Subject: [PATCH v2] btrfs: test premature submount unmounting when deleting default subvolume Date: Tue, 2 Jun 2015 22:05:30 -0700 Message-Id: X-Mailer: git-send-email 2.4.2 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 Add a regression test for a problem where attempting to delete the default subvolume would fail (as expected), but not until after all submounts under the subvolume were unmounted. Signed-off-by: Omar Sandoval Reviewed-by: Eryu Guan --- v1->v2: - Simpler test: just depends on umount of the bind mount succeeding instead of running find. Without the patch applied, the bind mount will disappear so umount will fail. - Fix Eryu's comments (better subject, copyright, use _btrfs_get_subvolid) tests/btrfs/089 | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/089.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 84 insertions(+) create mode 100755 tests/btrfs/089 create mode 100644 tests/btrfs/089.out diff --git a/tests/btrfs/089 b/tests/btrfs/089 new file mode 100755 index 000000000000..c81df2a3b225 --- /dev/null +++ b/tests/btrfs/089 @@ -0,0 +1,81 @@ +#! /bin/bash +# FS QA Test 089 +# +# Test deleting the default subvolume, making sure that it fails and that +# submounts under it are not unmounted prematurely. This is a regression test +# for Linux commit "Btrfs: don't invalidate root dentry when subvolume deletion +# fails". +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Omar Sandoval. 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" + +here=`pwd` +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 +. ./common/filter.btrfs + +# real QA test starts here + +# Modify as appropriate. +_need_to_be_root +_supported_fs btrfs +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 +_scratch_mount + +# Create a new subvolume and make it the default subvolume. +$BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/testvol" >> $seqres.full 2>&1 \ + || _fail "couldn't create subvol" +testvol_id=$(_btrfs_get_subvolid "$SCRATCH_MNT" testvol) +$BTRFS_UTIL_PROG subvolume set-default $testvol_id "$SCRATCH_MNT" >> $seqres.full 2>&1 \ + || _fail "couldn't set default" + +# Bind-mount a directory under the default subvolume. +mkdir "$SCRATCH_MNT/testvol/testdir" +touch "$SCRATCH_MNT/testvol/testdir/testfile" +mkdir "$SCRATCH_MNT/testvol/mnt" +mount --bind "$SCRATCH_MNT/testvol/testdir" "$SCRATCH_MNT/testvol/mnt" + +# Now attempt to delete the default subvolume, which should fail. +$BTRFS_UTIL_PROG subvolume delete "$SCRATCH_MNT/testvol" >> $seqres.full 2>&1 + +# Unmount the bind mount, which should still be alive. +$UMOUNT_PROG "$SCRATCH_MNT/testvol/mnt" + +echo "Silence is golden" +status=0 +exit diff --git a/tests/btrfs/089.out b/tests/btrfs/089.out new file mode 100644 index 000000000000..a7fcdee9b767 --- /dev/null +++ b/tests/btrfs/089.out @@ -0,0 +1,2 @@ +QA output created by 089 +Silence is golden diff --git a/tests/btrfs/group b/tests/btrfs/group index ffe18bff0d21..616d060758c1 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -91,6 +91,7 @@ 086 auto quick clone 087 auto quick send 088 auto quick metadata +089 auto quick subvol 090 auto quick metadata 091 auto quick qgroup 092 auto quick send