2 # FS QA Test No. btrfs/058
4 # Regression test for a btrfs issue where we create a RO snapshot to use for
5 # a send operation which fails with a -ESTALE error, due to the presence of
6 # orphan inodes accessible through the snapshot's commit root but no longer
7 # present through the main root.
9 # This issue is fixed by the following linux kernel btrfs patch:
11 # Btrfs: update commit root on snapshot creation after orphan cleanup
13 #-----------------------------------------------------------------------
14 # Copyright (C) 2014 SUSE Linux Products GmbH. All Rights Reserved.
15 # Author: Filipe Manana <fdmanana@suse.com>
17 # This program is free software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License as
19 # published by the Free Software Foundation.
21 # This program is distributed in the hope that it would be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write the Free Software Foundation,
28 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #-----------------------------------------------------------------------
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
37 status=1 # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
42 if [ ! -z $XFS_IO_PID ]; then
43 kill $XFS_IO_PID > /dev/null 2>&1
48 # get standard environment, filters and checks
52 # real QA test starts here
56 # Requiring flink command tests for the presence of the -T option used
57 # to pass O_TMPFILE to open(2).
58 _require_xfs_io_command "flink"
62 _scratch_mkfs >/dev/null 2>&1
65 # Create a tmpfile file, write some data to it and leave it open, so that our
66 # main subvolume has an orphan inode item.
67 $XFS_IO_PROG -T $SCRATCH_MNT >>$seqres.full 2>&1 < <(
73 # Give it some time to the xfs_io process to create the tmpfile.
76 # With the tmpfile open, create a RO snapshot and use it for a send operation.
77 # The send operation used to fail with -ESTALE due to the presence of the
79 _run_btrfs_util_prog subvolume snapshot -r $SCRATCH_MNT $SCRATCH_MNT/mysnap
80 _run_btrfs_util_prog send $SCRATCH_MNT/mysnap -f /dev/null