All of lore.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: fstests@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org, Omar Sandoval <osandov@osandov.com>
Subject: [PATCH v3] btrfs: test premature submount unmounting when deleting default subvolume
Date: Fri,  5 Jun 2015 14:00:32 -0700	[thread overview]
Message-ID: <1ebef916f54960cf6fef34be950e3d38cc3a50b0.1433537929.git.osandov@osandov.com> (raw)

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.

Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Omar Sandoval <osandov@osandov.com>
---
v2->v3:
- Update description (thanks, Eryu)
- Remove unneeded touch

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     | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/089.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 82 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..537269824b62
--- /dev/null
+++ b/tests/btrfs/089
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test 089
+#
+# Test deleting the default subvolume, making sure 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"
+mkdir "$SCRATCH_MNT/testvol/mnt"
+mount --bind "$SCRATCH_MNT/testvol/testdir" "$SCRATCH_MNT/testvol/mnt"
+
+# Now attempt to delete the default subvolume.
+$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
-- 
2.4.2


             reply	other threads:[~2015-06-05 21:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-05 21:00 Omar Sandoval [this message]
2015-06-19 17:49 ` [PATCH v3] btrfs: test premature submount unmounting when deleting default subvolume Filipe David Manana
2015-06-19 17:49   ` Filipe David Manana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ebef916f54960cf6fef34be950e3d38cc3a50b0.1433537929.git.osandov@osandov.com \
    --to=osandov@osandov.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.