4 # Memleak in overlayfs copy-up error handling path leads to panic
5 # when unmount the underlying fs.
6 # Kernel commit ab79efab0 fixed this issue.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
39 _destroy_loop_device $fs_loop_dev
40 _destroy_loop_device $upper_loop_dev
45 # get standard environment, filters and checks
49 # remove previous $seqres.full before test
52 # real QA test starts here
54 # Modify as appropriate.
57 # Use non-default scratch underlying overlay dirs, we need to check
58 # them explicity after test.
59 _require_scratch_nocheck
62 # Remove all files from previous tests
65 # setup loop images fs for overlayfs
66 lower_img=${OVL_BASE_SCRATCH_MNT}/${seq}.$$.img
67 $XFS_IO_PROG -f -c "truncate 120m" $lower_img >>$seqres.full 2>&1
68 fs_loop_dev=`_create_loop_device $lower_img`
69 $MKFS_XFS_PROG -f -n ftype=1 $fs_loop_dev >>$seqres.full 2>&1
71 # only 20m for upper dir
72 upper_img=${OVL_BASE_SCRATCH_MNT}/$$.${seq}.img
73 $XFS_IO_PROG -f -c "truncate 20m" $upper_img >>$seqres.full 2>&1
74 upper_loop_dev=`_create_loop_device $upper_img`
75 $MKFS_XFS_PROG -f -n ftype=1 $upper_loop_dev >>$seqres.full 2>&1
77 # mount underlying xfs
78 mkdir -p ${OVL_BASE_SCRATCH_MNT}/lowermnt
79 mkdir -p ${OVL_BASE_SCRATCH_MNT}/uppermnt
80 $MOUNT_PROG $fs_loop_dev ${OVL_BASE_SCRATCH_MNT}/lowermnt
81 $MOUNT_PROG $upper_loop_dev ${OVL_BASE_SCRATCH_MNT}/uppermnt
84 mkdir -p ${OVL_BASE_SCRATCH_MNT}/lowermnt/lower
85 mkdir -p ${OVL_BASE_SCRATCH_MNT}/uppermnt/upper
86 mkdir -p ${OVL_BASE_SCRATCH_MNT}/uppermnt/work
88 lowerd=${OVL_BASE_SCRATCH_MNT}/lowermnt/lower
89 upperd=${OVL_BASE_SCRATCH_MNT}/uppermnt/upper
90 workd=${OVL_BASE_SCRATCH_MNT}/uppermnt/work
92 # Create test file in lower dir, with too big a size for
93 # upper dir to copy up.
94 $XFS_IO_PROG -f -c "truncate 48m" ${lowerd}/test_file \
98 _overlay_scratch_mount_dirs $lowerd $upperd $workd
100 # the open call triggers copy-up and it will fail ENOSPC
101 $XFS_IO_PROG -f -c "o" ${SCRATCH_MNT}/test_file \
105 $UMOUNT_PROG $SCRATCH_MNT
108 _overlay_check_scratch_dirs $lowerd $upperd $workd
110 # unmount undelying xfs, this tiggers panic if memleak happens
111 $UMOUNT_PROG ${OVL_BASE_SCRATCH_MNT}/uppermnt
112 $UMOUNT_PROG ${OVL_BASE_SCRATCH_MNT}/lowermnt
115 echo "Silence is golden"